761: Adds PATCH hook to read tagged comment notifications#762
Conversation
ReviewAdds a Findings (most severe first):
Findings 1-3 are concrete correctness bugs with reproducible failure scenarios; 4-5 are rule/process concerns rather than crashes. |
|
thanks @nadavosa for reviewing! All good points, especially point 3. which I completely missed (needed to test with multiple tags). I've now pushed my changes |
There was a problem hiding this comment.
Claude went through this:
Likely bug — TaggedNotification.tsx handleReadTag:
const handleReadTag = async (e: React.MouseEvent) => {
if (isRead) return;
e.preventDefault();
await updateReadTagComment({ id: personId, readAt: new Date() });
};Since this cancels the wrapped <Link>'s navigation via preventDefault(), and there's no navigation call after the mutation resolves, the first click on an unread notification only marks it read — it doesn't take the user anywhere. They'd need to click the same notification a second time (once isRead flips to true and the early-return skips preventDefault) to actually navigate to the comment. Given the PR description says clicking should scroll to Coordinator Comments, this seems like it should either not call preventDefault at all (fire-and-forget the mark-as-read alongside normal navigation), or navigate programmatically after the mutation resolves.
Minor — NewestTaggedComments.tsx handleIsRead:
return taggedComment?.readAt !== null;If taggedComment isn't found in taggedPersons (shouldn't normally happen, but there's no guard), undefined !== null evaluates to true, silently treating "not found" as "read". Probably safer as !!taggedComment?.readAt.
Good catch (no action needed): I double-checked the scrollTo: "coordinator-comments" unification against the old per-entity-type hash targets (opportunity-volunteers-container, communication-tracker-container) — those actually pointed at unrelated sections (volunteer matching / communication log), not the comments section. The new approach correctly targets the shared EntityComments container used by all three entity types, so this is an improvement over the previous behavior.
…need4deed-org/fe into darrell/feat/patch-tagged-comments-read
|
thanks @nadavosa , have pushed my changes |
Description
Creates a
PATCHhook for tagged comment notifications. When the user clicks on the notification, it triggers this request and writes thereadAtproperty, reducing the number of notifications for tagged commentsRelated Issues
Closes #761
Changes
usePatchTaggedCommentshooknoToastproperty touseMutationhook, as I didn't want a toast notification everytime a user clicks on an unread notificaiton (if it is needed then it's also no problem)scrollTosideeffect to Profile Layout if it has parameterscrollTowithsetTimeout. This was so when the user clicks on the notification, the scrollbar navigates to the Coordinator CommentsreadScreenshots / Demos
Checklist