mirror of
				https://github.com/Alamantus/Lexiconga.git
				synced 2025-11-04 10:17:01 +01:00 
			
		
		
		
	Add commented outline for syncing in sync.js
This commit is contained in:
		
							parent
							
								
									d4d46c7afe
								
							
						
					
					
						commit
						62dad867e0
					
				
					 1 changed files with 27 additions and 0 deletions
				
			
		| 
						 | 
					@ -2,6 +2,33 @@ import { addMessage } from "../utilities";
 | 
				
			||||||
import { saveDictionary } from "../dictionaryManagement";
 | 
					import { saveDictionary } from "../dictionaryManagement";
 | 
				
			||||||
import { request, saveToken } from "./helpers";
 | 
					import { request, saveToken } from "./helpers";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Outline for syncing
 | 
				
			||||||
 | 
					login
 | 
				
			||||||
 | 
					-> check local dictionary id
 | 
				
			||||||
 | 
					  (DONE!) ? no id
 | 
				
			||||||
 | 
					    -> upload dictionary
 | 
				
			||||||
 | 
					    -> make new dictionary current
 | 
				
			||||||
 | 
					  ? mismatched id
 | 
				
			||||||
 | 
					    -> sync local dictionary (see 'same id' below)
 | 
				
			||||||
 | 
					      -> if no matching remote id, ignore (assume deleted)
 | 
				
			||||||
 | 
					    -> clear local dictionary
 | 
				
			||||||
 | 
					    -> insert downloaded dictionary
 | 
				
			||||||
 | 
					  ? same id
 | 
				
			||||||
 | 
					    -> compare detail last updated timestamp
 | 
				
			||||||
 | 
					      ? downloaded details are newer
 | 
				
			||||||
 | 
					        -> replace local details
 | 
				
			||||||
 | 
					      ? local details are newer
 | 
				
			||||||
 | 
					        -> flag to upload details
 | 
				
			||||||
 | 
					    -> filter deleted words from current words
 | 
				
			||||||
 | 
					      -- check id and compare deletedOn with createdOn
 | 
				
			||||||
 | 
					    -> compare each word and by lastUpdated/createdOn
 | 
				
			||||||
 | 
					      ? downloaded word is newer
 | 
				
			||||||
 | 
					        -> update local word
 | 
				
			||||||
 | 
					      ? local word is newer
 | 
				
			||||||
 | 
					        -> put word in an array to upload
 | 
				
			||||||
 | 
					    -> upload anything that needs update
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export function syncDictionary() {
 | 
					export function syncDictionary() {
 | 
				
			||||||
  if (!window.currentDictionary.hasOwnProperty('externalId')) {
 | 
					  if (!window.currentDictionary.hasOwnProperty('externalId')) {
 | 
				
			||||||
    uploadWholeDictionary(true);
 | 
					    uploadWholeDictionary(true);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue