Fix history bug
This commit is contained in:
1 parent
9456eec2af
commit
c5c1f34e1c
7 files changed
+38
-34
No files matched your search
+17
-6
@@ -1,9 +1,8 @@
|
||||
use crate::data_provider::history::{HistoryItem, get_history_of_set};
|
||||
use crate::lang::WordData;
|
||||
use crate::data_provider::history::{get_history_of_set, HistoryItem};
|
||||
use crate::lang::{WordData, INVALID_ID};
|
||||
use crate::navigation::{NavigatedPage, Page};
|
||||
use crate::styling::*;
|
||||
use crate::{AppState, RootMessage};
|
||||
use HistoryMessage::Back;
|
||||
use chrono::Local;
|
||||
use iced::alignment::Horizontal::Center;
|
||||
use iced::widget::space::horizontal;
|
||||
@@ -11,6 +10,7 @@ use iced::widget::*;
|
||||
use iced::{Element, Fill, FillPortion, Task};
|
||||
use parking_lot::Mutex;
|
||||
use std::sync::Arc;
|
||||
use HistoryMessage::Back;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct HistoryState {
|
||||
@@ -52,8 +52,19 @@ impl HistoryState {
|
||||
let history = get_history_of_set(id);
|
||||
let words = history
|
||||
.iter()
|
||||
.filter_map(|item| state.dictionary.iter().find(|w| w.id == item.word_id))
|
||||
.cloned()
|
||||
.map(
|
||||
|item| match state.dictionary.iter().find(|w| w.id == item.word_id) {
|
||||
None => WordData {
|
||||
id,
|
||||
key: "Удаленное слово".to_string(),
|
||||
value: "Удаленное слово".to_string(),
|
||||
tags: "Удаленное слово".to_string(),
|
||||
additional: Default::default(),
|
||||
group_id: INVALID_ID,
|
||||
},
|
||||
Some(word) => word.clone(),
|
||||
},
|
||||
)
|
||||
.collect();
|
||||
|
||||
Self {
|
||||
@@ -64,7 +75,7 @@ impl HistoryState {
|
||||
|
||||
fn history_lines(&self) -> Column<'_, HistoryMessage> {
|
||||
let mut column = Column::new();
|
||||
for (item, index) in self.list.iter().zip(0..self.list.len()) {
|
||||
for (index, item) in self.list.iter().enumerate() {
|
||||
column = column.push(
|
||||
row![
|
||||
iced::widget::column![
|
||||
|
||||
Reference in new issue
Block a user