-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FIX] Opening a new DM from user card (#24623)
* Change `useRoomIcon` signature * Fix `IRoom[t]` and `ISubscription[t]` * Ensure `IRoom['uids']` is not mandatory * Fix some typings
- Loading branch information
Showing
21 changed files
with
201 additions
and
106 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
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 was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import React, { ReactElement } from 'react'; | ||
|
||
import { IRoom } from '../../../../definition/IRoom'; | ||
import { useUserId } from '../../../contexts/UserContext'; | ||
import { usePresence } from '../../../hooks/usePresence'; | ||
import RoomHeader from './RoomHeader'; | ||
|
||
type DirectRoomHeaderProps = { | ||
room: IRoom; | ||
slots: { | ||
start?: unknown; | ||
preContent?: unknown; | ||
insideContent?: unknown; | ||
posContent?: unknown; | ||
end?: unknown; | ||
toolbox?: { | ||
pre?: unknown; | ||
content?: unknown; | ||
pos?: unknown; | ||
}; | ||
}; | ||
}; | ||
|
||
const DirectRoomHeader = ({ room, slots }: DirectRoomHeaderProps): ReactElement => { | ||
const userId = useUserId(); | ||
const directUserId = room.uids?.filter((uid) => uid !== userId).shift(); | ||
const directUserData = usePresence(directUserId); | ||
|
||
return <RoomHeader slots={slots} room={room} topic={directUserData?.statusText} />; | ||
}; | ||
|
||
export default DirectRoomHeader; |
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
11 changes: 8 additions & 3 deletions
11
...t/views/room/Header/HeaderIconWithRoom.js → .../views/room/Header/HeaderIconWithRoom.tsx
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,15 +1,20 @@ | ||
import React from 'react'; | ||
import React, { ReactElement } from 'react'; | ||
|
||
import { isOmnichannelRoom } from '../../../../definition/IRoom'; | ||
import { IRoom, isOmnichannelRoom } from '../../../../definition/IRoom'; | ||
import Header from '../../../components/Header'; | ||
import { OmnichannelRoomIcon } from '../../../components/RoomIcon/OmnichannelRoomIcon'; | ||
import { useRoomIcon } from '../../../hooks/useRoomIcon'; | ||
|
||
const HeaderIconWithRoom = ({ room }) => { | ||
type HeaderIconWithRoomProps = { | ||
room: IRoom; | ||
}; | ||
|
||
const HeaderIconWithRoom = ({ room }: HeaderIconWithRoomProps): ReactElement => { | ||
const icon = useRoomIcon(room); | ||
if (isOmnichannelRoom(room)) { | ||
return <OmnichannelRoomIcon room={room} size='x20' placement='default' />; | ||
} | ||
|
||
return <Header.Icon icon={icon} />; | ||
}; | ||
export default HeaderIconWithRoom; |
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
11 changes: 8 additions & 3 deletions
11
client/views/room/Header/ParentRoom.js → client/views/room/Header/ParentRoom.tsx
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 was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import React, { ReactElement } from 'react'; | ||
|
||
import { IRoom } from '../../../../definition/IRoom'; | ||
import { useUserSubscription } from '../../../contexts/UserContext'; | ||
import ParentRoom from './ParentRoom'; | ||
import ParentRoomWithEndpointData from './ParentRoomWithEndpointData'; | ||
|
||
type ParentRoomWithDataProps = { | ||
room: IRoom; | ||
}; | ||
|
||
const ParentRoomWithData = ({ room }: ParentRoomWithDataProps): ReactElement => { | ||
const { prid } = room; | ||
|
||
if (!prid) { | ||
throw new Error('Parent room ID is missing'); | ||
} | ||
|
||
const subscription = useUserSubscription(prid); | ||
|
||
if (subscription) { | ||
return <ParentRoom room={subscription} />; | ||
} | ||
|
||
return <ParentRoomWithEndpointData rid={prid} />; | ||
}; | ||
|
||
export default ParentRoomWithData; |
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import React, { ReactElement } from 'react'; | ||
|
||
import { IRoom } from '../../../../definition/IRoom'; | ||
import Header from '../../../components/Header'; | ||
import { AsyncStatePhase } from '../../../hooks/useAsyncState'; | ||
import { useEndpointData } from '../../../hooks/useEndpointData'; | ||
import ParentRoom from './ParentRoom'; | ||
|
||
type ParentRoomWithEndpointDataProps = { | ||
rid: IRoom['_id']; | ||
}; | ||
|
||
const ParentRoomWithEndpointData = ({ rid }: ParentRoomWithEndpointDataProps): ReactElement | null => { | ||
const { phase, value } = useEndpointData('rooms.info', { roomId: rid }); | ||
|
||
if (AsyncStatePhase.LOADING === phase) { | ||
return <Header.Tag.Skeleton />; | ||
} | ||
|
||
if (AsyncStatePhase.REJECTED === phase || !value?.room) { | ||
return null; | ||
} | ||
|
||
return <ParentRoom room={value.room} />; | ||
}; | ||
|
||
export default ParentRoomWithEndpointData; |
Oops, something went wrong.