issue-38 #62

Closed
y wants to merge 48 commits from issue-38 into main
5 changed files with 14 additions and 8 deletions
Showing only changes of commit 477ef47f46 - Show all commits

View File

@ -53,8 +53,8 @@ export const AppBar = () => {
metadataState.content
)
if (picture) {
setUserAvatar(picture)
if (picture || userRobotImage) {
setUserAvatar(picture || userRobotImage)
}
setUsername(shorten(display_name || name || '', 7))
@ -91,8 +91,8 @@ export const AppBar = () => {
nsecBunkerPubkey: undefined
})
)
dispatch(setMetadataEvent(metadataController.getEmptyMetadataEvent()))
dispatch(setUserRobotImage(null))
// clear authToken saved in local storage
clearAuthToken()

View File

@ -8,6 +8,7 @@ import { restoreState, setAuthState, setMetadataEvent } from '../store/actions'
import {
clearAuthToken,
clearState,
getRoboHashPicture,
loadState,
saveNsecBunkerDelegatedKey
} from '../utils'

View File

@ -1,7 +1,9 @@
import * as ActionTypes from '../actionTypes'
import { SetUserRobotImage } from './types'
export const setUserRobotImage = (payload: string | null): SetUserRobotImage => ({
export const setUserRobotImage = (
payload: string | null
): SetUserRobotImage => ({
type: ActionTypes.SET_USER_ROBOT_IMAGE,
payload
})

View File

@ -143,7 +143,10 @@ export const base64DecodeAuthToken = (authToken: string): SignedEvent => {
* @param pubkey in hex or npub format
* @returns robohash.org url for the avatar
*/
export const getRoboHashPicture = (pubkey?: string, set: number = 1): string => {
export const getRoboHashPicture = (
pubkey?: string,
set: number = 1
): string => {
if (!pubkey) return ''
const npub = hexToNpub(pubkey)
return `https://robohash.org/${npub}.png?set=set${set}`