From ae1c719f19b25e87acb448ecdcbf249bf59f3492 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Thu, 19 Dec 2024 13:05:04 +0100 Subject: [PATCH] MOBILE-4680 chore: Fix some jsdocs --- src/core/classes/sites/site.ts | 26 +++++++------------ .../features/login/services/login-helper.ts | 15 ++--------- src/core/services/sites.ts | 1 - src/core/singletons/opener.ts | 1 - src/core/singletons/window.ts | 1 - 5 files changed, 11 insertions(+), 33 deletions(-) diff --git a/src/core/classes/sites/site.ts b/src/core/classes/sites/site.ts index 005aad7d4..dbf13a114 100644 --- a/src/core/classes/sites/site.ts +++ b/src/core/classes/sites/site.ts @@ -268,7 +268,6 @@ export class CoreSite extends CoreAuthenticatedSite { * * @param component Component name. * @param componentId Component id. - * @returns Promise resolved when the entries are deleted. */ async deleteComponentFromCache(component: string, componentId?: number): Promise { if (!component) { @@ -284,7 +283,7 @@ export class CoreSite extends CoreAuthenticatedSite { await this.cacheTable.delete(params); } - /* + /** * Uploads a file using Cordova File API. * * @param filePath File path. @@ -366,13 +365,17 @@ export class CoreSite extends CoreAuthenticatedSite { * @param url The url to be fixed. * @returns Promise resolved with the fixed URL. */ - checkAndFixPluginfileURL(url: string): Promise { - return this.checkTokenPluginFile(url).then(() => this.fixPluginfileURL(url)); + async checkAndFixPluginfileURL(url: string): Promise { + // Resolve the checking promise to make sure it's finished. + await this.checkTokenPluginFile(url); + + // The previous promise (tokenPluginFileWorks) result will be used here. + return this.fixPluginfileURL(url); } /** * Generic function for adding the wstoken to Moodle urls and for pointing to the correct script. - * Uses CoreUtilsProvider.fixPluginfileURL, passing site's token. + * Uses CoreUrl.fixPluginfileURL, passing site's token. * * @param url The url to be fixed. * @returns Fixed URL. @@ -386,8 +389,6 @@ export class CoreSite extends CoreAuthenticatedSite { /** * Deletes site's DB. - * - * @returns Promise to be resolved when the DB is deleted. */ async deleteDB(): Promise { await CoreDB.deleteDB('Site-' + this.id); @@ -395,8 +396,6 @@ export class CoreSite extends CoreAuthenticatedSite { /** * Deletes site's folder. - * - * @returns Promise to be resolved when the DB is deleted. */ async deleteFolder(): Promise { if (!CoreFile.isAvailable() || !this.id) { @@ -466,7 +465,6 @@ export class CoreSite extends CoreAuthenticatedSite { * @param url The URL to open. * @param alertMessage If defined, an alert will be shown before opening the browser. * @param options Other options. - * @returns Promise resolved when done, rejected otherwise. */ async openInBrowserWithAutoLogin( url: string, @@ -598,8 +596,6 @@ export class CoreSite extends CoreAuthenticatedSite { /** * Invalidates config WS call. - * - * @returns Promise resolved when the data is invalidated. */ async invalidateConfig(): Promise { await this.invalidateWsCacheForKey(this.getConfigCacheKey()); @@ -728,7 +724,6 @@ export class CoreSite extends CoreAuthenticatedSite { * Deletes a site setting. * * @param name The config name. - * @returns Promise resolved when done. */ async deleteSiteConfig(name: string): Promise { await this.configTable.deleteByPrimaryKey({ name }); @@ -760,13 +755,12 @@ export class CoreSite extends CoreAuthenticatedSite { * * @param name The config name. * @param value The config value. Can only store number or strings. - * @returns Promise resolved when done. */ async setLocalSiteConfig(name: string, value: number | string): Promise { await this.configTable.insert({ name, value }); } - /* + /** * Check if tokenpluginfile script works in the site. * * @param url URL to check. @@ -802,7 +796,6 @@ export class CoreSite extends CoreAuthenticatedSite { * Deletes last viewed records based on some conditions. * * @param conditions Conditions. - * @returns Promise resolved when done. */ async deleteLastViewed(conditions?: Partial): Promise { await this.lastViewedTable.delete(conditions); @@ -853,7 +846,6 @@ export class CoreSite extends CoreAuthenticatedSite { * @param id ID. * @param value Last viewed item value. * @param options Options. - * @returns Promise resolved when done. */ async storeLastViewed( component: string, diff --git a/src/core/features/login/services/login-helper.ts b/src/core/features/login/services/login-helper.ts index 23ee93791..1db10e651 100644 --- a/src/core/features/login/services/login-helper.ts +++ b/src/core/features/login/services/login-helper.ts @@ -151,7 +151,6 @@ export class CoreLoginHelperProvider { * @param service The service to use. If not defined, core service will be used. * @param launchUrl The URL to open for SSO. If not defined, default tool mobile launch URL will be used. * @param redirectData Data of the path/url to open once authenticated. If not defined, site initial page. - * @returns Promise resolved when done or if user cancelled. * @deprecated since 4.3. Use openBrowserForSSOLogin instead. */ async confirmAndOpenBrowserForSSOLogin( @@ -393,7 +392,7 @@ export class CoreLoginHelperProvider { siteConfig.identityproviders.forEach((provider) => { const urlParams = CoreUrl.extractUrlParams(provider.url); - if (provider.url && (provider.url.indexOf(httpsUrl) != -1 || provider.url.indexOf(httpUrl) != -1) && + if (provider.url && (provider.url.indexOf(httpsUrl) !== -1 || provider.url.indexOf(httpUrl) !== -1) && !site.isFeatureDisabled(IDENTITY_PROVIDER_FEATURE_NAME_PREFIX + urlParams.id)) { validProviders.push(provider); } @@ -409,7 +408,6 @@ export class CoreLoginHelperProvider { * * @param setRoot True to set the new page as root, false to add it to the stack. * @param showKeyboard Whether to show keyboard in the new page. Only if no fixed URL set. - * @returns Promise resolved when done. */ async goToAddSite(setRoot = false, showKeyboard = false): Promise { if (CoreSites.isLoggedIn()) { @@ -462,6 +460,7 @@ export class CoreLoginHelperProvider { * @param privateToken User's private token. * @param oauthId OAuth ID. Only if the authentication was using an OAuth method. * @returns Promise resolved when the user is authenticated with the token. + * @deprecated since 5.0. This is now handled by CoreCustomURLSchemes. */ handleSSOLoginAuthentication(siteUrl: string, token: string, privateToken?: string, oauthId?: number): Promise { // Always create a new site to prevent overriding data if another user credentials were introduced. @@ -682,7 +681,6 @@ export class CoreLoginHelperProvider { * * @param siteUrl Site URL to construct change password URL. * @param error Error message. - * @returns Promise resolved when done. */ async openChangePassword(siteUrl: string, error: string): Promise { const alert = await CoreDomUtils.showAlert(Translate.instant('core.notice'), error, undefined, 3000); @@ -708,7 +706,6 @@ export class CoreLoginHelperProvider { * @param path The relative path of the URL to open. * @param alertMessage The key of the message to display before opening the in app browser. * @param invalidateCache Whether to invalidate site's cache (e.g. when the user is forced to change password). - * @returns Promise resolved when done. */ async openInAppForEdit(siteId: string, path: string, alertMessage?: string, invalidateCache?: boolean): Promise { if (!siteId || siteId !== CoreSites.getCurrentSiteId()) { @@ -840,7 +837,6 @@ export class CoreLoginHelperProvider { * Function that should be called when the session expires. Reserved for core use. * * @param data Data received by the SESSION_EXPIRED event. - * @returns Promise resolved when done. */ async sessionExpired(data: CoreEventSessionExpiredData & CoreEventSiteData): Promise { const siteId = data?.siteId; @@ -1214,8 +1210,6 @@ export class CoreLoginHelperProvider { /** * Start waiting when opening a browser/IAB. - * - * @returns Promise resolved when the app is resumed. */ async waitForBrowser(): Promise { if (!this.waitingForBrowser) { @@ -1268,8 +1262,6 @@ export class CoreLoginHelperProvider { /** * Show instructions to scan QR code. - * - * @returns Promise resolved if the user accepts to scan QR. */ async showScanQRInstructions(): Promise { const dontShowWarning = await CoreConfig.get(FAQ_QRCODE_INFO_DONE, 0); @@ -1303,8 +1295,6 @@ export class CoreLoginHelperProvider { /** * Scan a QR code and tries to authenticate the user using custom URL scheme. - * - * @returns Promise resolved when done. */ async scanQR(): Promise { // Scan for a QR code. @@ -1375,7 +1365,6 @@ export class CoreLoginHelperProvider { * * @param accountsList Account list. * @param site Site to be deleted. - * @returns Resolved when done. */ async deleteAccountFromList(accountsList: CoreAccountsList, site: CoreSiteBasicInfo): Promise { await CoreSites.deleteSite(site.id); diff --git a/src/core/services/sites.ts b/src/core/services/sites.ts index d052b9338..a58978349 100644 --- a/src/core/services/sites.ts +++ b/src/core/services/sites.ts @@ -1611,7 +1611,6 @@ export class CoreSitesProvider { * @param siteId Site Id. * @param token User's new token. * @param privateToken User's private token. - * @returns A promise resolved when the site is updated. */ async updateSiteTokenBySiteId(siteId: string, token: string, privateToken: string = ''): Promise { const site = await this.getSite(siteId); diff --git a/src/core/singletons/opener.ts b/src/core/singletons/opener.ts index df73a3270..a7f037b56 100644 --- a/src/core/singletons/opener.ts +++ b/src/core/singletons/opener.ts @@ -82,7 +82,6 @@ export class CoreOpener { * * @param path The local path of the file to be open. * @param options Options. - * @returns Promise resolved when done. */ static async openFile(path: string, options: CoreOpenerOpenFileOptions = {}): Promise { // Convert the path to a native path if needed. diff --git a/src/core/singletons/window.ts b/src/core/singletons/window.ts index 03972fe60..d3d08ac29 100644 --- a/src/core/singletons/window.ts +++ b/src/core/singletons/window.ts @@ -49,7 +49,6 @@ export class CoreWindow { * * @param url URL to open. * @param name Name of the browsing context into which to load the URL. - * @returns Promise resolved when done. */ static async open(url: string, name?: string): Promise { if (CoreUrl.isLocalFileUrl(url)) {