Работа над профилями

This commit is contained in:
Book Pauk
2019-03-17 16:14:03 +07:00
parent 02e6f392b4
commit a13146d722

View File

@@ -36,6 +36,7 @@ class ServerStorage extends Vue {
this.oldProfiles = this.profiles; this.oldProfiles = this.profiles;
await this.loadProfiles(); await this.loadProfiles();
this.checkCurrentProfile();
} }
get settings() { get settings() {
@@ -58,6 +59,12 @@ class ServerStorage extends Vue {
return this.$store.state.reader.currentProfile; return this.$store.state.reader.currentProfile;
} }
checkCurrentProfile() {
if (!this.profiles[this.currentProfile]) {
this.commit('reader/setCurrentProfile', '');
}
}
notifySuccessIfNeeded(rev1, rev2) { notifySuccessIfNeeded(rev1, rev2) {
if (rev1 != rev2) if (rev1 != rev2)
this.$notify.success({message: 'Данные синхронизированы с сервером'}); this.$notify.success({message: 'Данные синхронизированы с сервером'});
@@ -89,10 +96,6 @@ class ServerStorage extends Vue {
this.oldProfiles = this.profiles; this.oldProfiles = this.profiles;
if (!this.profiles[this.currentProfile]) {
this.commit('reader/setCurrentProfile', '');
}
this.notifySuccessIfNeeded(oldRev, prof.rev); this.notifySuccessIfNeeded(oldRev, prof.rev);
} else { } else {
this.warning(`Неверный ответ сервера: ${prof.state}`); this.warning(`Неверный ответ сервера: ${prof.state}`);
@@ -125,9 +128,7 @@ class ServerStorage extends Vue {
if (tries >= maxSetTries) { if (tries >= maxSetTries) {
this.commit('reader/setProfiles', this.oldProfiles); this.commit('reader/setProfiles', this.oldProfiles);
if (!this.profiles[this.currentProfile]) { this.checkCurrentProfile();
this.commit('reader/setCurrentProfile', '');
}
this.error('Не удалось отправить данные на сервер'); this.error('Не удалось отправить данные на сервер');
} else { } else {
this.oldProfiles = this.profiles; this.oldProfiles = this.profiles;