forked from element-hq/element-web
-
Notifications
You must be signed in to change notification settings - Fork 0
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 #50 from superhero-com/features/trusted-bots
- Loading branch information
Showing
12 changed files
with
127 additions
and
63 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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,31 @@ | ||
import React from "react"; | ||
|
||
import { useVerifiedBot } from "../../../hooks/useVerifiedBot"; | ||
|
||
export interface UserVerifiedBadgeProps { | ||
userId: string; | ||
} | ||
|
||
export const BotVerifiedBadge = ({ userId }: UserVerifiedBadgeProps): JSX.Element => { | ||
const isVerifiedBot = useVerifiedBot(userId); | ||
|
||
return ( | ||
<> | ||
{isVerifiedBot && ( | ||
<div | ||
style={{ | ||
color: "rgba(30, 203, 172, 1)", | ||
fontWeight: 700, | ||
fontSize: "10px", | ||
backgroundColor: "rgba(30, 203, 172, 0.2)", | ||
padding: "2px 4px", | ||
borderRadius: "15px", | ||
marginLeft: "15px", | ||
}} | ||
> | ||
Trusted Bot | ||
</div> | ||
)} | ||
</> | ||
); | ||
}; |
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
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
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,19 @@ | ||
import { useMemo } from "react"; | ||
import { useAtom } from "jotai"; | ||
|
||
import { verifiedBotsAtom } from "../atoms"; | ||
|
||
/** | ||
* Custom hook to check if a bot is verified. | ||
* @param botId - The ID of the bot to check. | ||
* @returns A boolean indicating whether the bot is verified or not. | ||
*/ | ||
export function useVerifiedBot(botId?: string): boolean { | ||
const [verifiedBots] = useAtom(verifiedBotsAtom); | ||
|
||
const isVerifiedBot: boolean = useMemo(() => { | ||
return !!(botId && !!verifiedBots[botId]); | ||
}, [botId, verifiedBots]); | ||
|
||
return isVerifiedBot; | ||
} |