2019-05-13 14:02:10 -06:00
|
|
|
import '../../scss/Account/main.scss';
|
|
|
|
|
|
|
|
import { renderLoginForm } from "./render";
|
2019-05-23 18:09:01 -06:00
|
|
|
import { validateToken, updateAccountData } from './login';
|
2019-05-23 15:07:10 -06:00
|
|
|
import {
|
|
|
|
uploadWords,
|
|
|
|
uploadDetails,
|
|
|
|
uploadWholeDictionary,
|
|
|
|
deleteWords
|
|
|
|
} from './sync';
|
|
|
|
import { saveDeletedWordLocally } from './utilities';
|
|
|
|
import { addMessage } from '../utilities';
|
2019-05-23 19:56:45 -06:00
|
|
|
import { updateCurrentChangeDictionaryOption, deleteDictionary } from './dictionaryManagement';
|
2019-05-13 14:02:10 -06:00
|
|
|
|
|
|
|
export function showLoginForm() {
|
|
|
|
renderLoginForm();
|
2019-05-21 16:29:05 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
export function loginWithToken() {
|
2019-05-23 16:06:16 -06:00
|
|
|
validateToken();
|
2019-05-22 20:22:57 -06:00
|
|
|
}
|
|
|
|
|
2019-05-23 18:09:01 -06:00
|
|
|
export function editAccount(accountData) {
|
|
|
|
updateAccountData(accountData);
|
|
|
|
}
|
|
|
|
|
2019-05-23 12:03:25 -06:00
|
|
|
export function syncImportedDictionary() {
|
|
|
|
uploadWholeDictionary(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
export function uploadDetailsDirect() {
|
2019-05-23 15:24:56 -06:00
|
|
|
uploadDetails().catch(err => {
|
|
|
|
console.error(err);
|
|
|
|
addMessage('Could not connect to account. Trying again in 10 seconds.', undefined, 'error');
|
|
|
|
setTimeout(() => {
|
|
|
|
uploadDetails();
|
|
|
|
}, 10000);
|
|
|
|
});
|
2019-05-23 12:03:25 -06:00
|
|
|
}
|
|
|
|
|
2019-05-22 20:22:57 -06:00
|
|
|
export function uploadWord(word) {
|
2019-05-23 15:24:56 -06:00
|
|
|
uploadWords([word]).catch(err => {
|
|
|
|
console.error(err);
|
|
|
|
addMessage('Could not connect to account. Trying again in 10 seconds.', undefined, 'error');
|
|
|
|
setTimeout(() => {
|
|
|
|
uploadWord(word);
|
|
|
|
}, 10000);
|
|
|
|
});
|
2019-05-23 12:03:25 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
export function syncImportedWords(words) {
|
|
|
|
uploadWords(words);
|
2019-05-23 15:07:10 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
export function deleteWord(wordId) {
|
|
|
|
deleteWords([wordId]).catch(err => {
|
|
|
|
console.error(err);
|
|
|
|
saveDeletedWordLocally(wordId);
|
2019-05-23 15:24:56 -06:00
|
|
|
addMessage('Could not connect to account. Trying again in 10 seconds.', undefined, 'error');
|
2019-05-23 15:07:10 -06:00
|
|
|
setTimeout(() => {
|
|
|
|
deleteWord(wordId);
|
|
|
|
}, 10000);
|
|
|
|
});
|
2019-05-23 17:00:13 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
export function updateChangeDictionaryOption() {
|
|
|
|
updateCurrentChangeDictionaryOption();
|
2019-05-23 19:56:45 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
export function deleteCurrentDictionary(deletedId) {
|
|
|
|
deleteDictionary(deletedId);
|
2019-05-13 14:02:10 -06:00
|
|
|
}
|