@@ -84,19 +84,19 @@ extension MessageCollectionManager on CollectionManager {
8484 }
8585
8686//------------------------------//
87- // resetMyHistory
87+ // updateMessageOffsetTimestamp
8888//------------------------------//
89- Future <void > resetMyHistory ({
89+ Future <void > updateMessageOffsetTimestamp ({
9090 required String channelUrl,
91- int ? messageOffsetTimestamp,
91+ required int messageOffsetTimestamp,
9292 }) async {
93- sbLog.d (StackTrace .current, 'resetMyHistory ()' );
93+ sbLog.d (StackTrace .current, 'updateMessageOffsetTimestamp ()' );
9494
9595 for (final collection in baseMessageCollections) {
9696 if (collection is MessageCollection ) {
9797 if (collection.isInitialized) {
9898 if (collection.baseChannel.channelUrl == channelUrl) {
99- await collection.resetMyHistory (
99+ await collection.updateMessageOffsetTimestamp (
100100 channelUrl: channelUrl,
101101 messageOffsetTimestamp: messageOffsetTimestamp,
102102 );
@@ -610,7 +610,7 @@ extension MessageCollectionManager on CollectionManager {
610610 List <RootMessage >? updatedMessages,
611611 List <dynamic >? deletedMessageIds,
612612 bool doNotSendDeleteEvent = false ,
613- bool isResetMyHistory = false ,
613+ bool isMessageOffsetTimestampUpdated = false ,
614614 }) async {
615615 sbLog.d (StackTrace .current,
616616 'channelUrl: ${messageCollection .baseChannel .channelUrl }, ${eventSource .toString ()}' );
@@ -623,7 +623,8 @@ extension MessageCollectionManager on CollectionManager {
623623 if (_chat.dbManager.isEnabled ()) {
624624 // [First] delete
625625 if (deletedMessageIds != null && deletedMessageIds.isNotEmpty) {
626- if (eventSource != CollectionEventSource .messageInitialize &&
626+ if (! (eventSource == CollectionEventSource .messageInitialize &&
627+ deletedMessageIds.length == addedMessages? .length) && // Check
627628 eventSource != CollectionEventSource .messageLoadPrevious &&
628629 eventSource != CollectionEventSource .messageLoadNext) {
629630 List <String > deletedStringIds = deletedMessageIds
@@ -772,7 +773,8 @@ extension MessageCollectionManager on CollectionManager {
772773 }
773774
774775 //+ [DBManager]
775- if (eventSource == CollectionEventSource .messageFill || isResetMyHistory) {
776+ if (eventSource == CollectionEventSource .messageFill ||
777+ isMessageOffsetTimestampUpdated) {
776778 messageCollection.setValuesFromMessageList (); // Check
777779 }
778780 //- [DBManager]
0 commit comments