Skip to content
Snippets Groups Projects
Commit d4e8aa81 authored by Léopold Chappuis's avatar Léopold Chappuis Committed by Léopold Chappuis
Browse files

conversation-loading: implement automatic reload upon conversation retrieval

This change aims to prevent the user from needing to refresh the page to view their loaded conversation.

Change-Id: Ie4e0e385d261d5a2ac5cab610463ede3caf8d96a
parent f441ad50
Branches
No related tags found
No related merge requests found
...@@ -116,14 +116,11 @@ const SummariesTabPanel = (props: TabPanelProps) => { ...@@ -116,14 +116,11 @@ const SummariesTabPanel = (props: TabPanelProps) => {
const refreshConversationsSummaries = useRefreshConversationsSummaries() const refreshConversationsSummaries = useRefreshConversationsSummaries()
useEffect(() => { useEffect(() => {
function conversationMessageListener() { websocket.bind(WebSocketMessageType.ConversationMessage, refreshConversationsSummaries)
refreshConversationsSummaries() websocket.bind(WebSocketMessageType.ConversationReady, refreshConversationsSummaries)
}
websocket.bind(WebSocketMessageType.ConversationMessage, conversationMessageListener)
return () => { return () => {
websocket.unbind(WebSocketMessageType.ConversationMessage, conversationMessageListener) websocket.unbind(WebSocketMessageType.ConversationMessage, refreshConversationsSummaries)
websocket.unbind(WebSocketMessageType.ConversationReady, refreshConversationsSummaries)
} }
}, [websocket, refreshConversationsSummaries]) }, [websocket, refreshConversationsSummaries])
......
...@@ -30,6 +30,7 @@ export enum WebSocketMessageType { ...@@ -30,6 +30,7 @@ export enum WebSocketMessageType {
LoadMoreMessages = 'load-more-messages', LoadMoreMessages = 'load-more-messages',
LoadSwarmUntil = 'load-swarm-until', LoadSwarmUntil = 'load-swarm-until',
KnownDevicesChanged = 'known-devices-changed', KnownDevicesChanged = 'known-devices-changed',
ConversationReady = 'conversation-ready',
// calls (in the order they should be sent) // calls (in the order they should be sent)
sendCallInvite = 'sendCallInvite', sendCallInvite = 'sendCallInvite',
......
...@@ -47,6 +47,10 @@ export interface ConversationView { ...@@ -47,6 +47,10 @@ export interface ConversationView {
conversationId: string conversationId: string
} }
export interface ConversationReady {
conversationId: string
}
export interface AccountMessageStatus { export interface AccountMessageStatus {
conversationId: string conversationId: string
peer: string peer: string
......
...@@ -25,6 +25,7 @@ import { ...@@ -25,6 +25,7 @@ import {
ComposingStatus, ComposingStatus,
ConversationMemberEvent, ConversationMemberEvent,
ConversationMessage, ConversationMessage,
ConversationReady,
ConversationView, ConversationView,
IAccountDetails, IAccountDetails,
IKnownDevicesChanged, IKnownDevicesChanged,
...@@ -54,6 +55,7 @@ export interface WebSocketMessageTable { ...@@ -54,6 +55,7 @@ export interface WebSocketMessageTable {
[WebSocketMessageType.LoadMoreMessages]: LoadMoreMessages [WebSocketMessageType.LoadMoreMessages]: LoadMoreMessages
[WebSocketMessageType.LoadSwarmUntil]: LoadSwarmUntil [WebSocketMessageType.LoadSwarmUntil]: LoadSwarmUntil
[WebSocketMessageType.KnownDevicesChanged]: IKnownDevicesChanged [WebSocketMessageType.KnownDevicesChanged]: IKnownDevicesChanged
[WebSocketMessageType.ConversationReady]: ConversationReady
// calls (in the order they should be sent) // calls (in the order they should be sent)
[WebSocketMessageType.sendCallInvite]: CallInvite [WebSocketMessageType.sendCallInvite]: CallInvite
......
...@@ -856,6 +856,9 @@ export class Jamid { ...@@ -856,6 +856,9 @@ export class Jamid {
this.events.onConversationReady.subscribe((signal) => { this.events.onConversationReady.subscribe((signal) => {
log.debug('Received ConversationReady:', JSON.stringify(signal)) log.debug('Received ConversationReady:', JSON.stringify(signal))
this.webSocketServer.send(signal.accountId, WebSocketMessageType.ConversationReady, {
conversationId: signal.conversationId,
})
}) })
this.events.onConversationRemoved.subscribe((signal) => { this.events.onConversationRemoved.subscribe((signal) => {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment