diff options
| author | Shpuld Shpuldson <shp@cock.li> | 2020-04-21 23:27:51 +0300 |
|---|---|---|
| committer | Shpuld Shpuldson <shp@cock.li> | 2020-04-21 23:27:51 +0300 |
| commit | 6bb75a3a6d8452a3e1b88085fe87cf27386f222c (patch) | |
| tree | 5142716edc3ad960329d212aba4b5250fbb0c1b9 /src/services/follow_manipulate | |
| parent | d5457c323a186ed7890e7ba311c36d189c33d3fa (diff) | |
make relationships separate from users
Diffstat (limited to 'src/services/follow_manipulate')
| -rw-r--r-- | src/services/follow_manipulate/follow_manipulate.js | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/services/follow_manipulate/follow_manipulate.js b/src/services/follow_manipulate/follow_manipulate.js index 29b38a0f..c5d86afa 100644 --- a/src/services/follow_manipulate/follow_manipulate.js +++ b/src/services/follow_manipulate/follow_manipulate.js @@ -1,15 +1,18 @@ -const fetchUser = (attempt, user, store) => new Promise((resolve, reject) => { +const fetchRelationship = (attempt, user, store) => new Promise((resolve, reject) => { setTimeout(() => { - store.state.api.backendInteractor.fetchUser({ id: user.id }) - .then((user) => store.commit('addNewUsers', [user])) - .then(() => resolve([user.following, user.requested, user.locked, attempt])) + store.state.api.backendInteractor.fetchUserRelationship({ id: user.id }) + .then((relationship) => { + store.commit('updateUserRelationship', [relationship]) + return relationship + }) + .then((relationship) => resolve([relationship.following, relationship.requested, user.locked, attempt])) .catch((e) => reject(e)) }, 500) }).then(([following, sent, locked, attempt]) => { if (!following && !(locked && sent) && attempt <= 3) { // If we BE reports that we still not following that user - retry, // increment attempts by one - fetchUser(++attempt, user, store) + fetchRelationship(++attempt, user, store) } }) @@ -31,7 +34,7 @@ export const requestFollow = (user, store) => new Promise((resolve, reject) => { // don't know that yet. // Recursive Promise, it will call itself up to 3 times. - return fetchUser(1, user, store) + return fetchRelationship(1, user, store) .then(() => { resolve() }) |
