1
0
mirror of https://gitcode.com/gh_mirrors/re/react-native-pushy.git synced 2025-09-18 21:10:40 +08:00
Code Issues Packages Projects Releases Wiki Activity GitHub Gitee
This commit is contained in:
sunnylqm
2024-03-08 11:27:18 +08:00
parent 94cf96a0e5
commit e39d4fa370
2 changed files with 8 additions and 2 deletions

View File

@@ -34,6 +34,7 @@ export const PushyProvider = ({
const [updateInfo, setUpdateInfo] = useState<CheckResult>();
const [progress, setProgress] = useState<ProgressData>();
const [lastError, setLastError] = useState<Error>();
const lastChecking = useRef(0);
const dismissError = useCallback(() => {
setLastError(undefined);
@@ -102,6 +103,11 @@ export const PushyProvider = ({
);
const checkUpdate = useCallback(async () => {
const now = Date.now();
if (lastChecking.current && now - lastChecking.current < 1000) {
return;
}
lastChecking.current = now;
let info: CheckResult;
try {
info = await client.checkUpdate();