Skip to content

Commit

Permalink
Merge pull request #14355 from nextcloud/fix/1031/OC-internal-handling
Browse files Browse the repository at this point in the history
fix(CalDavClient): handle XHR errors internally on Desktop client
  • Loading branch information
nickvergessen authored Feb 13, 2025
2 parents 92b2eb5 + 87a8d6e commit e0bf19a
Showing 1 changed file with 18 additions and 4 deletions.
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

0 comments on commit e0bf19a

Please sign in to comment.