mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-17 08:34:54 -04:00
fix(frontend): migrate code to use the commons workspace
Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
parent
7320fe2ac1
commit
c489aacea0
9 changed files with 24 additions and 16 deletions
|
@ -4,7 +4,7 @@
|
|||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
import { MARKDOWN_CONTENT_CHANNEL_NAME } from './use-markdown-content-y-text'
|
||||
import { YDocMessageTransporter } from '@hedgedoc/realtime'
|
||||
import { YDocMessageTransporter } from '@hedgedoc/commons'
|
||||
import type { Awareness } from 'y-protocols/awareness'
|
||||
import type { Doc } from 'yjs'
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
import { getGlobalState } from '../../../../../redux'
|
||||
import { isMockMode } from '../../../../../utils/test-modes'
|
||||
import { MockConnection } from './mock-connection'
|
||||
import type { YDocMessageTransporter } from '@hedgedoc/realtime'
|
||||
import type { YDocMessageTransporter } from '@hedgedoc/commons'
|
||||
import { useEffect } from 'react'
|
||||
|
||||
/**
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
import type { YDocMessageTransporter } from '@hedgedoc/realtime'
|
||||
import type { YDocMessageTransporter } from '@hedgedoc/commons'
|
||||
import { useEffect, useState } from 'react'
|
||||
|
||||
/**
|
||||
|
@ -18,9 +18,11 @@ export const useIsConnectionSynced = (connection: YDocMessageTransporter): boole
|
|||
useEffect(() => {
|
||||
const enableEditor = () => setEditorEnabled(true)
|
||||
const disableEditor = () => setEditorEnabled(false)
|
||||
connection.on('synced', enableEditor).on('disconnected', disableEditor)
|
||||
connection.on('synced', enableEditor)
|
||||
connection.on('disconnected', disableEditor)
|
||||
return () => {
|
||||
connection.off('synced', enableEditor).off('disconnected', disableEditor)
|
||||
connection.off('synced', enableEditor)
|
||||
connection.off('disconnected', disableEditor)
|
||||
}
|
||||
}, [connection])
|
||||
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
import { updateMetadata } from '../../../../../redux/note-details/methods'
|
||||
import type { YDocMessageTransporter } from '@hedgedoc/realtime'
|
||||
import { MessageType } from '@hedgedoc/realtime'
|
||||
import type { YDocMessageTransporter } from '@hedgedoc/commons'
|
||||
import { MessageType } from '@hedgedoc/commons'
|
||||
import { useCallback, useEffect } from 'react'
|
||||
|
||||
/**
|
||||
|
@ -19,9 +19,9 @@ export const useOnMetadataUpdated = (websocketConnection: YDocMessageTransporter
|
|||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
websocketConnection.on(MessageType.METADATA_UPDATED, updateMetadataHandler)
|
||||
websocketConnection.on(String(MessageType.METADATA_UPDATED), () => void updateMetadataHandler())
|
||||
return () => {
|
||||
websocketConnection.off(MessageType.METADATA_UPDATED, updateMetadataHandler)
|
||||
websocketConnection.off(String(MessageType.METADATA_UPDATED), () => void updateMetadataHandler())
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
import { useApplicationState } from '../../../../../hooks/common/use-application-state'
|
||||
import { Logger } from '../../../../../utils/logger'
|
||||
import { useUiNotifications } from '../../../../notifications/ui-notification-boundary'
|
||||
import type { YDocMessageTransporter } from '@hedgedoc/realtime'
|
||||
import { MessageType } from '@hedgedoc/realtime'
|
||||
import type { YDocMessageTransporter } from '@hedgedoc/commons'
|
||||
import { MessageType } from '@hedgedoc/commons'
|
||||
import { useRouter } from 'next/router'
|
||||
import { useCallback, useEffect } from 'react'
|
||||
|
||||
|
@ -35,9 +35,9 @@ export const useOnNoteDeleted = (websocketConnection: YDocMessageTransporter): v
|
|||
}, [router, noteTitle, dispatchUiNotification])
|
||||
|
||||
useEffect(() => {
|
||||
websocketConnection.on(MessageType.DOCUMENT_DELETED, noteDeletedHandler)
|
||||
websocketConnection.on(String(MessageType.DOCUMENT_DELETED), noteDeletedHandler)
|
||||
return () => {
|
||||
websocketConnection.off(MessageType.DOCUMENT_DELETED, noteDeletedHandler)
|
||||
websocketConnection.off(String(MessageType.DOCUMENT_DELETED), noteDeletedHandler)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ import { isMockMode } from '../../../../../utils/test-modes'
|
|||
import { MockConnection } from './mock-connection'
|
||||
import { useWebsocketUrl } from './use-websocket-url'
|
||||
import { WebsocketConnection } from './websocket-connection'
|
||||
import type { YDocMessageTransporter } from '@hedgedoc/realtime'
|
||||
import type { YDocMessageTransporter } from '@hedgedoc/commons'
|
||||
import { useEffect, useMemo } from 'react'
|
||||
import type { Awareness } from 'y-protocols/awareness'
|
||||
import type { Doc } from 'yjs'
|
||||
|
|
|
@ -8,7 +8,7 @@ import {
|
|||
encodeCompleteAwarenessStateRequestMessage,
|
||||
encodeDocumentUpdateMessage,
|
||||
WebsocketTransporter
|
||||
} from '@hedgedoc/realtime'
|
||||
} from '@hedgedoc/commons'
|
||||
import WebSocket from 'isomorphic-ws'
|
||||
import type { Awareness } from 'y-protocols/awareness'
|
||||
import type { Doc } from 'yjs'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue