Skip to content

Commit

Permalink
feat: say hello btn on new dm view (#18)
Browse files Browse the repository at this point in the history
* feat: say hello btn on new dm view

* fix: tokengated room
  • Loading branch information
ifaouibadi authored Dec 14, 2023
1 parent 8c355c1 commit 7fc46ec
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 6 deletions.
4 changes: 2 additions & 2 deletions res/themes/superhero/img/icons/tokengated-room.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 6 additions & 4 deletions src/components/views/elements/RoomName.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@ export const RoomName = ({ room, children, maxLength }: IProps): JSX.Element =>
const isVerifiedRoom = useVerifiedRoom(room);

const roomUsers: string[] = useMemo(() => {
return (room as Room)
.getMembers()
.map((m) => m.userId)
.filter((userId) => !!userId && userId != (room as Room).myUserId);
return (
(room as Room)
?.getMembers?.()
.map((m: { userId: string }) => m.userId)
.filter((userId: string) => !!userId && userId !== (room as Room)?.myUserId) || []
);
}, [room]);

const truncatedRoomName = useMemo(() => {
Expand Down
20 changes: 20 additions & 0 deletions src/components/views/rooms/NewRoomIntro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,24 @@ const NewRoomIntro: React.FC = () => {
const isLocalRoom = room instanceof LocalRoom;
const dmPartner = isLocalRoom ? room.targets[0]?.userId : DMRoomMap.shared().getUserIdForRoomId(roomId);

const onSendHelloClick = (): void => {
if (!dmPartner) return;
cli.sendEvent(roomId, EventType.RoomMessage, {
body: "👋",
msgtype: "m.text",
});
};

const sendHelloButton = !room.getLastActiveTimestamp() && (
<AccessibleButton
kind="primary_outline"
onClick={onSendHelloClick}
style={{ marginTop: "5px", fontSize: "30px" }}
>
👋
</AccessibleButton>
);

let body: JSX.Element;
if (dmPartner) {
const { shouldEncrypt: encryptedSingle3rdPartyInvite } = shouldEncryptRoomWithSingle3rdPartyInvite(room);
Expand Down Expand Up @@ -113,6 +131,7 @@ const NewRoomIntro: React.FC = () => {
)}
</p>
{caption && <p>{caption}</p>}
{sendHelloButton}
</React.Fragment>
);
} else {
Expand Down Expand Up @@ -262,6 +281,7 @@ const NewRoomIntro: React.FC = () => {
</p>
<p>{topicText}</p>
{buttons}
{sendHelloButton}
</React.Fragment>
);
}
Expand Down

0 comments on commit 7fc46ec

Please sign in to comment.