Repetition settings base
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
use std::fs;
|
||||
use crate::dictionary::app_data_dir;
|
||||
use crate::lang::WordOpenMode;
|
||||
use chrono::{DateTime, Utc};
|
||||
@@ -7,7 +8,7 @@ use std::io::{BufRead, BufReader};
|
||||
use std::path::PathBuf;
|
||||
|
||||
pub fn get_history_of_set(id: u32) -> Vec<HistoryItem> {
|
||||
let app_dir = app_data_dir();
|
||||
let app_dir = history_dir();
|
||||
let head = app_dir.clone().join(format!("set_{}_history.csv", id));
|
||||
let mut lines = Vec::new();
|
||||
|
||||
@@ -48,7 +49,7 @@ fn parse_history_items(strings: Vec<String>) -> Vec<HistoryItem> {
|
||||
}
|
||||
|
||||
pub fn push_note(set_id: u32, item: HistoryItem) {
|
||||
let app_dir = app_data_dir();
|
||||
let app_dir = history_dir();
|
||||
let path = app_dir.clone().join(format!("set_{}_history.csv", set_id));
|
||||
|
||||
let mut file = OpenOptions::new()
|
||||
@@ -72,6 +73,14 @@ pub fn push_note(set_id: u32, item: HistoryItem) {
|
||||
writeln!(&mut file, "{}", line_str.to_string()).unwrap();
|
||||
}
|
||||
|
||||
pub fn history_dir() -> PathBuf {
|
||||
let directory = app_data_dir().join("history");
|
||||
if !directory.exists() {
|
||||
fs::create_dir(directory.clone()).unwrap();
|
||||
}
|
||||
directory
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct HistoryItem {
|
||||
pub timestamp: DateTime<Utc>,
|
||||
|
||||
Reference in New Issue
Block a user