Scratchaddons: Only show link to user profile if user exists

Created on 11 Oct 2020  路  4Comments  路  Source: ScratchAddons/ScratchAddons

Is your feature request related to a problem? Please describe.

When using the user search addon, the profile tab still gets added even if the user doesn't exist. This could be confusing when it goes to a 404 page.

Describe the solution you'd like

Fetch the user page, if it doesn't have a 200 status code then don't add the tab.

Describe alternatives you've considered

Rather than not adding the tab, we could just disable it or add a message when it's clicked saying that this user doesn't exist or something.

Additional context

I won't make a pr yet, as I don't know whether we want this or not, or want to do an alternative, but you can see the changes at https://github.com/pufferfish101007/ScratchAddons/blob/user-search-enhancement/addons/search-profile/userscript.js

enhancement

Most helpful comment

request their profile comment api and if the user gets logged out then the account doesn't exist (/s)

All 4 comments

This would be a nice addition, problem is, there's no way to know if a profile exists with 100% certainty (not a user - a profile) without requesting to scratchr2. The Scratch API (api.scratch.mit.edu) wouldn't work for this, since it would say kaj exists, when there's no profile for kaj. And requesting scratchr2 is pretty slow 馃

request their profile comment api and if the user gets logged out then the account doesn't exist (/s)

Ok, so I've done some experimenting, and lefty's api (https://scratchdb.lefty.one/v2/user/info/[user]) returns "id": null for kaj, and the id of the user for everyone else. So this could work!
The reslonse time is about halfway between api.scratch.mit.edu and scratchr2, so that's not too bad. What do you think?

What about super recently created accounts, or new scratchers?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

BoomerScratch picture BoomerScratch  路  12Comments

Touchcreator picture Touchcreator  路  3Comments

Hans5958 picture Hans5958  路  10Comments

Richienb picture Richienb  路  8Comments

GrahamSH-LLK picture GrahamSH-LLK  路  8Comments