chore: update masto (#506)

Co-authored-by: userquin <userquin@gmail.com>
This commit is contained in:
Daniel Roe 2022-12-22 13:48:20 +00:00 committed by GitHub
parent 8d57cfc886
commit bae4ad7d4a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 105 additions and 52 deletions

View file

@ -96,17 +96,7 @@ async function loginTo(user?: Omit<UserLogin, 'account'> & { account?: AccountCr
return masto
}
export async function removePushNotifications(user: UserLogin, fromSWPushManager = true) {
if (!useRuntimeConfig().public.pwaEnabled || !user.pushSubscription)
return
// unsubscribe push notifications
try {
await useMasto().pushSubscriptions.remove()
}
catch {
// ignore
}
export async function removePushNotificationData(user: UserLogin, fromSWPushManager = true) {
// clear push subscription
user.pushSubscription = undefined
const { acct } = user.account
@ -130,6 +120,19 @@ export async function removePushNotifications(user: UserLogin, fromSWPushManager
}
}
export async function removePushNotifications(user: UserLogin) {
if (!useRuntimeConfig().public.pwaEnabled || !user.pushSubscription)
return
// unsubscribe push notifications
try {
await useMasto().pushSubscriptions.remove()
}
catch {
// ignore
}
}
export async function signout() {
// TODO: confirm
if (!currentUser.value)
@ -149,6 +152,8 @@ export async function signout() {
await removePushNotifications(currentUser.value)
await removePushNotificationData(currentUser.value)
currentUserId.value = ''
// Remove the current user from the users
users.value.splice(index, 1)