1
0
forked from mirror/misskey

Merge branch '7749' into swn

This commit is contained in:
tamaina 2021-08-31 21:47:30 +09:00
commit 1922ab6c00
6 changed files with 34 additions and 18 deletions

@ -0,0 +1 @@
Subproject commit 85b4313dbea6b9765aec2f865977bb7fe8750bab

1
misskey-assets Submodule

@ -0,0 +1 @@
Subproject commit 0179793ec891856d6f37a3be16ba4c22f67a81b5

View File

@ -1,4 +1,4 @@
import { get, set } from '@client/scripts/idb-proxy';
import { del, get, set } from '@client/scripts/idb-proxy';
import { reactive } from 'vue';
import { apiUrl } from '@client/config';
import { waiting } from '@client/os';
@ -26,14 +26,17 @@ export async function signout() {
//#region Remove account
const accounts = await getAccounts();
accounts.splice(accounts.findIndex(x => x.id === $i.id), 1);
set('accounts', accounts);
if (accounts.length > 0) await set('accounts', accounts);
else await del('accounts');
//#endregion
//#region Remove push notification registration
//#region Remove service worker registration
try {
if (navigator.serviceWorker.controller) {
const registration = await navigator.serviceWorker.ready;
const push = await registration.pushManager.getSubscription();
if (!push) return;
if (push) {
await fetch(`${apiUrl}/sw/unregister`, {
method: 'POST',
body: JSON.stringify({
@ -41,6 +44,15 @@ export async function signout() {
endpoint: push.endpoint,
}),
});
}
}
if (accounts.length === 0) {
await navigator.serviceWorker.getRegistrations()
.then(registrations => {
return Promise.all(registrations.map(registration => registration.unregister()));
});
}
} catch (e) {}
//#endregion

View File

@ -111,7 +111,9 @@ export default defineComponent({
onLogin(res) {
if (this.autoSet) {
login(res.i);
return login(res.i);
} else {
return;
}
},
@ -144,7 +146,7 @@ export default defineComponent({
});
}).then(res => {
this.$emit('login', res);
this.onLogin(res);
return this.onLogin(res);
}).catch(err => {
if (err === null) return;
os.dialog({

View File

@ -178,14 +178,14 @@ export default defineComponent({
'hcaptcha-response': this.hCaptchaResponse,
'g-recaptcha-response': this.reCaptchaResponse,
}).then(() => {
os.api('signin', {
return os.api('signin', {
username: this.username,
password: this.password
}).then(res => {
this.$emit('signup', res);
if (this.autoSet) {
login(res.i);
return login(res.i);
}
});
}).catch(() => {

View File

@ -53,7 +53,7 @@ export default defineComponent({
username: this.username,
password: this.password,
}).then(res => {
login(res.i);
return login(res.token);
}).catch(() => {
this.submitting = false;