feat: Initial clean release of CHM
一些检查失败了
automerge / automerge (push) Has been cancelled
react-native-android-build-apk / AssembleRelease (push) Has been cancelled
Build macOS M1 / Main (push) Has been cancelled
Joplin Continuous Integration / Main (macos-15-intel) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-11-vs2026-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-2025) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04-arm) (push) Has been cancelled
Joplin UI tests / Main (ubuntu-22.04) (push) Has been cancelled
Joplin UI tests / Main (windows-2025) (push) Has been cancelled
Joplin UI tests / Mobile (push) Has been cancelled
Close stale issues / ProcessStaleIssues (push) Has been cancelled
一些检查失败了
automerge / automerge (push) Has been cancelled
react-native-android-build-apk / AssembleRelease (push) Has been cancelled
Build macOS M1 / Main (push) Has been cancelled
Joplin Continuous Integration / Main (macos-15-intel) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-11-vs2026-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-2025) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04-arm) (push) Has been cancelled
Joplin UI tests / Main (ubuntu-22.04) (push) Has been cancelled
Joplin UI tests / Main (windows-2025) (push) Has been cancelled
Joplin UI tests / Mobile (push) Has been cancelled
Close stale issues / ProcessStaleIssues (push) Has been cancelled
这个提交包含在:
@@ -0,0 +1,51 @@
|
||||
import useAsyncEffect from '@joplin/lib/hooks/useAsyncEffect';
|
||||
import Logger from '@joplin/utils/Logger';
|
||||
import RepositoryApi, { InstallMode } from '@joplin/lib/services/plugins/RepositoryApi';
|
||||
import Setting, { AppType } from '@joplin/lib/models/Setting';
|
||||
import { useMemo } from 'react';
|
||||
import shim from '@joplin/lib/shim';
|
||||
import PluginService from '@joplin/lib/services/plugins/PluginService';
|
||||
|
||||
const logger = Logger.create('useRepoApi');
|
||||
|
||||
interface Props {
|
||||
reloadRepoCounter: number;
|
||||
setRepoApiError: (error: string|null)=> void;
|
||||
onRepoApiLoaded: (repoApi: RepositoryApi)=> void;
|
||||
}
|
||||
|
||||
let repoApi_: RepositoryApi|null = null;
|
||||
|
||||
export const resetRepoApi = () => {
|
||||
repoApi_ = null;
|
||||
};
|
||||
|
||||
const useRepoApi = ({ reloadRepoCounter, setRepoApiError, onRepoApiLoaded }: Props) => {
|
||||
const repoApi = useMemo(() => {
|
||||
const installMode = shim.mobilePlatform() === 'ios' ? InstallMode.Restricted : InstallMode.Default;
|
||||
const appInfo = { type: AppType.Mobile, version: PluginService.instance().appVersion };
|
||||
repoApi_ ??= RepositoryApi.ofDefaultJoplinRepo(Setting.value('tempDir'), appInfo, installMode);
|
||||
return repoApi_;
|
||||
}, []);
|
||||
|
||||
useAsyncEffect(async event => {
|
||||
if (reloadRepoCounter > 0) {
|
||||
logger.info(`Reloading the plugin repository -- try #${reloadRepoCounter + 1}`);
|
||||
}
|
||||
|
||||
setRepoApiError(null);
|
||||
try {
|
||||
await repoApi.reinitialize();
|
||||
} catch (error) {
|
||||
logger.error(error);
|
||||
setRepoApiError(error);
|
||||
}
|
||||
if (!event.cancelled) {
|
||||
onRepoApiLoaded(repoApi);
|
||||
}
|
||||
}, [setRepoApiError, reloadRepoCounter, repoApi]);
|
||||
|
||||
return repoApi;
|
||||
};
|
||||
|
||||
export default useRepoApi;
|
||||
在新工单中引用
屏蔽一个用户