Skip to content
Source
Sign inSign up
pingdotgg/t3code

feat(web,mobile): snooze a thread until provider limits reset #9012

Closedvitalyiegorov(GitHub profile, opens in a new tab)wants to merge 8 commits intomain fromrefs/pull/9012/headopened View on GitHub

Showing 15 changed files with 38 additions and 3 deletions (loading 12).

x
0 of 15 viewed, 15 left
11 additions and 2 deletionsapps/mobile/src/features/threads/thread-list-v2-items.tsxModified
View file
@@ -31,6 +31,7 @@
import { ProjectFavicon } from "../../components/ProjectFavicon";
import { ProviderInstanceIcon } from "../../components/ProviderIcon";
import type { ThreadRowProviderInstance } from "./thread-provider-instance";
+import { exhaustedUntil } from "@t3tools/shared/usageLimits";
import { cn } from "../../lib/cn";
import { copyTextWithHaptic } from "../../lib/copyTextWithHaptic";
import { relativeTime } from "../../lib/time";
@@ -597,9 +598,15 @@
snoozable: canSnooze(thread, { now: new Date().toISOString() }),
snoozed: snoozedRow,
});
+ // Re-read on the parent minute tick with the presets, so the row's own
+ // "Until limits reset" offer expires with the limit.
+ const limitsResetAt = exhaustedUntil(props.providerInstance?.usageLimits, Date.now());
const snoozePresets = useMemo(
- () => (swipeActions.secondary === "snooze" ? resolveSnoozePresets(new Date()) : ([] as const)),
- [props.snoozePresetMinute, swipeActions.secondary],
+ () =>
+ swipeActions.secondary === "snooze"
+ ? resolveSnoozePresets(new Date(), { limitsResetAt })
+ : ([] as const),
+ [props.snoozePresetMinute, limitsResetAt, swipeActions.secondary],
const snoozePresetActions = useMemo<MenuAction[]>(
() => [
@@ -735,6 +742,7 @@
event: nativeEvent.event,