diff options
author | Ferdinand Thiessen <opensource@fthiessen.de> | 2024-08-27 23:06:00 +0200 |
---|---|---|
committer | Ferdinand Thiessen <opensource@fthiessen.de> | 2024-09-20 03:30:20 +0200 |
commit | 085aab24ffd920df2f3610c9f6c2fa1e71a6d294 (patch) | |
tree | 0536be9d78feeba507bbe76d4c745158ab63005b /core/src/OC | |
parent | 4ba3d4a31a5a27a7fad6b8928d899ec7247289ca (diff) | |
download | nextcloud-server-085aab24ffd920df2f3610c9f6c2fa1e71a6d294.tar.gz nextcloud-server-085aab24ffd920df2f3610c9f6c2fa1e71a6d294.zip |
chore: fix usage of deprecated functions and adjust code style
This solves 57 ESLint warnings by replacing deprecated code with `@nextcloud/` libraries,
as well as adding missing type information, importing jQuery instead of relying on global one,
and the same with Moment.js.
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
Diffstat (limited to 'core/src/OC')
-rw-r--r-- | core/src/OC/l10n.js | 2 | ||||
-rw-r--r-- | core/src/OC/notification.js | 4 | ||||
-rw-r--r-- | core/src/OC/query-string.js | 4 | ||||
-rw-r--r-- | core/src/OC/xhr-error.js | 12 |
4 files changed, 12 insertions, 10 deletions
diff --git a/core/src/OC/l10n.js b/core/src/OC/l10n.js index 83fea41a16a..02f912d6a99 100644 --- a/core/src/OC/l10n.js +++ b/core/src/OC/l10n.js @@ -40,7 +40,7 @@ const L10n = { * @deprecated 26.0.0 use `register` from https://www.npmjs.com/package/@nextcloud/l10 * * @param {string} appName name of the app - * @param {Object<string, string>} bundle bundle + * @param {Record<string, string>} bundle bundle */ register, diff --git a/core/src/OC/notification.js b/core/src/OC/notification.js index 7f95f8335f4..b658f4163bb 100644 --- a/core/src/OC/notification.js +++ b/core/src/OC/notification.js @@ -120,7 +120,7 @@ export default { * Updates (replaces) a sanitized notification. * * @param {string} text Message to display - * @return {jQuery} JQuery element for notificaiton row + * @return {jQuery} JQuery element for notification row * @deprecated 17.0.0 use the `@nextcloud/dialogs` package */ showUpdate(text) { @@ -141,7 +141,7 @@ export default { * @param {number} [options.timeout] timeout in seconds, if this is 0 it will show the message permanently * @param {boolean} [options.isHTML] an indicator for HTML notifications (true) or text (false) * @param {string} [options.type] notification type - * @return {JQuery} the toast element + * @return {jQuery} the toast element * @deprecated 17.0.0 use the `@nextcloud/dialogs` package */ showTemporary(text, options) { diff --git a/core/src/OC/query-string.js b/core/src/OC/query-string.js index 57aef7a6850..df0f366133a 100644 --- a/core/src/OC/query-string.js +++ b/core/src/OC/query-string.js @@ -9,7 +9,7 @@ import $ from 'jquery' * Parses a URL query string into a JS map * * @param {string} queryString query string in the format param1=1234¶m2=abcde¶m3=xyz - * @return {Object<string, string>} map containing key/values matching the URL parameters + * @return {Record<string, string>} map containing key/values matching the URL parameters */ export const parse = queryString => { let pos @@ -58,7 +58,7 @@ export const parse = queryString => { /** * Builds a URL query from a JS map. * - * @param {Object<string, string>} params map containing key/values matching the URL parameters + * @param {Record<string, string>} params map containing key/values matching the URL parameters * @return {string} String containing a URL query (without question) mark */ export const build = params => { diff --git a/core/src/OC/xhr-error.js b/core/src/OC/xhr-error.js index 66ad638e10a..233aaf60350 100644 --- a/core/src/OC/xhr-error.js +++ b/core/src/OC/xhr-error.js @@ -8,16 +8,18 @@ import $ from 'jquery' import OC from './index.js' import Notification from './notification.js' +import { getCurrentUser } from '@nextcloud/auth' +import { showWarning } from '@nextcloud/dialogs' /** * Warn users that the connection to the server was lost temporarily * - * This function is throttled to prevent stacked notfications. + * This function is throttled to prevent stacked notifications. * After 7sec the first notification is gone, then we can show another one * if necessary. */ export const ajaxConnectionLostHandler = _.throttle(() => { - Notification.showTemporary(t('core', 'Connection to server lost')) + showWarning(t('core', 'Connection to server lost')) }, 7 * 1000, { trailing: false }) /** @@ -28,13 +30,13 @@ export const ajaxConnectionLostHandler = _.throttle(() => { */ export const processAjaxError = xhr => { // purposefully aborted request ? - // OC._userIsNavigatingAway needed to distinguish ajax calls cancelled by navigating away - // from calls cancelled by failed cross-domain ajax due to SSO redirect + // OC._userIsNavigatingAway needed to distinguish Ajax calls cancelled by navigating away + // from calls cancelled by failed cross-domain Ajax due to SSO redirect if (xhr.status === 0 && (xhr.statusText === 'abort' || xhr.statusText === 'timeout' || OC._reloadCalled)) { return } - if (_.contains([302, 303, 307, 401], xhr.status) && OC.currentUser) { + if ([302, 303, 307, 401].includes(xhr.status) && getCurrentUser()) { // sometimes "beforeunload" happens later, so need to defer the reload a bit setTimeout(function() { if (!OC._userIsNavigatingAway && !OC._reloadCalled) { |