Skip to content
Snippets Groups Projects

Better "follow" button behavior

Merged HJ requested to merge async_follow into develop
1 unresolved thread

Closes #133 (closed)

  • Button now becomes disabled when follow request is in progress and until confirmed.
  • Shows "Request sent!" for locked accounts, allows for re-sending it again
  • Tooltips for different states
    • tooltip for "Following!" telling that clicking it would unfollow,
    • tooltip for "Request sent!" telling that clicking will send follow request again
  • Checks if response contains following: true and does delayed user fetching if it's not.
    • Up to 3 attempts to re-fetch user data until it becomes following: true with 500ms interval between each
    • If still unconfirmed after 3 attempts - does same thing as with locked accounts - shows "Request sent!"
Edited by HJ

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
90 setTimeout(() => {
91 store.state.api.backendInteractor.fetchUser({ id: this.user.id })
92 .then((user) => store.commit('addNewUsers', [user]))
93 .then(() => resolve(this.user.following))
94 .catch((e) => reject(e))
95 }, 500)
96 }).then((confirmed) => {
97 if (!confirmed && attemptsLeft > 0) {
98 attemptsLeft--
99 return fetchUser()
100 } else if (confirmed) {
101 return true
102 } else {
103 return false
104 }
105 })
  • I would prefer something for the block above that doesn't resort to mutating a counter var. The amount of different booleans involved also makes it seem a bit bug prone, perhaps a single enum could be used to track state instead of a combination of bools.

  • Author Maintainer

    I've updated the code to pass counter and increment it within the promise instead, as well as simplified some logic and added comments everywhere, please take a look

  • mm, looks fine, comments keep the logic clear enough

  • Please register or sign in to reply
  • HJ added 65 commits

    added 65 commits

    • 9dfff107...5b6c1aa9 - 63 commits from branch develop
    • d7973b0b - Merge remote-tracking branch 'upstream/develop' into async_follow
    • 13fbef45 - slightly changed the code to have less mutations, added comments

    Compare with previous version

  • mentioned in commit 4b30ce64

  • Please register or sign in to reply
    Loading