Skip to content

Add "Watch task" to get notified of changes πŸ‘οΈΒ #532

Description

@anoopcodehack

Add "Watch task" to get notified of changes πŸ‘οΈ

File: server/models/Task.js + TaskModal.jsx

No way to follow a task you didn't create πŸ’€
Teammates can't track progress fr!!

Fix: add watchers array to Task model:
watchers: [{ type: mongoose.Schema.Types.ObjectId,
ref: 'User' }]

// add toggle in TaskModal:
const isWatching = task?.watchers?.includes(user?._id)

const handleWatch = async () => {
await updateTask(task._id, {
watchers: isWatching
? task.watchers.filter(w => w !== user._id)
: [...(task.watchers || []), user._id]
})
}

<button onClick={handleWatch}
className={text-xs px-3 py-1.5 rounded-lg border transition ${isWatching ? 'border-purple-500 text-purple-400' : 'border-[#2a2a2f] text-[#666]'}}>
{isWatching ? 'πŸ‘οΈ Watching' : 'πŸ‘οΈ Watch'}

~12 lines! 🎯

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions