mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-25 03:06:31 -05:00
fix: code formatting
Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
parent
ae9ec95a4e
commit
4d70ccafbc
13 changed files with 51 additions and 21 deletions
|
@ -372,9 +372,9 @@ export class NotesService {
|
||||||
return {
|
return {
|
||||||
id: note.publicId,
|
id: note.publicId,
|
||||||
aliases: await Promise.all(
|
aliases: await Promise.all(
|
||||||
(
|
(await note.aliases).map((alias) =>
|
||||||
await note.aliases
|
this.aliasService.toAliasDto(alias, note),
|
||||||
).map((alias) => this.aliasService.toAliasDto(alias, note)),
|
),
|
||||||
),
|
),
|
||||||
primaryAddress: (await getPrimaryAlias(note)) ?? note.publicId,
|
primaryAddress: (await getPrimaryAlias(note)) ?? note.publicId,
|
||||||
title: latestRevision.title,
|
title: latestRevision.title,
|
||||||
|
|
|
@ -32,7 +32,7 @@ jest.mock(
|
||||||
...jest.requireActual('@hedgedoc/commons'),
|
...jest.requireActual('@hedgedoc/commons'),
|
||||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||||
YDocSyncServerAdapter: jest.fn(() => Mock.of<YDocSyncServerAdapter>({})),
|
YDocSyncServerAdapter: jest.fn(() => Mock.of<YDocSyncServerAdapter>({})),
|
||||||
} as Record<string, unknown>),
|
}) as Record<string, unknown>,
|
||||||
);
|
);
|
||||||
|
|
||||||
describe('websocket connection', () => {
|
describe('websocket connection', () => {
|
||||||
|
|
|
@ -143,9 +143,9 @@ export class RevisionsService {
|
||||||
anonymousAuthorCount: revisionUserInfo.anonymousUserCount,
|
anonymousAuthorCount: revisionUserInfo.anonymousUserCount,
|
||||||
patch: revision.patch,
|
patch: revision.patch,
|
||||||
edits: await Promise.all(
|
edits: await Promise.all(
|
||||||
(
|
(await revision.edits).map(
|
||||||
await revision.edits
|
async (edit) => await this.editService.toEditDto(edit),
|
||||||
).map(async (edit) => await this.editService.toEditDto(edit)),
|
),
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,8 +61,12 @@ export class SessionService {
|
||||||
*/
|
*/
|
||||||
fetchUsernameForSessionId(sessionId: string): Promise<Username | undefined> {
|
fetchUsernameForSessionId(sessionId: string): Promise<Username | undefined> {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
this.typeormStore.get(sessionId, (error?: Error, result?: SessionState) =>
|
this.typeormStore.get(
|
||||||
error || !result ? reject(error) : resolve(result.username as Username),
|
sessionId,
|
||||||
|
(error?: Error, result?: SessionState) =>
|
||||||
|
error || !result
|
||||||
|
? reject(error)
|
||||||
|
: resolve(result.username as Username),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,10 @@ import { ApiError } from './api-error'
|
||||||
export class ErrorToI18nKeyMapper {
|
export class ErrorToI18nKeyMapper {
|
||||||
private foundI18nKey: string | undefined = undefined
|
private foundI18nKey: string | undefined = undefined
|
||||||
|
|
||||||
constructor(private apiError: Error, private i18nNamespace?: string) {}
|
constructor(
|
||||||
|
private apiError: Error,
|
||||||
|
private i18nNamespace?: string
|
||||||
|
) {}
|
||||||
|
|
||||||
public withHttpCode(code: number, i18nKey: string, treatAsAbsoluteKey?: boolean): this {
|
public withHttpCode(code: number, i18nKey: string, treatAsAbsoluteKey?: boolean): this {
|
||||||
if (this.foundI18nKey === undefined && this.apiError instanceof ApiError && this.apiError.statusCode === code) {
|
if (this.foundI18nKey === undefined && this.apiError instanceof ApiError && this.apiError.statusCode === code) {
|
||||||
|
|
|
@ -16,7 +16,11 @@ const syncAnnotation = Annotation.define()
|
||||||
export class YTextSyncViewPlugin implements PluginValue {
|
export class YTextSyncViewPlugin implements PluginValue {
|
||||||
private readonly observer: YTextSyncViewPlugin['onYTextUpdate']
|
private readonly observer: YTextSyncViewPlugin['onYTextUpdate']
|
||||||
|
|
||||||
constructor(private view: EditorView, private readonly yText: YText, pluginLoaded: () => void) {
|
constructor(
|
||||||
|
private view: EditorView,
|
||||||
|
private readonly yText: YText,
|
||||||
|
pluginLoaded: () => void
|
||||||
|
) {
|
||||||
this.observer = this.onYTextUpdate.bind(this)
|
this.observer = this.onYTextUpdate.bind(this)
|
||||||
this.yText.observe(this.observer)
|
this.yText.observe(this.observer)
|
||||||
pluginLoaded()
|
pluginLoaded()
|
||||||
|
|
|
@ -16,7 +16,11 @@ export class SendCursorViewPlugin implements PluginValue {
|
||||||
private lastCursor: SelectionRange | undefined
|
private lastCursor: SelectionRange | undefined
|
||||||
private listener?: Listener
|
private listener?: Listener
|
||||||
|
|
||||||
constructor(private view: EditorView, private messageTransporter: MessageTransporter, private mayEdit: boolean) {
|
constructor(
|
||||||
|
private view: EditorView,
|
||||||
|
private messageTransporter: MessageTransporter,
|
||||||
|
private mayEdit: boolean
|
||||||
|
) {
|
||||||
if (mayEdit) {
|
if (mayEdit) {
|
||||||
this.listener = messageTransporter.doAsSoonAsReady(() => {
|
this.listener = messageTransporter.doAsSoonAsReady(() => {
|
||||||
this.sendCursor(this.lastCursor)
|
this.sendCursor(this.lastCursor)
|
||||||
|
|
|
@ -40,10 +40,13 @@ export const useRealtimeConnection = (): MessageTransporter => {
|
||||||
const socket = new WebSocket(websocketUrl.toString())
|
const socket = new WebSocket(websocketUrl.toString())
|
||||||
socket.addEventListener('error', () => {
|
socket.addEventListener('error', () => {
|
||||||
const timeout = WEBSOCKET_RECONNECT_INTERVAL + reconnectCount.current * 1000 + Math.random() * 1000
|
const timeout = WEBSOCKET_RECONNECT_INTERVAL + reconnectCount.current * 1000 + Math.random() * 1000
|
||||||
setTimeout(() => {
|
setTimeout(
|
||||||
|
() => {
|
||||||
reconnectCount.current += 1
|
reconnectCount.current += 1
|
||||||
establishWebsocketConnection()
|
establishWebsocketConnection()
|
||||||
}, Math.max(timeout, WEBSOCKET_RECONNECT_MAX_DURATION))
|
},
|
||||||
|
Math.max(timeout, WEBSOCKET_RECONNECT_MAX_DURATION)
|
||||||
|
)
|
||||||
})
|
})
|
||||||
socket.addEventListener('open', () => {
|
socket.addEventListener('open', () => {
|
||||||
messageTransporter.setAdapter(new FrontendWebsocketAdapter(socket))
|
messageTransporter.setAdapter(new FrontendWebsocketAdapter(socket))
|
||||||
|
|
|
@ -17,7 +17,10 @@ export interface CodeProps {
|
||||||
* Checks if the given checked node is a code block with a specific language attribute and creates an react-element that receives the code.
|
* Checks if the given checked node is a code block with a specific language attribute and creates an react-element that receives the code.
|
||||||
*/
|
*/
|
||||||
export class CodeBlockComponentReplacer extends ComponentReplacer {
|
export class CodeBlockComponentReplacer extends ComponentReplacer {
|
||||||
constructor(private component: FunctionComponent<CodeProps>, private language: string) {
|
constructor(
|
||||||
|
private component: FunctionComponent<CodeProps>,
|
||||||
|
private language: string
|
||||||
|
) {
|
||||||
super()
|
super()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,10 @@ export interface IdProps {
|
||||||
* Replaces custom tags that have just an id (<app-something id="something"/>) with react elements.
|
* Replaces custom tags that have just an id (<app-something id="something"/>) with react elements.
|
||||||
*/
|
*/
|
||||||
export class CustomTagWithIdComponentReplacer extends ComponentReplacer {
|
export class CustomTagWithIdComponentReplacer extends ComponentReplacer {
|
||||||
constructor(private component: FunctionComponent<IdProps>, private tagName: string) {
|
constructor(
|
||||||
|
private component: FunctionComponent<IdProps>,
|
||||||
|
private tagName: string
|
||||||
|
) {
|
||||||
super()
|
super()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,10 @@ export abstract class WindowPostMessageCommunicator<
|
||||||
private readonly log: Logger
|
private readonly log: Logger
|
||||||
private readonly boundListener: (event: MessageEvent) => void
|
private readonly boundListener: (event: MessageEvent) => void
|
||||||
|
|
||||||
public constructor(private readonly uuid: string, private readonly targetOrigin: string) {
|
public constructor(
|
||||||
|
private readonly uuid: string,
|
||||||
|
private readonly targetOrigin: string
|
||||||
|
) {
|
||||||
this.boundListener = this.handleEvent.bind(this)
|
this.boundListener = this.handleEvent.bind(this)
|
||||||
this.communicationEnabled = false
|
this.communicationEnabled = false
|
||||||
this.log = this.createLogger()
|
this.log = this.createLogger()
|
||||||
|
|
|
@ -26,7 +26,10 @@ export interface QuoteExtraTagValues {
|
||||||
export class BlockquoteExtraTagMarkdownItPlugin {
|
export class BlockquoteExtraTagMarkdownItPlugin {
|
||||||
private static readonly BlockquoteExtraTagRuleName = 'blockquote_extra_tag'
|
private static readonly BlockquoteExtraTagRuleName = 'blockquote_extra_tag'
|
||||||
|
|
||||||
constructor(private tagName: string, private icon: BootstrapIconName) {}
|
constructor(
|
||||||
|
private tagName: string,
|
||||||
|
private icon: BootstrapIconName
|
||||||
|
) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers an inline rule that detects blockquote extra tags and replaces them with blockquote tokens.
|
* Registers an inline rule that detects blockquote extra tags and replaces them with blockquote tokens.
|
||||||
|
|
|
@ -13,7 +13,7 @@ jest.mock(
|
||||||
({
|
({
|
||||||
...jest.requireActual('@hedgedoc/commons'),
|
...jest.requireActual('@hedgedoc/commons'),
|
||||||
generateNoteTitle: () => 'generated title'
|
generateNoteTitle: () => 'generated title'
|
||||||
} as Record<string, unknown>)
|
}) as Record<string, unknown>
|
||||||
)
|
)
|
||||||
|
|
||||||
describe('build state from first heading update', () => {
|
describe('build state from first heading update', () => {
|
||||||
|
|
Loading…
Reference in a new issue