-
Notifications
You must be signed in to change notification settings - Fork 448
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(types): add typings for EventBus
Signed-off-by: Maksim Sukharev <antreesy.web@gmail.com>
- Loading branch information
Showing
4 changed files
with
63 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/** | ||
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors | ||
* SPDX-License-Identifier: AGPL-3.0-or-later | ||
*/ | ||
// import type { components, operations } from './openapi/openapi-full.ts' | ||
|
||
import type { Emitter, EventType, Handler, WildcardHandler } from 'mitt' | ||
import type { Route } from 'vue-router' | ||
|
||
import type { ChatMessage, Conversation, Participant } from './index.ts' | ||
import type { components } from './openapi/openapi-full.ts' | ||
|
||
// List of used events across the app | ||
export type Events = Record<EventType, unknown> & { | ||
'audio-player-ended': number, | ||
'conversations-received': { singleConversation: boolean }, | ||
'deleted-session-detected': void, | ||
'duplicate-session-detected': void, | ||
'editing-message': void, | ||
'editing-message-processing': { messageId: number, value: boolean }, | ||
'focus-chat-input': void, | ||
'focus-message': number, // TODO: listener method can receive ...[messageId, smooth, highlightAnimation] | ||
'forbidden-route': { error: string }, | ||
'joined-conversation': { token: string }, | ||
'message-height-changed': { heightDiff: number }, | ||
'poll-drafts-open': void, | ||
'poll-editor-open': number, | ||
'refresh-peer-list': void, | ||
'retry-message': number, | ||
'route-change': { from: Route, to: Route }, | ||
'scroll-chat-to-bottom': { smooth?: boolean, force?: boolean }, | ||
'should-refresh-chat-messages': void, | ||
'should-refresh-conversations': { token: string, properties: Partial<Conversation> } | { all: true } | void, | ||
'signaling-join-call': [string, number], | ||
'signaling-join-call-failed': [string, { meta: components['schemas']['OCSMeta'], data: { error: string } }], | ||
'signaling-join-room': [string], | ||
'signaling-participant-list-changed': void, | ||
'signaling-recording-status-changed': [string, number], | ||
'signaling-servers-updated': { server: string, verify: boolean }[], | ||
'signaling-users-changed': [(Partial<Participant> & ({ sessionId: string } | { nextcloudSessionId: string }))[]], | ||
'signaling-users-in-room': [{ sessionId: string, userId: string }[]], | ||
'smart-picker-open': void, | ||
'switch-to-conversation': { token: string }, | ||
'talk:poll-added': { token: string, message: ChatMessage }, | ||
'upload-discard': void, | ||
'upload-finished': void, | ||
'upload-start': void, | ||
} | ||
|
||
// Extended event for mitt() library | ||
export type GenericEventHandler = Handler<Events[keyof Events]> | WildcardHandler<Events> | ||
export type ExtendedEmitter = Emitter<Events> & { | ||
once<Key extends keyof Events>(type: Key, handler: Handler<Events[Key]>): void | ||
once(type: '*', handler: WildcardHandler<Events>): void | ||
_onceHandlers: Map<keyof Events | '*', Map<GenericEventHandler, GenericEventHandler>> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters