Skip to content

Commit 9430eeb

Browse files
Fixing typescript for date comparison
1 parent bcc20dc commit 9430eeb

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/components/ChannelList/hooks/usePaginatedChannels.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export const usePaginatedChannels = <
6161
const [loadingNextPage, setLoadingNextPage] = useState(false);
6262
const [offset, setOffset] = useState(0);
6363
const [refreshing, setRefreshing] = useState(false);
64-
const lastRefresh = useRef(new Date());
64+
const lastRefresh = useRef(new Date().getTime());
6565

6666
const queryChannels = async (
6767
queryType = '',
@@ -122,14 +122,13 @@ export const usePaginatedChannels = <
122122

123123
const loadNextPage = hasNextPage ? queryChannels : undefined;
124124
const refreshList = () => {
125-
const now = new Date();
125+
const now = Date.now();
126126
// Only allow pull-to-refresh 5 seconds after last successful refresh.
127-
// @ts-ignore
128127
if (now - lastRefresh.current < 5000 && !error) {
129128
return;
130129
}
131130

132-
lastRefresh.current = new Date();
131+
lastRefresh.current = new Date().getTime();
133132
return queryChannels('refresh');
134133
};
135134

0 commit comments

Comments
 (0)