Prepare for new anki format
This commit is contained in:
1 parent
0de809fcce
commit
ccfb302770
2 files changed
+34
-11
No files matched your search
@@ -5,6 +5,7 @@ use log::info;
|
||||
use rusqlite::Connection;
|
||||
use serde_json::Value;
|
||||
use std::collections::BTreeMap;
|
||||
use crate::pages::import::AnkiSchema;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct ImportData(pub(crate) Vec<ImportGroup>);
|
||||
@@ -25,7 +26,18 @@ pub struct ImportNote {
|
||||
pub fields: Vec<String>,
|
||||
}
|
||||
|
||||
pub fn load_groups(connection: &Connection) -> Result<ImportData, NotificationData> {
|
||||
pub fn load_groups(connection: &Connection, schema: AnkiSchema) -> Result<ImportData, NotificationData> {
|
||||
match schema {
|
||||
AnkiSchema::Old => {
|
||||
load_old_schema(connection)
|
||||
}
|
||||
AnkiSchema::Beta => {
|
||||
load_new_schema(connection)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn load_old_schema(connection: &Connection) -> Result<ImportData, NotificationData> {
|
||||
let json_models: String = connection
|
||||
.query_one("select models from col", (), |row| row.get(0))
|
||||
.map_err(|_| IncorrectAnkiFile)?;
|
||||
@@ -82,7 +94,9 @@ pub fn load_groups(connection: &Connection) -> Result<ImportData, NotificationDa
|
||||
}
|
||||
Err(IncorrectAnkiFile)
|
||||
}
|
||||
|
||||
fn load_new_schema(connection: &Connection) -> Result<ImportData, NotificationData> {
|
||||
return Err(IncorrectAnkiFile);
|
||||
}
|
||||
pub fn get_words_of_group(
|
||||
connection: &Connection,
|
||||
group_id: u64,
|
||||
|
||||
Reference in new issue
Block a user