refactor: inject masto instance via nuxt app (#134)

This commit is contained in:
Daniel Roe 2022-11-26 15:42:58 +00:00 committed by GitHub
parent 5c60497421
commit 39b005899e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
26 changed files with 67 additions and 48 deletions

View file

@ -11,7 +11,7 @@ let relationship = $(useRelationship(account))
async function toggleFollow() {
relationship!.following = !relationship!.following
try {
relationship = await masto.accounts[relationship!.following ? 'follow' : 'unfollow'](account.id)
relationship = await useMasto().accounts[relationship!.following ? 'follow' : 'unfollow'](account.id)
}
catch {
// TODO error handling

View file

@ -13,24 +13,24 @@ const toggleMute = async () => {
relationship!.muting = !relationship!.muting
relationship = relationship!.muting
? await masto.accounts.mute(account.id, {
? await useMasto().accounts.mute(account.id, {
// TODO support more options
})
: await masto.accounts.unmute(account.id)
: await useMasto().accounts.unmute(account.id)
}
const toggleBlockUser = async () => {
// TODO: Add confirmation
relationship!.blocking = !relationship!.blocking
relationship = await masto.accounts[relationship!.blocking ? 'block' : 'unblock'](account.id)
relationship = await useMasto().accounts[relationship!.blocking ? 'block' : 'unblock'](account.id)
}
const toggleBlockDomain = async () => {
// TODO: Add confirmation
relationship!.domainBlocking = !relationship!.domainBlocking
await masto.domainBlocks[relationship!.domainBlocking ? 'block' : 'unblock'](getServerName(account))
await useMasto().domainBlocks[relationship!.domainBlocking ? 'block' : 'unblock'](getServerName(account))
}
</script>