mirror of
https://github.com/nextcloud/richdocuments.git
synced 2025-12-17 21:12:14 +01:00
fix: Fix eslint errors for typescript files
Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
parent
369c33ce8a
commit
4158fbe917
6 changed files with 38 additions and 32 deletions
|
|
@ -29,5 +29,7 @@ module.exports = {
|
|||
'jsdoc/require-param-description': 'off',
|
||||
'jsdoc/require-param-type': 'off',
|
||||
'jsdoc/require-property-description': 'off',
|
||||
'@typescript-eslint/no-unused-vars': 'off',
|
||||
'@typescript-eslint/no-explicit-any': 'off',
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,9 +6,7 @@
|
|||
import { loadState } from '@nextcloud/initial-state'
|
||||
|
||||
/**
|
||||
* Gets the current user's display name if logged in.
|
||||
*
|
||||
* @return boolean | string
|
||||
* @return {boolean|string} Gets the current user's display name if logged in.
|
||||
*/
|
||||
function getLoggedInUser() {
|
||||
return loadState('richdocuments', 'loggedInUser')
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ class ConfigService {
|
|||
|
||||
private values: {[name: string]: any}
|
||||
|
||||
constructor () {
|
||||
constructor() {
|
||||
this.values = loadState('richdocuments', 'document', {})
|
||||
}
|
||||
|
||||
|
|
@ -19,6 +19,7 @@ class ConfigService {
|
|||
get(key: string): any {
|
||||
return this.values[key]
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const Config = new ConfigService()
|
||||
|
|
|
|||
|
|
@ -2,24 +2,31 @@
|
|||
* SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
import { emit } from "@nextcloud/event-bus"
|
||||
import { emit } from '@nextcloud/event-bus'
|
||||
|
||||
type MessageEventSource = Window | MessagePort | ServiceWorker;
|
||||
|
||||
export interface WopiPostValues {
|
||||
Deprecated?: boolean;
|
||||
}
|
||||
export interface WopiPost {
|
||||
MessageId: string;
|
||||
Values: WopiPostValues;
|
||||
}
|
||||
|
||||
export interface WopiPostValues {
|
||||
Deprecated?: boolean;
|
||||
}
|
||||
|
||||
interface WindowCallbackHandler { (): Window}
|
||||
|
||||
interface PostMessageHandlerParam {
|
||||
data: any;
|
||||
parsed: { msgId: string, args: WopiPostValues, deprecated: boolean }
|
||||
}
|
||||
|
||||
type PostMessageHandler = (values: PostMessageHandlerParam) => void;
|
||||
|
||||
export default class PostMessageService {
|
||||
private readonly targets: {[name: string]: (Window|WindowCallbackHandler)};
|
||||
private postMessageHandlers: Function[] = [];
|
||||
|
||||
private readonly targets: {[name: string]: (Window|WindowCallbackHandler)}
|
||||
private postMessageHandlers: PostMessageHandler[] = []
|
||||
|
||||
constructor(targets: {[name: string]: (Window|WindowCallbackHandler)}) {
|
||||
this.targets = targets
|
||||
|
|
@ -29,7 +36,7 @@ export default class PostMessageService {
|
|||
}
|
||||
|
||||
sendPostMessage(target: string, message: any, targetOrigin: string = '*') {
|
||||
let targetElement: Window;
|
||||
let targetElement: Window
|
||||
if (typeof this.targets[target] === 'function') {
|
||||
targetElement = (this.targets[target] as WindowCallbackHandler)()
|
||||
} else {
|
||||
|
|
@ -39,12 +46,11 @@ export default class PostMessageService {
|
|||
console.debug('PostMessageService.sendPostMessage', target, message)
|
||||
}
|
||||
|
||||
|
||||
sendWOPIPostMessage(target: string, msgId: string, values: any = {}) {
|
||||
const msg = {
|
||||
MessageId: msgId,
|
||||
SendTime: Date.now(),
|
||||
Values: values
|
||||
Values: values,
|
||||
}
|
||||
|
||||
this.sendPostMessage(target, JSON.stringify(msg))
|
||||
|
|
@ -66,17 +72,17 @@ export default class PostMessageService {
|
|||
return { msgId, args, deprecated }
|
||||
}
|
||||
|
||||
registerPostMessageHandler(callback: Function) {
|
||||
registerPostMessageHandler(callback: PostMessageHandler) {
|
||||
this.postMessageHandlers.push(callback)
|
||||
}
|
||||
|
||||
unregisterPostMessageHandler(callback: Function) {
|
||||
unregisterPostMessageHandler(callback: PostMessageHandler) {
|
||||
const handlerIndex = this.postMessageHandlers.findIndex(cb => cb === callback)
|
||||
delete this.postMessageHandlers[handlerIndex]
|
||||
}
|
||||
|
||||
private handlePostMessage(data: any) {
|
||||
const parsed = PostMessageService.parsePostMessage(data);
|
||||
const parsed = PostMessageService.parsePostMessage(data)
|
||||
if (typeof parsed === 'undefined' || parsed === null) {
|
||||
return
|
||||
}
|
||||
|
|
@ -88,15 +94,15 @@ export default class PostMessageService {
|
|||
}
|
||||
} catch (e) {}
|
||||
|
||||
this.postMessageHandlers.forEach((fn: Function): void => {
|
||||
this.postMessageHandlers.forEach((fn: PostMessageHandler): void => {
|
||||
if (parsed.deprecated) {
|
||||
console.debug('PostMessageService.handlePostMessage', 'Ignoring deprecated post message', parsed.msgId)
|
||||
return;
|
||||
return
|
||||
}
|
||||
try {
|
||||
fn({
|
||||
data: data,
|
||||
parsed
|
||||
data,
|
||||
parsed,
|
||||
})
|
||||
} catch (e) {
|
||||
console.error('Error during post message handler', parsed, e)
|
||||
|
|
|
|||
|
|
@ -93,7 +93,6 @@ export default {
|
|||
}
|
||||
},
|
||||
async openFilePicker() {
|
||||
const self = this
|
||||
await getFilePickerBuilder(t('files', 'Select file or folder to link to'))
|
||||
.setMimeTypeFilter(getCapabilities().mimetypes)
|
||||
.addButton({
|
||||
|
|
@ -101,8 +100,8 @@ export default {
|
|||
callback: (files) => {
|
||||
const file = files[0]
|
||||
this.fileId = file.fileid
|
||||
self.filePath = file.path
|
||||
self.fetchReferences()
|
||||
this.filePath = file.path
|
||||
this.fetchReferences()
|
||||
},
|
||||
})
|
||||
.setContainer(this.$refs.picker)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue