-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Regression: Fix RoomItem's loading status (#4835)
- Loading branch information
1 parent
f34b5b5
commit 9cf6981
Showing
2 changed files
with
27 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { TUserStatus } from '../../definitions'; | ||
import { useAppSelector } from '../../lib/hooks'; | ||
import { RoomTypes } from '../../lib/methods'; | ||
|
||
export const useUserStatus = ( | ||
type: RoomTypes, | ||
liveChatStatus?: TUserStatus, | ||
id?: string | ||
): { connected: boolean; status: TUserStatus } => { | ||
const connected = useAppSelector(state => state.meteor.connected); | ||
const userStatus = useAppSelector(state => state.activeUsers[id || '']?.status); | ||
let status = 'loading'; | ||
if (connected) { | ||
if (type === 'd') { | ||
status = userStatus || 'loading'; | ||
} else if (type === 'l' && liveChatStatus) { | ||
status = liveChatStatus; | ||
} | ||
} | ||
return { | ||
connected, | ||
status: status as TUserStatus | ||
}; | ||
}; |