-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #132 from Crossbell-Box/feat/notification
feat: notification related updates
- Loading branch information
Showing
5 changed files
with
100 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { useCharacter } from "@crossbell/indexer"; | ||
import { extractCharacterAvatar } from "@crossbell/util-metadata"; | ||
import { ipfsLinkToHttpLink } from "@crossbell/util-ipfs"; | ||
import { CharacterEntity } from "crossbell.js"; | ||
|
||
import { getDefaultAvatar } from "~/shared/avatar"; | ||
import React from "react"; | ||
|
||
export type UseCharacterAvatarParams = { | ||
characterId?: number | null; | ||
character?: CharacterEntity | null; | ||
disabled?: boolean; | ||
}; | ||
|
||
export function useCharacterAvatar({ | ||
character, | ||
characterId, | ||
disabled, | ||
}: UseCharacterAvatarParams) { | ||
const { isLoading, data } = useCharacter( | ||
characterId ?? character?.characterId, | ||
{ | ||
enabled: !!characterId && !disabled, | ||
initialData: character, | ||
} | ||
); | ||
|
||
return React.useMemo( | ||
() => ({ | ||
src: ipfsLinkToHttpLink( | ||
extractCharacterAvatar(data) ?? | ||
(isLoading | ||
? getDefaultAvatar() | ||
: extractCharacterAvatar(data) ?? getDefaultAvatar(data?.handle)) | ||
), | ||
character: data, | ||
}), | ||
[data, isLoading] | ||
); | ||
} |
e8321b1
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.
Successfully deployed to the following URLs:
x-sync – ./sites/x-sync
xsync.app
x-sync.vercel.app
x-sync-crossbell.vercel.app
x-sync-git-main-crossbell.vercel.app
www.xsync.app
e8321b1
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.
Successfully deployed to the following URLs:
crossbell-io – ./sites/crossbell.io
crossbell-io-crossbell.vercel.app
crossbell-io-git-main-crossbell.vercel.app
crossbell.vercel.app