From 1ad72f00c20b653bbed21cd864008d96e1cd9a9e Mon Sep 17 00:00:00 2001 From: Nolan Lawson Date: Wed, 11 Apr 2018 22:55:04 -0700 Subject: [PATCH] fix optimistic follow button (#91) Fixes #85 --- routes/_actions/accounts.js | 5 ++- routes/_actions/follow.js | 2 -- .../profile/AccountProfileFollow.html | 34 +++++++++++-------- routes/_pages/accounts/[accountId].html | 3 +- 4 files changed, 26 insertions(+), 18 deletions(-) diff --git a/routes/_actions/accounts.js b/routes/_actions/accounts.js index e7cf7d38..471e3889 100644 --- a/routes/_actions/accounts.js +++ b/routes/_actions/accounts.js @@ -39,11 +39,14 @@ async function updateRelationship (accountId, instanceName, accessToken) { } } -export async function updateProfileAndRelationship (accountId) { +export async function clearProfileAndRelationship () { store.set({ currentAccountProfile: null, currentAccountRelationship: null }) +} + +export async function updateProfileAndRelationship (accountId) { let instanceName = store.get('currentInstance') let accessToken = store.get('accessToken') diff --git a/routes/_actions/follow.js b/routes/_actions/follow.js index 1f7fb7c2..e50f8115 100644 --- a/routes/_actions/follow.js +++ b/routes/_actions/follow.js @@ -14,8 +14,6 @@ export async function setAccountFollowed (accountId, follow, toastOnSuccess) { } else { account = await unfollowAccount(instanceName, accessToken, accountId) } - // TODO: hack to let the animation fully play - await new Promise(resolve => setTimeout(resolve, 400)) await updateProfileAndRelationship(accountId) let relationship = await database.getRelationship(instanceName, accountId) if (toastOnSuccess) { diff --git a/routes/_components/profile/AccountProfileFollow.html b/routes/_components/profile/AccountProfileFollow.html index f1529db1..a61b3fdf 100644 --- a/routes/_components/profile/AccountProfileFollow.html +++ b/routes/_components/profile/AccountProfileFollow.html @@ -1,20 +1,22 @@ -
- {{#if verifyCredentials && relationship && verifyCredentials.id !== relationship.id}} - - {{/if}} +