Fix CI lint errors
This commit is contained in:
parent
42e5a2431c
commit
fe43676c32
3 changed files with 22 additions and 21 deletions
|
|
@ -41,8 +41,14 @@ const MessageRowWithObserver = ({
|
|||
const reportedRef = useRef(false);
|
||||
const messageRef = useRef(message);
|
||||
const onVisibleRef = useRef(onVisible);
|
||||
messageRef.current = message;
|
||||
onVisibleRef.current = onVisible;
|
||||
|
||||
useEffect(() => {
|
||||
messageRef.current = message;
|
||||
}, [message]);
|
||||
|
||||
useEffect(() => {
|
||||
onVisibleRef.current = onVisible;
|
||||
}, [onVisible]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!onVisible) return;
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ export const TaskDetailDialog = ({
|
|||
if (comments.length === 0) return;
|
||||
const latest = Math.max(...comments.map((c) => new Date(c.createdAt).getTime()));
|
||||
if (latest > 0) markAsRead(teamName, currentTask.id, latest);
|
||||
}, [open, teamName, currentTask?.id, currentTask?.comments]);
|
||||
}, [open, teamName, currentTask]);
|
||||
|
||||
const handleDependencyClick = (taskId: string): void => {
|
||||
onClose();
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { useCallback, useEffect, useState } from 'react';
|
||||
import { useCallback, useMemo, useState } from 'react';
|
||||
|
||||
import {
|
||||
getReadSet as getReadSetStorage,
|
||||
|
|
@ -9,28 +9,23 @@ export function useTeamMessagesRead(teamName: string): {
|
|||
readSet: Set<string>;
|
||||
markRead: (messageKey: string) => void;
|
||||
} {
|
||||
const [readSet, setReadSet] = useState<Set<string>>(() =>
|
||||
teamName ? getReadSetStorage(teamName) : new Set()
|
||||
const [version, setVersion] = useState(0);
|
||||
const readSet = useMemo(
|
||||
() => {
|
||||
if (version < 0) return new Set<string>();
|
||||
return teamName ? getReadSetStorage(teamName) : new Set();
|
||||
},
|
||||
[teamName, version]
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
if (!teamName) {
|
||||
setReadSet(new Set());
|
||||
return;
|
||||
}
|
||||
setReadSet(getReadSetStorage(teamName));
|
||||
}, [teamName]);
|
||||
|
||||
const markRead = useCallback(
|
||||
(messageKey: string) => {
|
||||
if (!teamName) return;
|
||||
setReadSet((prev) => {
|
||||
if (prev.has(messageKey)) return prev;
|
||||
const next = new Set(prev);
|
||||
next.add(messageKey);
|
||||
markReadStorage(teamName, messageKey, next);
|
||||
return next;
|
||||
});
|
||||
const existing = getReadSetStorage(teamName);
|
||||
if (existing.has(messageKey)) return;
|
||||
existing.add(messageKey);
|
||||
markReadStorage(teamName, messageKey, existing);
|
||||
setVersion((v) => v + 1);
|
||||
},
|
||||
[teamName]
|
||||
);
|
||||
|
|
|
|||
Loading…
Reference in a new issue