Skip to content

Commit

Permalink
fix: reset ComposerAPI when has chat.composer and node is null
Browse files Browse the repository at this point in the history
  • Loading branch information
dougfabris committed Dec 17, 2024
1 parent 4e000f1 commit 8e3522d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion apps/meteor/app/ui/client/lib/ChatMessages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class ChatMessages implements ChatAPI {

public composer: ComposerAPI | undefined;

public setComposerAPI = (composer: ComposerAPI): void => {
public setComposerAPI = (composer?: ComposerAPI): void => {
this.composer?.release();
this.composer = composer;
};
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/client/lib/chats/ChatAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export type UploadsAPI = {
export type ChatAPI = {
readonly uid: string | null;
readonly composer?: ComposerAPI;
readonly setComposerAPI: (composer: ComposerAPI) => void;
readonly setComposerAPI: (composer?: ComposerAPI) => void;
readonly data: DataAPI;
readonly uploads: UploadsAPI;
readonly readStateManager: ReadStateManager;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,11 @@ const MessageBox = ({

const callbackRef = useCallback(
(node: HTMLTextAreaElement) => {
if (node === null || chat.composer) {
if (node === null && chat.composer) {
return chat.setComposerAPI();
}

if (chat.composer) {
return;
}
chat.setComposerAPI(createComposerAPI(node, storageID));
Expand Down

0 comments on commit 8e3522d

Please sign in to comment.