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
refactor: avatar plugin #11473
refactor: avatar plugin #11473
Conversation
d428df5
to
282baaa
Compare
7f93455
to
0d8282a
Compare
refactor: remove unused components chore: tidy up components refactor: store helpers chore: impl store refactor: avatar components refactor: cleanup types refactor: remove mobile sniffing
1c065bb
to
11f7c46
Compare
4d9641f
to
9769cda
Compare
const indexOf = url.indexOf('?') | ||
return url.slice(0, Math.max(0, indexOf === -1 ? url.length : indexOf)) |
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.
why you don't use new URL()
??
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.
CC @UncleBill
private getAvatarToken = memoizePromise( | ||
memoize, | ||
(userId: string, avatarId?: string, publicKey?: string): Promise<StoreItem | null> => { | ||
return requestIdleCallbackAsync(async () => { |
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.
what will happen if you don't use this requestIdleCallback? why do you need it?
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 result of the callback function doesn't need to be used immediately.
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 result of the callback function doesn't need to be used immediately.
sorry can you clarify? I don't understand
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 created a data hub to store avatar records. It accepts data fetch requests from the UI in various places. When it receives a request, it fetches data when the browser is idle, because the quantity of requests might be quite high. I don't want this task to block the UI.
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.
but you are not queueing them. so it will block the UI next time you have idle
5757282
to
fcd627d
Compare
@@ -0,0 +1,21 @@ | |||
import { type StoreAPI } from '../types/Store.js' | |||
|
|||
export abstract class StoreProvider<T> implements StoreAPI.Provider<T> { |
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.
in case you're referring to React's API (which also has a getSnapshot), you cannot store mutable objects in it, or you have to do a full-clone in the getSnapshot
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.
It's consumed by useExternalStore
. I stored an instance of this class, which is created once and doesn't change. The one thing that might break the rule is that the instance contains a mutable map. However, since this is used internally, I think it's fine.
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 one thing that might break the rule is that the instance contains a mutable map.
well, this is wrong.
getSnapshot() { return structuredClone(this.store) }
you can do this, if this.store
does not store a custom class. things like Map<string, string>
is ok
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.
So each time the getSnapshot()
is invoked, a new instance of Store class should be returned?
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.
So each time the getSnapshot() is invoked, a new instance of Store class should be returned?
No, it should return what it stored. The store itself is untouched.
b1e5cb3
to
8d7b46e
Compare
* chore: bump version to 2.25.0 * fix: setting list (#11556) * fix: swap page in dark mode (#11555) * fix: bugfix for swap settings list * fix: scroll * chore: replace lens profile link (#11557) * fix: replace lens profile link * chore: name * fix: remove edit profile * fix: swap get gas alert (#11559) * fix: conflict * fix: scroll and metis token value (#11584) * fix: mf-6168 reset connection error (#11579) * fix: bugfix for exchange ui (#11586) * fix: selecting token from other chain set it to native token (#11587) * fix: mf-6195 selecting token from other chain set it to native token * fix: mf-6193 background of redpacket history * fix: repalce lens link (#11588) * fix: bugfix for switch logo button (#11589) * refactor: avatar plugin (#11473) * refactor: avatar refactor: remove unused components chore: tidy up components refactor: store helpers chore: impl store refactor: avatar components refactor: cleanup types refactor: remove mobile sniffing * fix: eslint * refactor: cleanup * refactor: code style * fix: smoke testing * fix: warning * fix: test case * fix: eslint --------- Co-authored-by: guanbinrui <guanbinrui@users.noreply.github.com> * fix: mf-6201 crash caused by mui (#11592) * fix: missing chain (#11593) * fix: set max number for chain select (#11595) * fix: invoke redpacket parsing api on Firefly only (#11594) * fix: profile avatar (#11596) * fix: profile avatar * fix: lint error * fix: mf-6200 nft avatar decoration (#11598) * chore: add lens handle name fallback (#11601) * fix: uniq binding account (#11602) * chore: lock file --------- Co-authored-by: nuanyang233 <nuanyang233@gmail.com> Co-authored-by: Jack Works <jackworks@protonmail.com> Co-authored-by: Wukong Sun <158803171+swkatmask@users.noreply.github.com> Co-authored-by: guanbinrui <guanbinrui@users.noreply.github.com>
Description
Closes MF-6073
Type of change
Previews
Checklist
console.log
sIf this PR depends on external APIs:
chrome-extension://[id]
moz-extension://[id]