@acorex/components 20.8.29 → 20.8.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -2253,7 +2253,8 @@ function validateLongitude(longitude) {
|
|
|
2253
2253
|
* Plain class — not DI-registered; instantiated by `AXConversationService`.
|
|
2254
2254
|
*/
|
|
2255
2255
|
function withNormalizedPayload(message) {
|
|
2256
|
-
|
|
2256
|
+
const timestamp = message.timestamp instanceof Date ? message.timestamp : new Date(message.timestamp);
|
|
2257
|
+
return { ...message, timestamp, payload: normalizeMessagePayload(message.payload) };
|
|
2257
2258
|
}
|
|
2258
2259
|
class ConversationState {
|
|
2259
2260
|
constructor(config) {
|
|
@@ -15201,6 +15202,18 @@ class AXConversationService {
|
|
|
15201
15202
|
.subscribe((conversation) => {
|
|
15202
15203
|
this.handleConversationUpdate(conversation);
|
|
15203
15204
|
});
|
|
15205
|
+
// Global message stream — backs message list even when the backend only pushes
|
|
15206
|
+
// conversation.lastMessage updates or when per-conversation subscribe races loadMessages.
|
|
15207
|
+
this.realtimeApi
|
|
15208
|
+
.subscribeToMessages('')
|
|
15209
|
+
.pipe(takeUntil(this.destroy$), catchError((error) => {
|
|
15210
|
+
this.errorHandler.handle(error, 'subscribeToMessages');
|
|
15211
|
+
return EMPTY;
|
|
15212
|
+
}))
|
|
15213
|
+
.subscribe((message) => {
|
|
15214
|
+
this.handleNewMessage(message);
|
|
15215
|
+
this._messageReceived$.next(message);
|
|
15216
|
+
});
|
|
15204
15217
|
}
|
|
15205
15218
|
/**
|
|
15206
15219
|
* Load conversations from server
|
|
@@ -15274,19 +15287,6 @@ class AXConversationService {
|
|
|
15274
15287
|
finally {
|
|
15275
15288
|
this._loadingActiveMessages.set(false);
|
|
15276
15289
|
}
|
|
15277
|
-
// Subscribe to new messages with error handling (only if realtime is available)
|
|
15278
|
-
if (this.realtimeApi) {
|
|
15279
|
-
this.realtimeApi
|
|
15280
|
-
.subscribeToMessages(conversationId)
|
|
15281
|
-
.pipe(takeUntil(this._conversationSwitch$), takeUntil(this.destroy$), catchError((error) => {
|
|
15282
|
-
this.errorHandler.handle(error, 'subscribeToMessages', { conversationId });
|
|
15283
|
-
return EMPTY;
|
|
15284
|
-
}))
|
|
15285
|
-
.subscribe((message) => {
|
|
15286
|
-
this.handleNewMessage(message);
|
|
15287
|
-
this._messageReceived$.next(message);
|
|
15288
|
-
});
|
|
15289
|
-
}
|
|
15290
15290
|
}
|
|
15291
15291
|
catch (error) {
|
|
15292
15292
|
this.errorHandler.handle(error, 'selectConversation', { conversationId });
|
|
@@ -15685,11 +15685,15 @@ class AXConversationService {
|
|
|
15685
15685
|
* Handle new message received
|
|
15686
15686
|
*/
|
|
15687
15687
|
handleNewMessage(message) {
|
|
15688
|
+
if (this.state.getMessage(message.id)) {
|
|
15689
|
+
return;
|
|
15690
|
+
}
|
|
15688
15691
|
this.state.addMessage(message);
|
|
15689
15692
|
this.state.updateLastMessage(message);
|
|
15690
15693
|
const currentId = this._currentUser()?.id ?? 'current-user';
|
|
15691
15694
|
const isFromOtherUser = message.senderId !== currentId;
|
|
15692
|
-
|
|
15695
|
+
const isActiveConversation = message.conversationId === this._activeConversationId();
|
|
15696
|
+
if (isFromOtherUser && !isActiveConversation) {
|
|
15693
15697
|
this.state.incrementUnreadCount(message.conversationId);
|
|
15694
15698
|
}
|
|
15695
15699
|
}
|
|
@@ -15697,6 +15701,13 @@ class AXConversationService {
|
|
|
15697
15701
|
* Handle message update
|
|
15698
15702
|
*/
|
|
15699
15703
|
handleMessageUpdate(message) {
|
|
15704
|
+
const existing = this.state.getMessage(message.id);
|
|
15705
|
+
if (!existing) {
|
|
15706
|
+
if (message.conversationId === this._activeConversationId()) {
|
|
15707
|
+
this.handleNewMessage(message);
|
|
15708
|
+
}
|
|
15709
|
+
return;
|
|
15710
|
+
}
|
|
15700
15711
|
this.state.updateMessage(message.id, message);
|
|
15701
15712
|
}
|
|
15702
15713
|
/**
|
|
@@ -15745,6 +15756,12 @@ class AXConversationService {
|
|
|
15745
15756
|
* Updates conversation metadata including unread count, last message, etc.
|
|
15746
15757
|
*/
|
|
15747
15758
|
handleConversationUpdate(conversation) {
|
|
15759
|
+
const lastMessage = conversation.lastMessage;
|
|
15760
|
+
if (lastMessage &&
|
|
15761
|
+
conversation.id === this._activeConversationId() &&
|
|
15762
|
+
!this.state.getMessage(lastMessage.id)) {
|
|
15763
|
+
this.state.addMessage(lastMessage);
|
|
15764
|
+
}
|
|
15748
15765
|
this.state.setConversation(conversation);
|
|
15749
15766
|
}
|
|
15750
15767
|
/**
|