profile: update profile images #42

Closed
offbyn wants to merge 1 commits from update-profile-imgs into master
offbyn commented 2 years ago
Owner

Textnotes often miss profile pictures of authors because they
are rendered when received even without knowing the pic yet.

Update profile pic of already rendered textnotes with the picture
of the first kind 0 event that has a valid picture, should now
render missing profile pics.

Textnotes often miss profile pictures of authors because they are rendered when received even without knowing the pic yet. Update profile pic of already rendered textnotes with the picture of the first kind 0 event that has a valid picture, should now render missing profile pics.
offbyn self-assigned this 2 years ago
offbyn added 1 commit 2 years ago
ci/woodpecker/push/woodpecker Pipeline was successful Details
ci/woodpecker/pr/woodpecker Pipeline was successful Details
4195d438d9
profile: update profile images
Textnotes often miss profile pictures of authors because they
are rendered when received even without knowing the pic yet.

Update profile pic of already rendered textnotes with the picture
of the first kind 0 event that has a valid picture, should now
render missing profile pics.
offbyn force-pushed update-profile-imgs from 4195d438d9 to cc174060a3 2 years ago
x1ddos approved these changes 2 years ago
x1ddos left a comment
Owner

lgtm

lgtm
x1ddos commented 2 years ago
Owner

sometime in the future, consider using a hashmap (object?) in getMetadata. instead of this:

const user = userList.find(user => user.pubkey === evt.pubkey);

do something like this:

const user = userMap[evt.pubkey];

it's a linear search O(N) vs theoretically O(1) object value lookup by key: http://jsben.ch/Y9jDP

as the userlist grows it'll be slower and slower.


then, could it make sense to store userMap in localStorage or indexeddb? so on next page reload you already have all previously seen metadata.

sometime in the future, consider using a hashmap (object?) in `getMetadata`. instead of this: ```js const user = userList.find(user => user.pubkey === evt.pubkey); ``` do something like this: ```js const user = userMap[evt.pubkey]; ``` it's a linear search O(N) vs theoretically O(1) object value lookup by key: http://jsben.ch/Y9jDP as the userlist grows it'll be slower and slower. --- then, could it make sense to store `userMap` in localStorage or indexeddb? so on next page reload you already have all previously seen metadata.
offbyn force-pushed update-profile-imgs from cc174060a3 to 05cae37e3b 2 years ago
offbyn force-pushed update-profile-imgs from 05cae37e3b to a3c0c5bfe1 2 years ago
offbyn force-pushed update-profile-imgs from a3c0c5bfe1 to 2683b072fe 2 years ago
offbyn commented 2 years ago
Poster
Owner

then, could it make sense to store userMap in localStorage or indexeddb? so on next page reload you already have all previously seen metadata.

userMap object should be fasted, but I am not sure how many contacts a client should keep.

Object in localStorage need to be stringified. so can't query from localStorage diretly, (unless each user would have it's own localstorage key, but that feels messy/wrong).

I wanted to use indexdb anyway for received events. but not sure yet.

maybe one advantage of userList array could be that it is sorted on access and could forget oldest accessed users after 1000 or so newer users.

> then, could it make sense to store userMap in localStorage or indexeddb? so on next page reload you already have all previously seen metadata. userMap object should be fasted, but I am not sure how many contacts a client should keep. Object in localStorage need to be stringified. so can't query from localStorage diretly, (unless each user would have it's own localstorage key, but that feels messy/wrong). I wanted to use indexdb anyway for received events. but not sure yet. maybe one advantage of userList array could be that it is sorted on access and could forget oldest accessed users after 1000 or so newer users.
offbyn commented 2 years ago
Poster
Owner

superseded by #45

superseded by https://git.qcode.ch/nostr/nostrweb/pulls/45
offbyn closed this pull request 2 years ago

Reviewers

x1ddos approved these changes 2 years ago
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/pr/woodpecker Pipeline was successful
This pull request cannot be reopened because the branch was deleted.
You can also view command line instructions.

Step 1:

From your project repository, check out a new branch and test the changes.
git checkout -b update-profile-imgs master
git pull origin update-profile-imgs

Step 2:

Merge the changes and update on Gitea.
git checkout master
git merge --no-ff update-profile-imgs
git push origin master
Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: nostr/nostrweb#42
Loading…
There is no content yet.