mirror of
https://gitcode.com/gh_mirrors/re/react-native-pushy.git
synced 2025-09-18 21:10:40 +08:00
v10.2.5
This commit is contained in:
@@ -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();
|
||||
|
Reference in New Issue
Block a user