Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix incorrect follow status on followers and following pages #2669

Merged
merged 1 commit into from
Mar 9, 2024

Conversation

shuuji3
Copy link
Member

@shuuji3 shuuji3 commented Mar 9, 2024

fix #2668

There were two cases missed by the current implementation:

  1. Mastodon relationships API accepts batch requests for multiple IDs (ref. https://docs.joinmastodon.org/methods/accounts/#relationships) but it does not always ensure the order of returned relationships. For example, when we requests for [id1, id2], the response can be [relationship2, relationship1].
  2. when there's an issue with fetching the relationship for some accounts, the response array omits those accounts in response. For example, the request [id1, id2, id3] can result in the response [relationship1, relationship3].

This fix ensures using only returned relationships and updating the correct corresponding relationship data with the same ID.

Debugging notes

I inserted the following logs here to see how the relationship value is assigned:

requested[i][1].value = relationships[i]

    console.log('assigning:', requested[i][0], '<-', relationships[i].id)

I got the results like the following:

...
relationship.ts:36 assigning: 1147 <- 109491336352118388
relationship.ts:36 assigning: 111186761817498794 <- 109515037453915631
relationship.ts:36 assigning: 13179 <- 110645833556279910
relationship.ts:36 assigning: 1 <- 111186761817498794
...

which means that for example, the fetched relationship for the user ID 111186761817498794 is stored as the relationship for the user ID 1. This is clearly wrong.

This is the example logs after the fix:

...
relationship.ts:41 assigning: 108390124684993425 <- 108390124684993425
relationship.ts:41 assigning: 111086202750549423 <- 111086202750549423
relationship.ts:41 assigning: 111694022200023471 <- 111694022200023471
...

Copy link

stackblitz bot commented Mar 9, 2024

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

Copy link

netlify bot commented Mar 9, 2024

Deploy Preview for elk-docs canceled.

Name Link
🔨 Latest commit 0f2b631
🔍 Latest deploy log https://app.netlify.com/sites/elk-docs/deploys/65ecaf0b07d3d400082292d7

Copy link

netlify bot commented Mar 9, 2024

Deploy Preview for elk-zone ready!

Name Link
🔨 Latest commit 0f2b631
🔍 Latest deploy log https://app.netlify.com/sites/elk-zone/deploys/65ecaf0b321fea0008f92772
😎 Deploy Preview https://deploy-preview-2669--elk-zone.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Member

@patak-dev patak-dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

@patak-dev patak-dev added this pull request to the merge queue Mar 9, 2024
Merged via the queue into elk-zone:main with commit 0fd9374 Mar 9, 2024
19 checks passed
@shuuji3 shuuji3 deleted the fix/incorrect-follow-status branch March 10, 2024 05:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Follow status on follower/following page is incorrect
2 participants