fix follows

This commit is contained in:
Henry Jameson 2026-06-16 22:32:17 +03:00
commit c062ae66e3
2 changed files with 31 additions and 40 deletions

View file

@ -245,19 +245,19 @@ export const getCaptcha = () =>
}) })
export const followUser = ({ id, credentials, ...options }) => { export const followUser = ({ id, credentials, ...options }) => {
const form = {} const payload = {}
if (options.reblogs !== undefined) { if (options.reblogs !== undefined) {
form.reblogs = options.reblogs payload.reblogs = options.reblogs
} }
if (options.notify !== undefined) { if (options.notify !== undefined) {
form.notify = options.notify payload.notify = options.notify
} }
return promisedRequest({ return promisedRequest({
url: MASTODON_FOLLOW_URL(id), url: MASTODON_FOLLOW_URL(id),
formData: form, payload,
credentials, credentials,
method: 'POST', method: 'POST',
}) })

View file

@ -35,17 +35,16 @@ const fetchRelationship = (attempt, userId, store) =>
} }
}) })
export const requestFollow = (userId, store) => export const requestFollow = async (userId, store) => {
new Promise((resolve) => { const updated = await followUser({
followUser({
id: userId, id: userId,
credentials: useOAuthStore().token, credentials: useOAuthStore().token,
}).then((updated) => { })
store.commit('updateUserRelationship', [updated]) store.commit('updateUserRelationship', [updated])
if (updated.following || (updated.locked && updated.requested)) { if (updated.following || (updated.locked && updated.requested)) {
// If we get result immediately or the account is locked, just stop. // If we get result immediately or the account is locked, just stop.
resolve()
return return
} }
@ -55,22 +54,14 @@ export const requestFollow = (userId, store) =>
// user anyway, probably because they locked themselves and we // user anyway, probably because they locked themselves and we
// don't know that yet. // don't know that yet.
// Recursive Promise, it will call itself up to 3 times. // Recursive Promise, it will call itself up to 3 times.
return await fetchRelationship(1, updated, store)
}
return fetchRelationship(1, updated, store).then(() => { export const requestUnfollow = async (userId, store) => {
resolve() const updated = await unfollowUser({
})
})
})
export const requestUnfollow = (userId, store) =>
new Promise((resolve) => {
unfollowUser({
id: userId, id: userId,
credentials: useOAuthStore().token, credentials: useOAuthStore().token,
}).then((updated) => {
store.commit('updateUserRelationship', [updated])
resolve({
updated,
})
})
}) })
return await store.commit('updateUserRelationship', [updated])
}