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,13 +312,42 @@ export function Dashboard() {
|
|||||||
{suggestion.message}
|
{suggestion.message}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<button
|
<div className="ml-3 flex gap-1.5 shrink-0">
|
||||||
onClick={() => setDismissedSuggestions((prev) => new Set([...prev, suggestion.labelPattern]))}
|
<button
|
||||||
className="ml-3 text-xs px-2 py-1 rounded-lg cursor-pointer shrink-0"
|
onClick={() => {
|
||||||
style={{ backgroundColor: 'var(--cm-surface-muted)', color: 'var(--cm-text-tertiary)' }}
|
// Apply suggestion: shift matching active timers by suggested delay
|
||||||
>
|
const delayMs = suggestion.suggestedDelayMinutes * 60_000;
|
||||||
Dismiss
|
const normalized = suggestion.labelPattern;
|
||||||
</button>
|
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="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>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user