You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-07-13 00:10:37 +02:00
Co-authored-by: Laurent Cozic <laurent22@users.noreply.github.com>
This commit is contained in:
@ -6,7 +6,7 @@ import { createTempDir, supportDir } from '@joplin/lib/testing/test-utils';
|
|||||||
const newRepoApi = async (installMode: InstallMode, appVersion = '3.0.0'): Promise<RepositoryApi> => {
|
const newRepoApi = async (installMode: InstallMode, appVersion = '3.0.0'): Promise<RepositoryApi> => {
|
||||||
const appInfo = { type: AppType.Mobile, version: appVersion };
|
const appInfo = { type: AppType.Mobile, version: appVersion };
|
||||||
const repo = new RepositoryApi(`${supportDir}/pluginRepo`, await createTempDir(), appInfo, installMode);
|
const repo = new RepositoryApi(`${supportDir}/pluginRepo`, await createTempDir(), appInfo, installMode);
|
||||||
await repo.initialize();
|
await repo.reinitialize();
|
||||||
return repo;
|
return repo;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ const useRepoApi = ({ reloadRepoCounter, setRepoApiError, onRepoApiLoaded }: Pro
|
|||||||
|
|
||||||
setRepoApiError(null);
|
setRepoApiError(null);
|
||||||
try {
|
try {
|
||||||
await repoApi.initialize();
|
await repoApi.reinitialize();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error(error);
|
logger.error(error);
|
||||||
setRepoApiError(error);
|
setRepoApiError(error);
|
||||||
|
@ -77,6 +77,7 @@ export default class RepositoryApi {
|
|||||||
private githubApiUrl_: string;
|
private githubApiUrl_: string;
|
||||||
private contentBaseUrl_: string;
|
private contentBaseUrl_: string;
|
||||||
private isUsingDefaultContentUrl_ = true;
|
private isUsingDefaultContentUrl_ = true;
|
||||||
|
private lastInitializedTime_ = 0;
|
||||||
|
|
||||||
public constructor(baseUrl: string, tempDir: string, appInfo: AppInfo, installMode: InstallMode) {
|
public constructor(baseUrl: string, tempDir: string, appInfo: AppInfo, installMode: InstallMode) {
|
||||||
this.installMode_ = installMode;
|
this.installMode_ = installMode;
|
||||||
@ -102,6 +103,15 @@ export default class RepositoryApi {
|
|||||||
|
|
||||||
await this.loadManifests();
|
await this.loadManifests();
|
||||||
await this.loadRelease();
|
await this.loadRelease();
|
||||||
|
|
||||||
|
this.lastInitializedTime_ = Date.now();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async reinitialize() {
|
||||||
|
// Refresh at most once per minute
|
||||||
|
if (Date.now() - this.lastInitializedTime_ > 5 * 60000) {
|
||||||
|
await this.initialize();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async loadManifests() {
|
private async loadManifests() {
|
||||||
|
Reference in New Issue
Block a user