refactor: initialise masto outside of functions/handlers

This commit is contained in:
Daniel Roe 2022-12-25 15:04:50 +01:00
parent 03d3775011
commit 720b5114af
No known key found for this signature in database
GPG key ID: 22D5008E4F5D9B55
13 changed files with 44 additions and 30 deletions

View file

@ -11,10 +11,11 @@ const isSelf = $computed(() => currentUser.value?.account.id === account.id)
const enable = $computed(() => !isSelf && currentUser.value)
const relationship = $computed(() => props.relationship || useRelationship(account).value)
const masto = useMasto()
async function toggleFollow() {
relationship!.following = !relationship!.following
try {
const newRel = await useMasto().accounts[relationship!.following ? 'follow' : 'unfollow'](account.id)
const newRel = await masto.accounts[relationship!.following ? 'follow' : 'unfollow'](account.id)
Object.assign(relationship!, newRel)
}
catch {
@ -26,7 +27,7 @@ async function toggleFollow() {
async function unblock() {
relationship!.blocking = false
try {
const newRel = await useMasto().accounts.unblock(account.id)
const newRel = await masto.accounts.unblock(account.id)
Object.assign(relationship!, newRel)
}
catch {
@ -38,7 +39,7 @@ async function unblock() {
async function unmute() {
relationship!.muting = false
try {
const newRel = await useMasto().accounts.unmute(account.id)
const newRel = await masto.accounts.unmute(account.id)
Object.assign(relationship!, newRel)
}
catch {