@@ -7,6 +7,7 @@ export interface ParsedSaveData {
77 correctQuestionIds : number [ ] ;
88 views : View [ ] ;
99 language : string ;
10+ engine : string ;
1011}
1112
1213export interface MergeConflict {
@@ -41,6 +42,11 @@ export function parseImportFile(data: string): ParsedSaveData {
4142 const commentLangMatch = data . match ( / ^ - - L a n g u a g e : ( \w + ) $ / m) ;
4243 const language = structuredLangMatch ? structuredLangMatch [ 1 ] : ( commentLangMatch ? commentLangMatch [ 1 ] : "sv" ) ;
4344
45+ const structuredEngineMatch = data . match (
46+ / \/ \* \s - - - B E G I N S a v e E n g i n e - - - \* \/ \n - - \s ( \w + ) \n \/ \* \s - - - E N D S a v e E n g i n e - - - \* \/ /
47+ ) ;
48+ const engine = structuredEngineMatch ? structuredEngineMatch [ 1 ] : "sqlite" ;
49+
4450 const rawQueriesMatch = data . match (
4551 / \/ \* \s - - - B E G I N R a w Q u e r i e s - - - \* \/ \n \/ \* \n ( [ \s \S ] * ?) \n \* \/ \n \/ \* \s - - - E N D R a w Q u e r i e s - - - \* \/ /
4652 ) ;
@@ -78,11 +84,11 @@ export function parseImportFile(data: string): ParsedSaveData {
7884 }
7985 }
8086
81- return { rawQueries, correctQueries, writtenQuestionIds, correctQuestionIds, views, language } ;
87+ return { rawQueries, correctQueries, writtenQuestionIds, correctQuestionIds, views, language, engine } ;
8288}
8389
84- export function getLocalData ( langPrefix : string = "sv" ) : ParsedSaveData {
85- const pfx = `${ langPrefix } :` ;
90+ export function getLocalData ( lang : string = "sv" , engine : string = "sqlite ") : ParsedSaveData {
91+ const pfx = `${ lang } : ${ engine } :` ;
8692 const writtenQuestionIds : number [ ] = JSON . parse (
8793 localStorage . getItem ( `${ pfx } writtenQuestions` ) || "[]"
8894 ) ;
@@ -104,7 +110,7 @@ export function getLocalData(langPrefix: string = "sv"): ParsedSaveData {
104110
105111 const views : View [ ] = JSON . parse ( localStorage . getItem ( `${ pfx } views` ) || "[]" ) ;
106112
107- return { rawQueries, correctQueries, writtenQuestionIds, correctQuestionIds, views, language : langPrefix } ;
113+ return { rawQueries, correctQueries, writtenQuestionIds, correctQuestionIds, views, language : lang , engine } ;
108114}
109115
110116export function detectConflicts (
@@ -281,5 +287,5 @@ export function buildMergedData(
281287 new Set ( [ ...local . correctQuestionIds , ...imported . correctQuestionIds ] )
282288 ) . filter ( ( id ) => String ( id ) in correctQueries ) ;
283289
284- return { rawQueries, correctQueries, writtenQuestionIds, correctQuestionIds, views, language : local . language } ;
290+ return { rawQueries, correctQueries, writtenQuestionIds, correctQuestionIds, views, language : local . language , engine : local . engine } ;
285291}
0 commit comments