@ravshansbox/pi-quota 0.10.9 → 0.10.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.ts +7 -10
- package/package.json +1 -1
package/index.ts
CHANGED
|
@@ -303,21 +303,18 @@ export default function (pi: ExtensionAPI) {
|
|
|
303
303
|
child.unref();
|
|
304
304
|
}
|
|
305
305
|
|
|
306
|
-
function scheduleAnthropicPing(state: QuotaState) {
|
|
306
|
+
function scheduleAnthropicPing(state: QuotaState, after = Date.now()) {
|
|
307
307
|
if (anthropicPingTimer) clearTimeout(anthropicPingTimer);
|
|
308
308
|
anthropicPingTimer = null;
|
|
309
|
-
const now = Date.now();
|
|
310
309
|
const resets = [state.fiveHourReset, state.sevenDayReset]
|
|
311
310
|
.map((reset) => reset?.getTime())
|
|
312
|
-
.filter((time): time is number => time !== undefined && time >
|
|
311
|
+
.filter((time): time is number => time !== undefined && time > after);
|
|
313
312
|
if (resets.length === 0) return;
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
Math.min(...resets) - now,
|
|
320
|
-
);
|
|
313
|
+
const next = Math.min(...resets);
|
|
314
|
+
anthropicPingTimer = setTimeout(() => {
|
|
315
|
+
pingProviderOnReset('anthropic');
|
|
316
|
+
scheduleAnthropicPing(state, next);
|
|
317
|
+
}, next - Date.now());
|
|
321
318
|
}
|
|
322
319
|
|
|
323
320
|
function updateState(parsed: QuotaState) {
|