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.
- Loading branch information
1 parent
7fc46ec
commit 6367c98
Showing
5 changed files
with
26 additions
and
19 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,24 +1,24 @@ | ||
import { IPublicRoomsChunkRoom, Room } from "matrix-js-sdk/src/matrix"; | ||
import { useMemo } from "react"; | ||
|
||
/** | ||
* Determines if a room is a token gated room | ||
* @param room - The room model | ||
* @returns {boolean} true if the room is token gated | ||
*/ | ||
export function isTokenGatedRoom(room?: Room | IPublicRoomsChunkRoom): boolean { | ||
return !!room?.name?.startsWith("[TG]"); | ||
} | ||
|
||
/** | ||
* Custom hook to check if a room is verified | ||
* @param room - The room model | ||
* @returns {boolean} true if the room is verified, false otherwise | ||
*/ | ||
export function useVerifiedRoom(room?: Room | IPublicRoomsChunkRoom): boolean { | ||
const isVerifiedRoom = useMemo(() => { | ||
return isTokenGatedRoom(room); | ||
export function useVerifiedRoom(room?: Room | IPublicRoomsChunkRoom): { | ||
isTokenGatedRoom: boolean; | ||
isCommunityRoom: boolean; | ||
} { | ||
const isTokenGatedRoom = useMemo<boolean>(() => { | ||
return !!room?.name?.startsWith("[TG]"); | ||
}, [room]); | ||
|
||
const isCommunityRoom = useMemo(() => { | ||
return !!room?.name?.startsWith("$"); | ||
}, [room]); | ||
|
||
return isVerifiedRoom; | ||
return { | ||
isTokenGatedRoom, | ||
isCommunityRoom, | ||
}; | ||
} |