@onyx-p/imlib-web 2.3.4 → 2.3.5
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.
- package/index.esm.js +27 -69
- package/index.umd.js +27 -69
- package/package.json +1 -1
package/index.esm.js
CHANGED
@@ -21102,87 +21102,44 @@ class MessageCache {
|
|
21102
21102
|
if (!messageUIds || messageUIds.length === 0 || !this.db) {
|
21103
21103
|
return;
|
21104
21104
|
}
|
21105
|
-
|
21106
|
-
|
21107
|
-
|
21108
|
-
|
21109
|
-
|
21110
|
-
|
21111
|
-
const
|
21112
|
-
|
21113
|
-
|
21114
|
-
if (completed === messageUIds.length && !hasError) {
|
21115
|
-
resolve();
|
21116
|
-
}
|
21117
|
-
};
|
21118
|
-
deleteRequest.onerror = event => {
|
21119
|
-
logger.error('Failed to delete message', id, event);
|
21120
|
-
if (!hasError) {
|
21121
|
-
hasError = true;
|
21122
|
-
reject(new Error('Failed to delete message'));
|
21123
|
-
}
|
21124
|
-
};
|
21125
|
-
});
|
21126
|
-
transaction.oncomplete = () => {
|
21127
|
-
if (!hasError) {
|
21128
|
-
resolve();
|
21105
|
+
const transaction = this.db.transaction(this.STORE_NAME, 'readwrite');
|
21106
|
+
const store = transaction.objectStore(this.STORE_NAME);
|
21107
|
+
const index = store.index('messageUId');
|
21108
|
+
messageUIds.forEach(messageUId => {
|
21109
|
+
const getRequest = index.get(messageUId);
|
21110
|
+
getRequest.onsuccess = () => {
|
21111
|
+
const message = getRequest.result;
|
21112
|
+
if (message) {
|
21113
|
+
store.delete(message.messageId);
|
21129
21114
|
}
|
21130
21115
|
};
|
21131
|
-
transaction.onerror = event => {
|
21132
|
-
reject(new Error('Batch delete message transaction failed'));
|
21133
|
-
};
|
21134
21116
|
});
|
21135
21117
|
}
|
21136
21118
|
async updateMessageReceiptStatus(event, type) {
|
21137
21119
|
if (!event || !event.messageUIdList || event.messageUIdList.length === 0 || !this.db) {
|
21138
21120
|
return;
|
21139
21121
|
}
|
21140
|
-
const
|
21141
|
-
|
21142
|
-
|
21143
|
-
|
21144
|
-
|
21145
|
-
|
21146
|
-
|
21147
|
-
|
21148
|
-
|
21149
|
-
|
21150
|
-
|
21151
|
-
|
21152
|
-
|
21153
|
-
|
21154
|
-
|
21155
|
-
if (type === 0 && message.receivedStatus < ReceivedStatus.RECEIVED) {
|
21156
|
-
message.receivedStatus = ReceivedStatus.RECEIVED;
|
21157
|
-
needUpdate = true;
|
21158
|
-
} else if (type === 1 && message.receivedStatus < ReceivedStatus.READ) {
|
21159
|
-
message.receivedStatus = ReceivedStatus.READ;
|
21160
|
-
needUpdate = true;
|
21161
|
-
}
|
21162
|
-
if (needUpdate) {
|
21163
|
-
store.put(message);
|
21164
|
-
}
|
21165
|
-
}
|
21166
|
-
completed++;
|
21167
|
-
if (completed === event.messageUIdList.length && !hasError) {
|
21168
|
-
resolve();
|
21122
|
+
const transaction = this.db.transaction(this.STORE_NAME, 'readwrite');
|
21123
|
+
const store = transaction.objectStore(this.STORE_NAME);
|
21124
|
+
const index = store.index('messageUId');
|
21125
|
+
event.messageUIdList.forEach(messageUId => {
|
21126
|
+
const getRequest = index.get(messageUId);
|
21127
|
+
getRequest.onsuccess = () => {
|
21128
|
+
const message = getRequest.result;
|
21129
|
+
if (message) {
|
21130
|
+
let needUpdate = false;
|
21131
|
+
if (type === 0 && message.receivedStatus < ReceivedStatus.RECEIVED) {
|
21132
|
+
message.receivedStatus = ReceivedStatus.RECEIVED;
|
21133
|
+
needUpdate = true;
|
21134
|
+
} else if (type === 1 && message.receivedStatus < ReceivedStatus.READ) {
|
21135
|
+
message.receivedStatus = ReceivedStatus.READ;
|
21136
|
+
needUpdate = true;
|
21169
21137
|
}
|
21170
|
-
|
21171
|
-
|
21172
|
-
if (!hasError) {
|
21173
|
-
hasError = true;
|
21174
|
-
reject(new Error('更新消息状态失败'));
|
21138
|
+
if (needUpdate) {
|
21139
|
+
store.put(message);
|
21175
21140
|
}
|
21176
|
-
};
|
21177
|
-
});
|
21178
|
-
transaction.oncomplete = () => {
|
21179
|
-
if (!hasError) {
|
21180
|
-
resolve();
|
21181
21141
|
}
|
21182
21142
|
};
|
21183
|
-
transaction.onerror = event => {
|
21184
|
-
reject(new Error('更新消息状态事务失败'));
|
21185
|
-
};
|
21186
21143
|
});
|
21187
21144
|
}
|
21188
21145
|
async clearBurnAfterReadingExpiredMessages(conversation) {
|
@@ -21480,6 +21437,7 @@ class MessageLoader {
|
|
21480
21437
|
l.forEach(m => {
|
21481
21438
|
if (m.messageType === MessageTypes.RECALL && RecallMessageStore.has(m.content.messageUId)) {
|
21482
21439
|
RecallMessageStore.remove(m.content.messageUId);
|
21440
|
+
recallMessageUIds.push(m.content.messageUId);
|
21483
21441
|
} else {
|
21484
21442
|
m.isOffLineMessage = isOffLineMessage;
|
21485
21443
|
if (!m.messageId || m.messageId > getCurrentMessageId()) {
|
package/index.umd.js
CHANGED
@@ -21108,87 +21108,44 @@
|
|
21108
21108
|
if (!messageUIds || messageUIds.length === 0 || !this.db) {
|
21109
21109
|
return;
|
21110
21110
|
}
|
21111
|
-
|
21112
|
-
|
21113
|
-
|
21114
|
-
|
21115
|
-
|
21116
|
-
|
21117
|
-
const
|
21118
|
-
|
21119
|
-
|
21120
|
-
if (completed === messageUIds.length && !hasError) {
|
21121
|
-
resolve();
|
21122
|
-
}
|
21123
|
-
};
|
21124
|
-
deleteRequest.onerror = event => {
|
21125
|
-
logger.error('Failed to delete message', id, event);
|
21126
|
-
if (!hasError) {
|
21127
|
-
hasError = true;
|
21128
|
-
reject(new Error('Failed to delete message'));
|
21129
|
-
}
|
21130
|
-
};
|
21131
|
-
});
|
21132
|
-
transaction.oncomplete = () => {
|
21133
|
-
if (!hasError) {
|
21134
|
-
resolve();
|
21111
|
+
const transaction = this.db.transaction(this.STORE_NAME, 'readwrite');
|
21112
|
+
const store = transaction.objectStore(this.STORE_NAME);
|
21113
|
+
const index = store.index('messageUId');
|
21114
|
+
messageUIds.forEach(messageUId => {
|
21115
|
+
const getRequest = index.get(messageUId);
|
21116
|
+
getRequest.onsuccess = () => {
|
21117
|
+
const message = getRequest.result;
|
21118
|
+
if (message) {
|
21119
|
+
store.delete(message.messageId);
|
21135
21120
|
}
|
21136
21121
|
};
|
21137
|
-
transaction.onerror = event => {
|
21138
|
-
reject(new Error('Batch delete message transaction failed'));
|
21139
|
-
};
|
21140
21122
|
});
|
21141
21123
|
}
|
21142
21124
|
async updateMessageReceiptStatus(event, type) {
|
21143
21125
|
if (!event || !event.messageUIdList || event.messageUIdList.length === 0 || !this.db) {
|
21144
21126
|
return;
|
21145
21127
|
}
|
21146
|
-
const
|
21147
|
-
|
21148
|
-
|
21149
|
-
|
21150
|
-
|
21151
|
-
|
21152
|
-
|
21153
|
-
|
21154
|
-
|
21155
|
-
|
21156
|
-
|
21157
|
-
|
21158
|
-
|
21159
|
-
|
21160
|
-
|
21161
|
-
if (type === 0 && message.receivedStatus < exports.ReceivedStatus.RECEIVED) {
|
21162
|
-
message.receivedStatus = exports.ReceivedStatus.RECEIVED;
|
21163
|
-
needUpdate = true;
|
21164
|
-
} else if (type === 1 && message.receivedStatus < exports.ReceivedStatus.READ) {
|
21165
|
-
message.receivedStatus = exports.ReceivedStatus.READ;
|
21166
|
-
needUpdate = true;
|
21167
|
-
}
|
21168
|
-
if (needUpdate) {
|
21169
|
-
store.put(message);
|
21170
|
-
}
|
21171
|
-
}
|
21172
|
-
completed++;
|
21173
|
-
if (completed === event.messageUIdList.length && !hasError) {
|
21174
|
-
resolve();
|
21128
|
+
const transaction = this.db.transaction(this.STORE_NAME, 'readwrite');
|
21129
|
+
const store = transaction.objectStore(this.STORE_NAME);
|
21130
|
+
const index = store.index('messageUId');
|
21131
|
+
event.messageUIdList.forEach(messageUId => {
|
21132
|
+
const getRequest = index.get(messageUId);
|
21133
|
+
getRequest.onsuccess = () => {
|
21134
|
+
const message = getRequest.result;
|
21135
|
+
if (message) {
|
21136
|
+
let needUpdate = false;
|
21137
|
+
if (type === 0 && message.receivedStatus < exports.ReceivedStatus.RECEIVED) {
|
21138
|
+
message.receivedStatus = exports.ReceivedStatus.RECEIVED;
|
21139
|
+
needUpdate = true;
|
21140
|
+
} else if (type === 1 && message.receivedStatus < exports.ReceivedStatus.READ) {
|
21141
|
+
message.receivedStatus = exports.ReceivedStatus.READ;
|
21142
|
+
needUpdate = true;
|
21175
21143
|
}
|
21176
|
-
|
21177
|
-
|
21178
|
-
if (!hasError) {
|
21179
|
-
hasError = true;
|
21180
|
-
reject(new Error('更新消息状态失败'));
|
21144
|
+
if (needUpdate) {
|
21145
|
+
store.put(message);
|
21181
21146
|
}
|
21182
|
-
};
|
21183
|
-
});
|
21184
|
-
transaction.oncomplete = () => {
|
21185
|
-
if (!hasError) {
|
21186
|
-
resolve();
|
21187
21147
|
}
|
21188
21148
|
};
|
21189
|
-
transaction.onerror = event => {
|
21190
|
-
reject(new Error('更新消息状态事务失败'));
|
21191
|
-
};
|
21192
21149
|
});
|
21193
21150
|
}
|
21194
21151
|
async clearBurnAfterReadingExpiredMessages(conversation) {
|
@@ -21486,6 +21443,7 @@
|
|
21486
21443
|
l.forEach(m => {
|
21487
21444
|
if (m.messageType === MessageTypes.RECALL && RecallMessageStore.has(m.content.messageUId)) {
|
21488
21445
|
RecallMessageStore.remove(m.content.messageUId);
|
21446
|
+
recallMessageUIds.push(m.content.messageUId);
|
21489
21447
|
} else {
|
21490
21448
|
m.isOffLineMessage = isOffLineMessage;
|
21491
21449
|
if (!m.messageId || m.messageId > getCurrentMessageId()) {
|