Migrate to Id type

This commit is contained in:
micialware committed 2026-08-18 12:47:06 +03:00
1 parent 99b3818181
commit 97c76350e1
12 files changed
+106 -62

No files matched your search

+5 -5
View File
@@ -1,5 +1,5 @@
use crate::dictionary::app_data_dir;
use crate::lang::WordOpenMode;
use crate::lang::{Id, WordOpenMode};
use chrono::{DateTime, Utc};
use std::fs;
use std::fs::{File, OpenOptions};
@@ -7,7 +7,7 @@ use std::io::Write;
use std::io::{BufRead, BufReader};
use std::path::PathBuf;
pub fn get_history_of_set(id: u32) -> Vec<HistoryItem> {
pub fn get_history_of_set(id: Id) -> Vec<HistoryItem> {
let app_dir = history_dir();
let head = app_dir.clone().join(format!("set_{}_history.csv", id));
let mut lines = Vec::new();
@@ -32,7 +32,7 @@ fn parse_history_items(strings: Vec<String>) -> Vec<HistoryItem> {
if let [time, word, mode, before, after] = string.split(';').collect::<Vec<&str>>()[..] {
items.push(HistoryItem {
timestamp: DateTime::from_timestamp(time.parse().unwrap(), 0).unwrap(),
word_id: word.parse::<u32>().unwrap(),
word_id: word.parse::<u32>().unwrap().into(),
mode: match mode.parse::<u8>().unwrap() {
2 => WordOpenMode::Hard,
3 => WordOpenMode::Ok,
@@ -48,7 +48,7 @@ fn parse_history_items(strings: Vec<String>) -> Vec<HistoryItem> {
items
}
pub fn push_note(set_id: u32, item: HistoryItem) {
pub fn push_note(set_id: Id, item: HistoryItem) {
let app_dir = history_dir();
let path = app_dir.clone().join(format!("set_{}_history.csv", set_id));
@@ -84,7 +84,7 @@ pub fn history_dir() -> PathBuf {
#[derive(Clone)]
pub struct HistoryItem {
pub timestamp: DateTime<Utc>,
pub word_id: u32,
pub word_id: Id,
pub mode: WordOpenMode,
pub before: u8,
pub after: u8,