-
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.
CW-mark-as-read-in-space Added function to mark all chats as read for…
… spaces
- Loading branch information
Showing
8 changed files
with
78 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,5 @@ export enum CommonFeedMenuItem { | |
Share = "share", | ||
Follow = "follow", | ||
Mute = "mute", | ||
MarkRead = "markRead", | ||
} |
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,43 @@ | ||
import { useCallback } from "react"; | ||
import { useSelector } from "react-redux"; | ||
import { selectUser } from "@/pages/Auth/store/selectors"; | ||
import { CommonService } from "@/services"; | ||
import useNotification from "../useNotification"; | ||
|
||
interface Return { | ||
markCommonAsSeen: ( | ||
commonId: string, | ||
delay?: number, | ||
) => ReturnType<typeof setTimeout>; | ||
} | ||
|
||
export const useUpdateCommonSeenState = (): Return => { | ||
const user = useSelector(selectUser()); | ||
const userId = user?.uid; | ||
const { notify } = useNotification(); | ||
|
||
const updateSeenState = async ( | ||
commonId: string, | ||
) => { | ||
if (!userId) { | ||
return; | ||
} | ||
|
||
try { | ||
await CommonService.markCommonAsSeen(commonId, userId); | ||
} catch (error) { | ||
notify("Something went wrong"); | ||
} | ||
}; | ||
|
||
const markCommonAsSeen = useCallback( | ||
(commonId: string, delay = 0) => { | ||
return setTimeout(() => { | ||
updateSeenState(commonId); | ||
}, delay); | ||
}, | ||
[userId], | ||
); | ||
|
||
return { markCommonAsSeen }; | ||
}; |