Uniformize WebSocketMessageType
Change-Id: I26d0f193804773d5835413deb4f4e26d30ea711a
diff --git a/client/src/components/SendMessageForm.tsx b/client/src/components/SendMessageForm.tsx
index c0b9253..e5d2371 100644
--- a/client/src/components/SendMessageForm.tsx
+++ b/client/src/components/SendMessageForm.tsx
@@ -52,13 +52,13 @@
// We ensure it will stay on at least 4 seconds after the last typed character
if (currentTime - composingNotificationTimeRef.current > 8000) {
composingNotificationTimeRef.current = currentTime;
- webSocket?.send(WebSocketMessageType.SetIsComposing, { conversationId, isWriting: true });
+ webSocket?.send(WebSocketMessageType.ComposingStatus, { conversationId, isWriting: true });
}
}, [webSocket, conversationId]);
const notifyStopcomposing = useCallback(() => {
composingNotificationTimeRef.current = 0;
- webSocket?.send(WebSocketMessageType.SetIsComposing, { conversationId, isWriting: false });
+ webSocket?.send(WebSocketMessageType.ComposingStatus, { conversationId, isWriting: false });
}, [webSocket, conversationId]);
const handleSubmit = useCallback(
diff --git a/client/src/contexts/ConversationProvider.tsx b/client/src/contexts/ConversationProvider.tsx
index 3c24896..d518c64 100644
--- a/client/src/contexts/ConversationProvider.tsx
+++ b/client/src/contexts/ConversationProvider.tsx
@@ -105,9 +105,9 @@
};
webSocket.send(WebSocketMessageType.ConversationView, conversationView);
- webSocket.bind(WebSocketMessageType.OnComposingStatusChanged, onComposingStatusChanged);
+ webSocket.bind(WebSocketMessageType.ComposingStatus, onComposingStatusChanged);
- return () => webSocket.unbind(WebSocketMessageType.OnComposingStatusChanged, onComposingStatusChanged);
+ return () => webSocket.unbind(WebSocketMessageType.ComposingStatus, onComposingStatusChanged);
}, [accountId, conversationInfos, conversationId, onComposingStatusChanged, webSocket]);
const value = useMemo(() => {
diff --git a/common/src/enums/websocket-message-type.ts b/common/src/enums/websocket-message-type.ts
index 512c1dc..238f443 100644
--- a/common/src/enums/websocket-message-type.ts
+++ b/common/src/enums/websocket-message-type.ts
@@ -19,8 +19,7 @@
ConversationMessage = 'conversation-message',
ConversationRequest = 'conversation-request',
ConversationView = 'conversation-view',
- OnComposingStatusChanged = 'on-composing-status-changed', // Sent by server to indicate who is composing a message or not
- SetIsComposing = 'set-is-composing', // Sent by user to indicate whether they are composing a message or not
+ ComposingStatus = 'composing-status',
CallBegin = 'call-begin',
CallAccept = 'call-accept',
CallEnd = 'call-end',
diff --git a/common/src/interfaces/websocket-message.ts b/common/src/interfaces/websocket-message.ts
index d633059..b908737 100644
--- a/common/src/interfaces/websocket-message.ts
+++ b/common/src/interfaces/websocket-message.ts
@@ -28,14 +28,13 @@
} from './websocket-interfaces.js';
export interface WebSocketMessageTable {
+ [WebSocketMessageType.CallAccept]: CallAction;
+ [WebSocketMessageType.CallBegin]: CallBegin;
+ [WebSocketMessageType.CallEnd]: CallAction;
+ [WebSocketMessageType.ComposingStatus]: ComposingStatus;
[WebSocketMessageType.ConversationMessage]: ConversationMessage;
[WebSocketMessageType.ConversationRequest]: IConversationRequest;
[WebSocketMessageType.ConversationView]: ConversationView;
- [WebSocketMessageType.OnComposingStatusChanged]: ComposingStatus;
- [WebSocketMessageType.SetIsComposing]: ComposingStatus;
- [WebSocketMessageType.CallBegin]: CallBegin;
- [WebSocketMessageType.CallAccept]: CallAction;
- [WebSocketMessageType.CallEnd]: CallAction;
[WebSocketMessageType.WebRtcOffer]: WebRtcSdp;
[WebSocketMessageType.WebRtcAnswer]: WebRtcSdp;
[WebSocketMessageType.WebRtcIceCandidate]: WebRtcIceCandidate;
diff --git a/server/src/jamid/jamid.ts b/server/src/jamid/jamid.ts
index 15ff23c..7ca3ea2 100644
--- a/server/src/jamid/jamid.ts
+++ b/server/src/jamid/jamid.ts
@@ -538,7 +538,7 @@
conversationId: signal.conversationId,
isWriting: signal.status === 1,
};
- this.webSocketServer.send(signal.accountId, WebSocketMessageType.OnComposingStatusChanged, data);
+ this.webSocketServer.send(signal.accountId, WebSocketMessageType.ComposingStatus, data);
});
}
}
diff --git a/server/src/websocket/chat-handler.ts b/server/src/websocket/chat-handler.ts
index 161203b..8789544 100644
--- a/server/src/websocket/chat-handler.ts
+++ b/server/src/websocket/chat-handler.ts
@@ -27,10 +27,10 @@
export function bindChatCallbacks() {
webSocketServer.bind(
- WebSocketMessageType.SetIsComposing,
+ WebSocketMessageType.ComposingStatus,
(accountId, { contactId, conversationId, isWriting }: ComposingStatus) => {
if (contactId !== undefined) {
- log.warn('SetIsComposing expects contactId to be undefined');
+ log.warn('ComposingStatus expects contactId to be undefined');
return;
}