Skip to content

Commit

Permalink
chore(ts): fix TS and ESLint errors
Browse files Browse the repository at this point in the history
Signed-off-by: Grigorii K. Shartsev <[email protected]>
  • Loading branch information
ShGKme committed Sep 9, 2024
1 parent cc151f9 commit acc4570
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/shared/globals/OC/OcDialogsAdapter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ function deleteDialog(id) {
* @param {Function} callback which will be triggered when user presses OK
* @param {boolean} [modal] make the dialog modal
*/
function info(text, title, callback, modal) {
function info(text, title, callback, modal) { // eslint-disable-line @typescript-eslint/no-unused-vars
// TODO: currently not used in Talk, but should be implemented
// this.message(text, title, 'info', Dialogs.OK_BUTTON, callback, modal)
console.warn('OC.dialogs.info is not implemented in Talk Desktop')
Expand Down Expand Up @@ -158,7 +158,7 @@ function confirmDestructive(text, title, buttons, callback, modal) {
* @param {boolean} password whether the input should be a password input
* @return {void}
*/
function prompt(text, title, callback, modal, name, password) {
function prompt(text, title, callback, modal, name, password) { // eslint-disable-line @typescript-eslint/no-unused-vars
// TODO: currently not used in Talk, but should be implemented
console.warn('OC.dialogs.prompt is not implemented in Talk Desktop')
}
Expand Down
2 changes: 1 addition & 1 deletion src/talk/renderer/Viewer/ViewerApp.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const isOpen = ref(false)
const onClose = ref(noop)
const file = ref(null)

const viewComponent = computed(() => file.value && OCA.Viewer.availableHandlers.find((handler) => handler.mimes.includes(file.value.mime))?.component)
const viewComponent = computed(() => file.value && window.OCA.Viewer.availableHandlers.find((handler) => handler.mimes.includes(file.value.mime))?.component)

const link = computed(() => file.value && generateUrl(`/f/${file.value.fileid}`))

Expand Down
20 changes: 9 additions & 11 deletions src/talk/renderer/Viewer/viewer.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,15 @@ export async function fetchFileContent(filename: string, format: 'binary'): Prom
export async function fetchFileContent(filename: string, format: 'text' | 'binary'): Promise<string | Blob> {
const webDavClient = davGetClient(davRemoteURL + davRootPath)

// Get the MIME type of the file for the binary file to generate a correct Blob later
let mimeType: string
if (format === 'binary') {
const stat = await webDavClient.stat(filename) as FileStat
mimeType = stat.mime
if (format === 'text') {
// Get the text file content
return await webDavClient.getFileContents(filename, { format }) as string
}

// Fetch file content
type FileContent = typeof format extends 'binary' ? ArrayBuffer : string
const content = await webDavClient.getFileContents(filename, { format }) as FileContent

// Return the content in the requested format
return format === 'binary' ? new Blob([content], { type: mimeType }) : content
// Get the MIME type of the file for the binary file to generate a correct Blob later
const stat = await webDavClient.stat(filename) as FileStat
const mimeType = stat.mime
// Get the file content as ArrayBuffer and convert it to Blob
const content = await webDavClient.getFileContents(filename, { format }) as ArrayBuffer
return new Blob([content], { type: mimeType })
}

0 comments on commit acc4570

Please sign in to comment.