feat(web): accept snooze suggestion to auto-adjust timer timing
- Accept button on snooze suggestions shifts matching active timers - Applies suggestedDelayMinutes to targetTime of pattern-matched timers - Dismiss still available alongside Accept
This commit is contained in:
parent
ad4bc946a8
commit
6e339c6cf0
@ -312,14 +312,43 @@ export function Dashboard() {
|
||||
{suggestion.message}
|
||||
</p>
|
||||
</div>
|
||||
<div className="ml-3 flex gap-1.5 shrink-0">
|
||||
<button
|
||||
onClick={() => {
|
||||
// Apply suggestion: shift matching active timers by suggested delay
|
||||
const delayMs = suggestion.suggestedDelayMinutes * 60_000;
|
||||
const normalized = suggestion.labelPattern;
|
||||
const { timers } = useTimerStore.getState();
|
||||
timers.forEach((t) => {
|
||||
if (
|
||||
['active', 'warning'].includes(t.state) &&
|
||||
t.label.toLowerCase().trim().includes(normalized)
|
||||
) {
|
||||
useTimerStore.setState((s) => ({
|
||||
timers: s.timers.map((timer) =>
|
||||
timer.id === t.id
|
||||
? { ...timer, targetTime: timer.targetTime + delayMs }
|
||||
: timer
|
||||
),
|
||||
}));
|
||||
}
|
||||
});
|
||||
setDismissedSuggestions((prev) => new Set([...prev, suggestion.labelPattern]));
|
||||
}}
|
||||
className="text-xs px-2 py-1 rounded-lg cursor-pointer"
|
||||
style={{ backgroundColor: 'rgba(90,140,255,0.2)', color: 'var(--cm-accent)' }}
|
||||
>
|
||||
Accept
|
||||
</button>
|
||||
<button
|
||||
onClick={() => setDismissedSuggestions((prev) => new Set([...prev, suggestion.labelPattern]))}
|
||||
className="ml-3 text-xs px-2 py-1 rounded-lg cursor-pointer shrink-0"
|
||||
className="text-xs px-2 py-1 rounded-lg cursor-pointer"
|
||||
style={{ backgroundColor: 'var(--cm-surface-muted)', color: 'var(--cm-text-tertiary)' }}
|
||||
>
|
||||
Dismiss
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user