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-description': 'off',
|
||||||
'jsdoc/require-param-type': 'off',
|
'jsdoc/require-param-type': 'off',
|
||||||
'jsdoc/require-property-description': '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'
|
import { loadState } from '@nextcloud/initial-state'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the current user's display name if logged in.
|
* @return {boolean|string} Gets the current user's display name if logged in.
|
||||||
*
|
|
||||||
* @return boolean | string
|
|
||||||
*/
|
*/
|
||||||
function getLoggedInUser() {
|
function getLoggedInUser() {
|
||||||
return loadState('richdocuments', 'loggedInUser')
|
return loadState('richdocuments', 'loggedInUser')
|
||||||
|
|
|
||||||
|
|
@ -6,19 +6,20 @@ import { loadState } from '@nextcloud/initial-state'
|
||||||
|
|
||||||
class ConfigService {
|
class ConfigService {
|
||||||
|
|
||||||
private values: {[name: string]: any}
|
private values: {[name: string]: any}
|
||||||
|
|
||||||
constructor () {
|
constructor() {
|
||||||
this.values = loadState('richdocuments', 'document', {})
|
this.values = loadState('richdocuments', 'document', {})
|
||||||
}
|
}
|
||||||
|
|
||||||
update(key: string, value: any) {
|
update(key: string, value: any) {
|
||||||
this.values[key] = value
|
this.values[key] = value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get(key: string): any {
|
||||||
|
return this.values[key]
|
||||||
|
}
|
||||||
|
|
||||||
get(key: string): any {
|
|
||||||
return this.values[key]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const Config = new ConfigService()
|
const Config = new ConfigService()
|
||||||
|
|
|
||||||
|
|
@ -2,24 +2,31 @@
|
||||||
* SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
|
* SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
|
||||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
* 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;
|
type MessageEventSource = Window | MessagePort | ServiceWorker;
|
||||||
|
|
||||||
|
export interface WopiPostValues {
|
||||||
|
Deprecated?: boolean;
|
||||||
|
}
|
||||||
export interface WopiPost {
|
export interface WopiPost {
|
||||||
MessageId: string;
|
MessageId: string;
|
||||||
Values: WopiPostValues;
|
Values: WopiPostValues;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface WopiPostValues {
|
|
||||||
Deprecated?: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface WindowCallbackHandler { (): Window}
|
interface WindowCallbackHandler { (): Window}
|
||||||
|
|
||||||
|
interface PostMessageHandlerParam {
|
||||||
|
data: any;
|
||||||
|
parsed: { msgId: string, args: WopiPostValues, deprecated: boolean }
|
||||||
|
}
|
||||||
|
|
||||||
|
type PostMessageHandler = (values: PostMessageHandlerParam) => void;
|
||||||
|
|
||||||
export default class PostMessageService {
|
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)}) {
|
constructor(targets: {[name: string]: (Window|WindowCallbackHandler)}) {
|
||||||
this.targets = targets
|
this.targets = targets
|
||||||
|
|
@ -29,7 +36,7 @@ export default class PostMessageService {
|
||||||
}
|
}
|
||||||
|
|
||||||
sendPostMessage(target: string, message: any, targetOrigin: string = '*') {
|
sendPostMessage(target: string, message: any, targetOrigin: string = '*') {
|
||||||
let targetElement: Window;
|
let targetElement: Window
|
||||||
if (typeof this.targets[target] === 'function') {
|
if (typeof this.targets[target] === 'function') {
|
||||||
targetElement = (this.targets[target] as WindowCallbackHandler)()
|
targetElement = (this.targets[target] as WindowCallbackHandler)()
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -39,12 +46,11 @@ export default class PostMessageService {
|
||||||
console.debug('PostMessageService.sendPostMessage', target, message)
|
console.debug('PostMessageService.sendPostMessage', target, message)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
sendWOPIPostMessage(target: string, msgId: string, values: any = {}) {
|
sendWOPIPostMessage(target: string, msgId: string, values: any = {}) {
|
||||||
const msg = {
|
const msg = {
|
||||||
MessageId: msgId,
|
MessageId: msgId,
|
||||||
SendTime: Date.now(),
|
SendTime: Date.now(),
|
||||||
Values: values
|
Values: values,
|
||||||
}
|
}
|
||||||
|
|
||||||
this.sendPostMessage(target, JSON.stringify(msg))
|
this.sendPostMessage(target, JSON.stringify(msg))
|
||||||
|
|
@ -66,17 +72,17 @@ export default class PostMessageService {
|
||||||
return { msgId, args, deprecated }
|
return { msgId, args, deprecated }
|
||||||
}
|
}
|
||||||
|
|
||||||
registerPostMessageHandler(callback: Function) {
|
registerPostMessageHandler(callback: PostMessageHandler) {
|
||||||
this.postMessageHandlers.push(callback)
|
this.postMessageHandlers.push(callback)
|
||||||
}
|
}
|
||||||
|
|
||||||
unregisterPostMessageHandler(callback: Function) {
|
unregisterPostMessageHandler(callback: PostMessageHandler) {
|
||||||
const handlerIndex = this.postMessageHandlers.findIndex(cb => cb === callback)
|
const handlerIndex = this.postMessageHandlers.findIndex(cb => cb === callback)
|
||||||
delete this.postMessageHandlers[handlerIndex]
|
delete this.postMessageHandlers[handlerIndex]
|
||||||
}
|
}
|
||||||
|
|
||||||
private handlePostMessage(data: any) {
|
private handlePostMessage(data: any) {
|
||||||
const parsed = PostMessageService.parsePostMessage(data);
|
const parsed = PostMessageService.parsePostMessage(data)
|
||||||
if (typeof parsed === 'undefined' || parsed === null) {
|
if (typeof parsed === 'undefined' || parsed === null) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -88,15 +94,15 @@ export default class PostMessageService {
|
||||||
}
|
}
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
|
|
||||||
this.postMessageHandlers.forEach((fn: Function): void => {
|
this.postMessageHandlers.forEach((fn: PostMessageHandler): void => {
|
||||||
if (parsed.deprecated) {
|
if (parsed.deprecated) {
|
||||||
console.debug('PostMessageService.handlePostMessage', 'Ignoring deprecated post message', parsed.msgId)
|
console.debug('PostMessageService.handlePostMessage', 'Ignoring deprecated post message', parsed.msgId)
|
||||||
return;
|
return
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
fn({
|
fn({
|
||||||
data: data,
|
data,
|
||||||
parsed
|
parsed,
|
||||||
})
|
})
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('Error during post message handler', parsed, e)
|
console.error('Error during post message handler', parsed, e)
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,6 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async openFilePicker() {
|
async openFilePicker() {
|
||||||
const self = this
|
|
||||||
await getFilePickerBuilder(t('files', 'Select file or folder to link to'))
|
await getFilePickerBuilder(t('files', 'Select file or folder to link to'))
|
||||||
.setMimeTypeFilter(getCapabilities().mimetypes)
|
.setMimeTypeFilter(getCapabilities().mimetypes)
|
||||||
.addButton({
|
.addButton({
|
||||||
|
|
@ -101,8 +100,8 @@ export default {
|
||||||
callback: (files) => {
|
callback: (files) => {
|
||||||
const file = files[0]
|
const file = files[0]
|
||||||
this.fileId = file.fileid
|
this.fileId = file.fileid
|
||||||
self.filePath = file.path
|
this.filePath = file.path
|
||||||
self.fetchReferences()
|
this.fetchReferences()
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
.setContainer(this.$refs.picker)
|
.setContainer(this.$refs.picker)
|
||||||
|
|
|
||||||
|
|
@ -23,4 +23,4 @@ if (OCA.Viewer) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
autoSetupBuiltInCodeServerIfNeeded()
|
autoSetupBuiltInCodeServerIfNeeded()
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue