Migrate to Id type

This commit is contained in:
2026-08-18 12:47:06 +03:00
parent 99b3818181
commit 97c76350e1
12 changed files with 106 additions and 62 deletions
+8 -8
View File
@@ -2,7 +2,7 @@ use crate::data_provider::words::{delete_group, delete_word, update_group, updat
use crate::dictionary::DictionaryMessage::*;
use crate::dictionary_test::DictionaryQuizState;
use crate::import::ImportState;
use crate::lang::{WordData, WordGroup};
use crate::lang::{WordData, WordGroup, INVALID_ID};
use crate::navigation::Page::{Import, Word};
use crate::navigation::{NavigatedPage, Page};
use crate::styling::*;
@@ -96,7 +96,7 @@ impl NavigatedPage<DictionaryMessage> for DictionaryState {
let dict = &state.dictionary;
word = dict[*index].clone();
}
if word.id != 0 {
if word.id != INVALID_ID {
return Some(Word(WordState::new(word, *index, self.state.clone())));
}
}
@@ -172,7 +172,7 @@ impl NavigatedPage<DictionaryMessage> for DictionaryState {
}
Include(i, b) => self.include_map[i] = b,
IncludeTag(t, v) => {
let index: u32;
let index;
{
let state = self.state.lock().unwrap();
index = state.word_groups[self.selected_group_index].id;
@@ -197,7 +197,7 @@ impl NavigatedPage<DictionaryMessage> for DictionaryState {
let state = &mut self.state.lock().unwrap();
state.word_groups.push(WordGroup {
id: 0,
id: 0.into(),
name: format!("Группа слов {}", random_range(100..1000)),
});
}
@@ -222,7 +222,7 @@ impl NavigatedPage<DictionaryMessage> for DictionaryState {
}
SelectGroup(i) => {
self.selected_group_index = i;
let index: u32;
let index;
{
let state = self.state.lock().unwrap();
index = state.word_groups[i].id;
@@ -423,7 +423,7 @@ impl DictionaryState {
let line_button = || {
let action = WordAction(index);
if data.id == 0 {
if data.id == INVALID_ID {
return button("-").on_press(action).style(|_x, _status| Style {
background: None,
text_color: Color::BLACK,
@@ -532,7 +532,7 @@ impl DictionaryState {
});
}
fn update_words_include(&mut self, group_id: u32) {
fn update_words_include(&mut self, group_id: crate::lang::Id) {
let include_tags = self
.tag_map
.iter()
@@ -626,6 +626,6 @@ struct WordLineState {
key: String,
value: String,
tags: String,
id: u32,
id: crate::lang::Id,
index: usize,
}