Skip to content

Commit

Permalink
fix: fetch refresh token earlier than it actually expires
Browse files Browse the repository at this point in the history
  • Loading branch information
xiduzo committed Jun 20, 2024
1 parent 04d28c0 commit dffae19
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions apps/expo/src/providers/SpotifyProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { differenceInMinutes, scopes, useInterval, useSpotify } from "@fissa/utils";
import { addMinutes, differenceInMinutes, scopes, useInterval, useSpotify } from "@fissa/utils";
import {
Prompt,
ResponseType,
Expand Down Expand Up @@ -149,8 +149,7 @@ export const SpotifyProvider: FC<PropsWithChildren> = ({ children }) => {
}, [updateTokens, user, getScopes]);

useOnActiveApp(() => {
const { current } = lastTokenSaveTime;
const difference = differenceInMinutes(new Date(), current);
const difference = differenceInMinutes(new Date(), addMinutes(lastTokenSaveTime.current, -2));

if (difference < REFRESH_INTERVAL_MINUTES) return;

Expand Down

0 comments on commit dffae19

Please sign in to comment.