mirror of
https://github.com/Alamantus/Lexiconga.git
synced 2025-05-19 08:31:25 +02:00
72 lines
No EOL
1.7 KiB
JavaScript
72 lines
No EOL
1.7 KiB
JavaScript
import '../../scss/Account/main.scss';
|
|
|
|
import { renderLoginForm } from "./render";
|
|
import { validateToken, updateAccountData } from './login';
|
|
import {
|
|
uploadWords,
|
|
uploadDetails,
|
|
uploadWholeDictionary,
|
|
deleteWords
|
|
} from './sync';
|
|
import { saveDeletedWordLocally } from './utilities';
|
|
import { addMessage } from '../utilities';
|
|
import { updateCurrentChangeDictionaryOption, deleteDictionary } from './dictionaryManagement';
|
|
|
|
export function showLoginForm() {
|
|
renderLoginForm();
|
|
}
|
|
|
|
export function loginWithToken() {
|
|
validateToken();
|
|
}
|
|
|
|
export function editAccount(accountData) {
|
|
updateAccountData(accountData);
|
|
}
|
|
|
|
export function syncImportedDictionary() {
|
|
uploadWholeDictionary(true);
|
|
}
|
|
|
|
export function uploadDetailsDirect() {
|
|
uploadDetails().catch(err => {
|
|
console.error(err);
|
|
addMessage('Could not connect to account. Trying again in 10 seconds.', undefined, 'error');
|
|
setTimeout(() => {
|
|
uploadDetails();
|
|
}, 10000);
|
|
});
|
|
}
|
|
|
|
export function uploadWord(word) {
|
|
uploadWords([word]).catch(err => {
|
|
console.error(err);
|
|
addMessage('Could not connect to account. Trying again in 10 seconds.', undefined, 'error');
|
|
setTimeout(() => {
|
|
uploadWord(word);
|
|
}, 10000);
|
|
});
|
|
}
|
|
|
|
export function syncImportedWords(words) {
|
|
uploadWords(words);
|
|
}
|
|
|
|
export function deleteWord(wordId) {
|
|
deleteWords([wordId]).catch(err => {
|
|
console.error(err);
|
|
saveDeletedWordLocally(wordId);
|
|
addMessage('Could not connect to account. Trying again in 10 seconds.', undefined, 'error');
|
|
setTimeout(() => {
|
|
deleteWord(wordId);
|
|
}, 10000);
|
|
});
|
|
}
|
|
|
|
export function updateChangeDictionaryOption() {
|
|
updateCurrentChangeDictionaryOption();
|
|
}
|
|
|
|
export function deleteCurrentDictionary(deletedId) {
|
|
deleteDictionary(deletedId);
|
|
} |