issue-38 #62
@ -53,8 +53,8 @@ export const AppBar = () => {
|
|||||||
metadataState.content
|
metadataState.content
|
||||||
)
|
)
|
||||||
|
|
||||||
if (picture) {
|
if (picture || userRobotImage) {
|
||||||
setUserAvatar(picture)
|
setUserAvatar(picture || userRobotImage)
|
||||||
}
|
}
|
||||||
|
|
||||||
setUsername(shorten(display_name || name || '', 7))
|
setUsername(shorten(display_name || name || '', 7))
|
||||||
@ -91,8 +91,8 @@ export const AppBar = () => {
|
|||||||
nsecBunkerPubkey: undefined
|
nsecBunkerPubkey: undefined
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
|
||||||
dispatch(setMetadataEvent(metadataController.getEmptyMetadataEvent()))
|
dispatch(setMetadataEvent(metadataController.getEmptyMetadataEvent()))
|
||||||
|
dispatch(setUserRobotImage(null))
|
||||||
|
|
||||||
// clear authToken saved in local storage
|
// clear authToken saved in local storage
|
||||||
clearAuthToken()
|
clearAuthToken()
|
||||||
|
@ -8,6 +8,7 @@ import { restoreState, setAuthState, setMetadataEvent } from '../store/actions'
|
|||||||
import {
|
import {
|
||||||
clearAuthToken,
|
clearAuthToken,
|
||||||
clearState,
|
clearState,
|
||||||
|
getRoboHashPicture,
|
||||||
loadState,
|
loadState,
|
||||||
saveNsecBunkerDelegatedKey
|
saveNsecBunkerDelegatedKey
|
||||||
} from '../utils'
|
} from '../utils'
|
||||||
|
@ -246,14 +246,14 @@ export const ProfilePage = () => {
|
|||||||
/**
|
/**
|
||||||
* Handles the logic for Image URL.
|
* Handles the logic for Image URL.
|
||||||
* If no picture in kind 0 found - use robohash avatar
|
* If no picture in kind 0 found - use robohash avatar
|
||||||
*
|
*
|
||||||
* @returns robohash image url
|
* @returns robohash image url
|
||||||
*/
|
*/
|
||||||
const getProfileImage = (metadata: ProfileMetadata) => {
|
const getProfileImage = (metadata: ProfileMetadata) => {
|
||||||
if (!isUsersOwnProfile) {
|
if (!isUsersOwnProfile) {
|
||||||
return metadata.picture || getRoboHashPicture(npub!)
|
return metadata.picture || getRoboHashPicture(npub!)
|
||||||
}
|
}
|
||||||
|
|
||||||
// userRobotImage is used only when visiting own profile
|
// userRobotImage is used only when visiting own profile
|
||||||
// while kind 0 picture is not set
|
// while kind 0 picture is not set
|
||||||
return metadata.picture || userRobotImage || getRoboHashPicture(npub!)
|
return metadata.picture || userRobotImage || getRoboHashPicture(npub!)
|
||||||
@ -293,7 +293,7 @@ export const ProfilePage = () => {
|
|||||||
<img
|
<img
|
||||||
onError={(event: any) => {
|
onError={(event: any) => {
|
||||||
event.target.src = getRoboHashPicture(npub!)
|
event.target.src = getRoboHashPicture(npub!)
|
||||||
}}
|
}}
|
||||||
className={styles.img}
|
className={styles.img}
|
||||||
src={getProfileImage(profileMetadata)}
|
src={getProfileImage(profileMetadata)}
|
||||||
alt="Profile Image"
|
alt="Profile Image"
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
import * as ActionTypes from '../actionTypes'
|
import * as ActionTypes from '../actionTypes'
|
||||||
import { SetUserRobotImage } from './types'
|
import { SetUserRobotImage } from './types'
|
||||||
|
|
||||||
export const setUserRobotImage = (payload: string | null): SetUserRobotImage => ({
|
export const setUserRobotImage = (
|
||||||
|
payload: string | null
|
||||||
|
): SetUserRobotImage => ({
|
||||||
type: ActionTypes.SET_USER_ROBOT_IMAGE,
|
type: ActionTypes.SET_USER_ROBOT_IMAGE,
|
||||||
payload
|
payload
|
||||||
})
|
})
|
||||||
|
@ -143,7 +143,10 @@ export const base64DecodeAuthToken = (authToken: string): SignedEvent => {
|
|||||||
* @param pubkey in hex or npub format
|
* @param pubkey in hex or npub format
|
||||||
* @returns robohash.org url for the avatar
|
* @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 ''
|
if (!pubkey) return ''
|
||||||
const npub = hexToNpub(pubkey)
|
const npub = hexToNpub(pubkey)
|
||||||
return `https://robohash.org/${npub}.png?set=set${set}`
|
return `https://robohash.org/${npub}.png?set=set${set}`
|
||||||
|
Loading…
Reference in New Issue
Block a user