Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(CalDavClient): handle XHR errors internally on Desktop client #14355

Merged
merged 1 commit into from
Feb 13, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions src/services/CalDavClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,13 @@ import type {
} from '../types/index.ts'

/**
* Copied from https://github.com/nextcloud/calendar/blob/main/src/services/caldavService.js
* Modified for TS usage
* Copied from:
* - https://github.com/nextcloud/calendar/blob/main/src/services/caldavService.js
* - https://github.com/nextcloud/server/blob/master/core/src/OC/xhr-error.js
* Modified for usage in Talk and Talk Desktop:
* - migrated to TypeScript
* - removed jQuery dependency
* - dropped Ajax Error processing via OC.registerXHRForErrorProcessing
*/
const clients: Record<string, DavClient> = {}

Expand Down Expand Up @@ -51,8 +56,17 @@ const getClient = (headers: object = {}) => {
return result
}

// @ts-expect-error: Vue: Cannot find name OC
OC.registerXHRForErrorProcessing(xhr) // eslint-disable-line no-undef
xhr.onload = (event: ProgressEvent) => {
if (xhr.readyState !== 4) {
return
} else if ((xhr.status >= 200 && xhr.status < 300) || xhr.status === 304) {
return
}
console.error(event)
}
xhr.onerror = (event: ProgressEvent) => {
console.error(event)
}
return xhr
})

Expand Down
Loading