Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/marius-wieschollek/passwords-webextension.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarius David Wieschollek <passwords.public@mdns.eu>2021-12-13 18:10:15 +0300
committerMarius David Wieschollek <passwords.public@mdns.eu>2021-12-13 18:10:15 +0300
commit0bcedae9d584d3e89e1b0e022367403e24e113da (patch)
treefee694c068abfc393e344b94b033d9f34c918c4d
parent5fa8e97088a845388b3d2f58be0a2d8c3e726487 (diff)
[#203] Fix authorisation window not closing
-rw-r--r--src/js/Queue/Client/AuthorisationClient.js10
-rw-r--r--src/js/Services/PopupStateService.js23
-rw-r--r--src/vue/App/Popup.vue13
-rw-r--r--src/vue/Components/Popup/Authorisation.vue37
4 files changed, 57 insertions, 26 deletions
diff --git a/src/js/Queue/Client/AuthorisationClient.js b/src/js/Queue/Client/AuthorisationClient.js
index 5066d0c..918b256 100644
--- a/src/js/Queue/Client/AuthorisationClient.js
+++ b/src/js/Queue/Client/AuthorisationClient.js
@@ -1,6 +1,6 @@
-import Popup from '@js/App/Popup';
import AuthorisationItem from '@js/Models/Queue/AuthorisationItem';
-import FeedbackClient from '@js/Queue/Client/FeedbackClient';
+import FeedbackClient from '@js/Queue/Client/FeedbackClient';
+import PopupStateService from '@js/Services/PopupStateService';
export default class AuthorisationClient extends FeedbackClient {
@@ -61,7 +61,7 @@ export default class AuthorisationClient extends FeedbackClient {
reject
};
- if(Popup.app) Popup.app.authorized = false;
+ PopupStateService.setStatus('authorized', false);
});
}
@@ -87,7 +87,7 @@ export default class AuthorisationClient extends FeedbackClient {
resolve();
if(Object.keys(this._items).length === 0) {
- if(Popup.app) Popup.app.authorized = true;
+ PopupStateService.setStatus('authorized', true);
}
return;
@@ -100,7 +100,7 @@ export default class AuthorisationClient extends FeedbackClient {
reject
};
- if(Popup.app) Popup.app.authorized = false;
+ PopupStateService.setStatus('authorized', false);
});
}
} \ No newline at end of file
diff --git a/src/js/Services/PopupStateService.js b/src/js/Services/PopupStateService.js
index 2254deb..24113df 100644
--- a/src/js/Services/PopupStateService.js
+++ b/src/js/Services/PopupStateService.js
@@ -1,12 +1,23 @@
import MessageService from "@js/Services/MessageService";
-import ErrorManager from "@js/Manager/ErrorManager";
+import ErrorManager from "@js/Manager/ErrorManager";
+import EventQueue from '@js/Event/EventQueue';
export default new class PopupStateService {
+ get change() {
+ return this._dataEvents;
+ }
+
+ get status() {
+ return this._statusEvents;
+ }
+
constructor() {
this._tab = 'related';
this._data = {};
this._status = {};
+ this._dataEvents = new EventQueue();
+ this._statusEvents = new EventQueue();
this._defaults = {
'search.query': ''
@@ -56,6 +67,15 @@ export default new class PopupStateService {
}
/**
+ * @param {String} key
+ * @param {*} value
+ */
+ setStatus(key, value) {
+ this._status[key] = [value];
+ this._statusEvents.emit({key, value});
+ }
+
+ /**
* @param {(String|String[])} key
* @param {(String|null)} [tab=null]
* @returns {*}
@@ -133,6 +153,7 @@ export default new class PopupStateService {
if(tab === null) tab = this._tab;
if(!this._data.hasOwnProperty(tab)) this._data[tab] = {};
this._data[tab][key] = value;
+ this._dataEvents.emit({tab, key, value});
}
/**
diff --git a/src/vue/App/Popup.vue b/src/vue/App/Popup.vue
index aaf5fb8..b9e19f3 100644
--- a/src/vue/App/Popup.vue
+++ b/src/vue/App/Popup.vue
@@ -47,6 +47,16 @@
}
},
+ data() {
+ PopupStateService.status.on((data) => {
+ if(data.key === 'authorized') this.authorized = data.value;
+ });
+
+ return {
+ authorized: PopupStateService.getStatus('authorized')
+ }
+ },
+
computed: {
tab() {
return PopupStateService.getTab();
@@ -54,9 +64,6 @@
firstRun() {
return PopupStateService.getStatus('firstRun');
},
- authorized() {
- return PopupStateService.getStatus('authorized');
- },
tabs() {
return {
related : {
diff --git a/src/vue/Components/Popup/Authorisation.vue b/src/vue/Components/Popup/Authorisation.vue
index 3f83ff9..f7eb8c0 100644
--- a/src/vue/Components/Popup/Authorisation.vue
+++ b/src/vue/Components/Popup/Authorisation.vue
@@ -36,15 +36,16 @@
</template>
<script>
- import MessageService from '@js/Services/MessageService';
- import Translate from '@vue/Components/Translate';
- import Icon from '@vue/Components/Icon';
- import Popup from '@js/App/Popup';
- import ToastService from '@js/Services/ToastService';
- import InputField from '@vue/Components/Form/InputField';
- import ButtonField from '@vue/Components/Form/ButtonField';
- import SelectField from '@vue/Components/Form/SelectField';
- import ErrorManager from '@js/Manager/ErrorManager';
+ import MessageService from '@js/Services/MessageService';
+ import Translate from '@vue/Components/Translate';
+ import Icon from '@vue/Components/Icon';
+ import Popup from '@js/App/Popup';
+ import ToastService from '@js/Services/ToastService';
+ import InputField from '@vue/Components/Form/InputField';
+ import ButtonField from '@vue/Components/Form/ButtonField';
+ import SelectField from '@vue/Components/Form/SelectField';
+ import ErrorManager from '@js/Manager/ErrorManager';
+ import PopupStateService from '@js/Services/PopupStateService';
export default {
components: {SelectField, ButtonField, InputField, Icon, Translate},
@@ -114,7 +115,7 @@
this.focus();
});
} else {
- this.$parent.authorized = true;
+ PopupStateService.setStatus('authorized', true);
}
},
focus() {
@@ -202,21 +203,23 @@
watch: {
provider(value) {
- let provider = this.getProvider(value);
- if(provider) {
- this.tokenField = provider.hasInput;
- this.tokenRequest = provider.hasRequest;
+ if(value) {
+ let provider = this.getProvider(value);
+ if(provider) {
+ this.tokenField = provider.hasInput;
+ this.tokenRequest = provider.hasRequest;
+ }
}
this.token = null;
- this.authRequest.setProvider(value);
+ if(this.authRequest) this.authRequest.setProvider(value);
if(this.tokenRequest && value) this.requestToken();
},
token(value) {
- this.authRequest.setToken(value);
+ if(this.authRequest) this.authRequest.setToken(value);
},
password(value) {
- this.authRequest.setPassword(value);
+ if(this.authRequest) this.authRequest.setPassword(value);
}
}
};