-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Migrate local thread mutes #4523
Conversation
Your Render PR Server URL is https://social-app-pr-4523.onrender.com. Follow its progress at https://dashboard.render.com/web/srv-cpm9ieeehbks73djbjjg. |
|
src/state/cache/thread-mutes.tsx
Outdated
function migrateThreadMutes(agent: BskyAgent) { | ||
const threadMutes = persisted.get('mutedThreads') | ||
if (threadMutes.length > 0) { | ||
console.log('migrating', threadMutes.length, 'thread mutes') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
log
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you have a thousand (as some older heavy users might), i think this version will fire off a thousand concurrent requests. would that result in a rate limit?
not sure how to solve but let's think about what we want to happen in this case
Might be best to migrate the newest mutes first, and to update the array as the migration progresses? (if there's a lot of mutes then it's possible that the migration won't be finished by the time the user's done with the app and closes it) There's some concern around web being able to open multiple tabs... |
ccf6a4f
to
8990cc8
Compare
src/state/cache/thread-mutes.tsx
Outdated
// not a big deal if this fails, since the post might have been deleted | ||
.catch(console.error) | ||
|
||
persisted.write('mutedThreads', threads) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are multiple browser tabs going to fight with each other and try to sync this value with each other? I wonder if we should just skip the "broadcast" here. cc @estrattonbailey for thoughts
src/state/queries/post.ts
Outdated
onSuccess(finalIsMuted) { | ||
// finalize | ||
setThreadMute(rootUri, finalIsMuted) | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to handle the failure case and reset, or nah?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This resets it, just without feedback. Should I add feedback?
src/state/cache/thread-mutes.tsx
Outdated
|
||
if (!root) break | ||
|
||
persisted.write('mutedThreads', threads) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could add a param here to not emit an update. But also, if a user reloads the app with 4 tabs open, this migration is going to fire 4 times, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The list will be processed in parallel by each active tab. It's fine if there's data races though, nothing happens if you mute the same thread twice. Also, writing to persisted
doesn't refire the effect, so it doesn't cause multiple migrations or something
cancelled = true | ||
} | ||
} | ||
}, [agent, currentAccount, setThreadMute]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think agent
or currentAccount
can change here, but we might want to protect against this hook being called more than once?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The loop cancels itself, so it's fine for the effect to fire multiple times
c7779f1
to
a5e7cfb
Compare
59ce2b8
to
28d52a8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
* origin/main: (35 commits) Bump labeler limit to 20 (#4565) Migrate local thread mutes (#4523) Disable newskie dialog tap in hover card web (#4562) Implement thread locking (#4545) Prevent unecessary calls (#4561) Force callers of `getTimeAgo` to pass in the value for "now" (#4560) Fix: only apply self-thread load-more behavior on the outer edge of the reply tree (#4559) Server-side thread mutes (#4518) Explore fixes (#4540) Is it "newskie" or "newsky" 🤔 (#4557) fix keyboard overlaying onboarding inputs (#4558) Add `useGetTimeAgo` and utils (#4556) Unconditionally polyfill Intl.PluralRules for native (#4554) Dedupe Zod installation (#4551) Use exact imports for icons (#4549) Fix Android startup perf regression (#4544) Explore feed cards (#4521) Onboarding fixes (#4508) Add `native_pwi_disabled` feature gate experiment (#4507) Select, don't mutate (#4541) ...
* origin/main: (62 commits) Rework "Who can reply" to blend more nicely into the UI (#4578) Fix threadgate read after write (#4577) Convert button to use forwardRef (#4576) use 1000x1000 for image height in avatar cropper (#4453) fix for autofill covering border (#4573) Update HomeHeaderLayoutMobile.tsx (#4572) Option for large alt badges (#4571) Truncate post metrics and fix truncation on native (#4575) Fix avi placeholder layout (#4570) add support for `ListEmptyComponent`, allow `undefined` data (#4403) GIF previews in notifications (#4447) [Session] Convert account to session data explicitly (#4446) Move onboarding start to after successfull account creation (#4381) Collection of moderation fixes (#4566) Fix undefined block (#4479) fix gap between tab bar and its border (#4538) Better handling of blocks in `KnownFollowers` (#4563) Verify email reminders (#4510) Bump labeler limit to 20 (#4565) Migrate local thread mutes (#4523) ...
Stacked on #4518
Simple. Uploads existing thread mutes then deletes them.
Does not account for multi-accounts, but I'm not sure if there is a neat solution here without making this far more complex than necessary