1
0
mirror of https://gitcode.com/gh_mirrors/re/react-native-pushy.git synced 2025-09-16 08:51:40 +08:00
Code Issues Packages Projects Releases Wiki Activity GitHub Gitee

chore: Update switchVersion and switchVersionLater to be async functions

This commit is contained in:
sunnylqm
2024-08-16 10:48:39 +08:00
parent 6d980a4c04
commit 10178e1e64
3 changed files with 12 additions and 12 deletions

View File

@@ -126,7 +126,7 @@ export class Pushy {
PushyModule.markSuccess();
this.report({ type: 'markSuccess' });
};
switchVersion = (hash: string) => {
switchVersion = async (hash: string) => {
if (__DEV__) {
console.warn(
'您调用了switchVersion方法但是当前是开发环境不会进行任何操作。',
@@ -136,11 +136,11 @@ export class Pushy {
if (this.assertHash(hash) && !this.applyingUpdate) {
log('switchVersion: ' + hash);
this.applyingUpdate = true;
PushyModule.reloadUpdate({ hash });
return PushyModule.reloadUpdate({ hash });
}
};
switchVersionLater = (hash: string) => {
switchVersionLater = async (hash: string) => {
if (__DEV__) {
console.warn(
'您调用了switchVersionLater方法但是当前是开发环境不会进行任何操作。',
@@ -149,7 +149,7 @@ export class Pushy {
}
if (this.assertHash(hash)) {
log('switchVersionLater: ' + hash);
PushyModule.setNeedUpdate({ hash });
return PushyModule.setNeedUpdate({ hash });
}
};
checkUpdate = async (extra?: Record<string, any>) => {

View File

@@ -7,8 +7,8 @@ const asyncNoop = () => Promise.resolve();
export const defaultContext = {
checkUpdate: asyncNoop,
switchVersion: noop,
switchVersionLater: noop,
switchVersion: asyncNoop,
switchVersionLater: asyncNoop,
markSuccess: noop,
dismissError: noop,
downloadUpdate: asyncNoop,
@@ -21,8 +21,8 @@ export const defaultContext = {
export const PushyContext = createContext<{
checkUpdate: () => Promise<void>;
switchVersion: () => void;
switchVersionLater: () => void;
switchVersion: () => Promise<void>;
switchVersionLater: () => Promise<void>;
markSuccess: () => void;
dismissError: () => void;
downloadUpdate: () => Promise<void>;

View File

@@ -73,18 +73,18 @@ export const PushyProvider = ({
);
const switchVersion = useCallback(
(info: CheckResult | undefined = updateInfoRef.current) => {
async (info: CheckResult | undefined = updateInfoRef.current) => {
if (info && info.hash) {
client.switchVersion(info.hash);
return client.switchVersion(info.hash);
}
},
[client],
);
const switchVersionLater = useCallback(
(info: CheckResult | undefined = updateInfoRef.current) => {
async (info: CheckResult | undefined = updateInfoRef.current) => {
if (info && info.hash) {
client.switchVersionLater(info.hash);
return client.switchVersionLater(info.hash);
}
},
[client],