@onyx-p/imlib-web 2.6.8 → 2.7.0
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 +47 -30
- package/index.umd.js +47 -30
- package/package.json +4 -9
package/index.esm.js
CHANGED
@@ -22469,44 +22469,62 @@ class MessageCache {
|
|
22469
22469
|
return decryptedMessage;
|
22470
22470
|
}
|
22471
22471
|
async addMessages(messages, toConversation, isEnd = undefined) {
|
22472
|
-
const dialogId = getFullDialogId(toConversation);
|
22473
|
-
if (isDef(isEnd)) {
|
22474
|
-
await this.updateDialogState(dialogId, isEnd);
|
22475
|
-
}
|
22476
22472
|
if (!messages || messages.length === 0 || !this.db) {
|
22473
|
+
if (isDef(isEnd)) {
|
22474
|
+
const dialogId = getFullDialogId(toConversation);
|
22475
|
+
await this.updateDialogState(dialogId, isEnd);
|
22476
|
+
}
|
22477
22477
|
return;
|
22478
22478
|
}
|
22479
|
-
const
|
22480
|
-
|
22481
|
-
|
22482
|
-
|
22483
|
-
|
22484
|
-
|
22485
|
-
|
22486
|
-
|
22487
|
-
|
22488
|
-
|
22479
|
+
const dialogId = getFullDialogId(toConversation);
|
22480
|
+
return new Promise(resolve => {
|
22481
|
+
try {
|
22482
|
+
const transaction = this.db.transaction(this.STORE_NAME, 'readwrite');
|
22483
|
+
const store = transaction.objectStore(this.STORE_NAME);
|
22484
|
+
transaction.oncomplete = async () => {
|
22485
|
+
if (isDef(isEnd)) {
|
22486
|
+
try {
|
22487
|
+
await this.updateDialogState(dialogId, isEnd);
|
22488
|
+
} catch (err) {
|
22489
|
+
logger$1.error('Failed to update dialog state:', err);
|
22490
|
+
}
|
22489
22491
|
}
|
22490
|
-
|
22491
|
-
|
22492
|
+
resolve();
|
22493
|
+
};
|
22494
|
+
transaction.onerror = event => {
|
22495
|
+
logger$1.error('Transaction failed in addMessages:', messages, transaction.error);
|
22496
|
+
if (isDef(isEnd)) {
|
22497
|
+
this.updateDialogState(dialogId, isEnd).catch(err => logger$1.error('Failed to update dialog state after transaction error:', err)).finally(() => resolve());
|
22498
|
+
} else {
|
22499
|
+
resolve();
|
22492
22500
|
}
|
22493
|
-
|
22494
|
-
|
22495
|
-
|
22496
|
-
|
22497
|
-
|
22498
|
-
|
22499
|
-
|
22501
|
+
};
|
22502
|
+
for (const message of messages) {
|
22503
|
+
try {
|
22504
|
+
const messageToStore = {
|
22505
|
+
...message,
|
22506
|
+
dialogId
|
22507
|
+
};
|
22508
|
+
if (messageToStore.content) {
|
22509
|
+
messageToStore.content = this.encryptContent(messageToStore.content);
|
22500
22510
|
}
|
22501
|
-
|
22502
|
-
|
22503
|
-
|
22504
|
-
|
22511
|
+
if (messageToStore.quotedReply?.content) {
|
22512
|
+
messageToStore.quotedReply.content = this.encryptContent(messageToStore.quotedReply.content);
|
22513
|
+
}
|
22514
|
+
store.put(messageToStore);
|
22515
|
+
} catch (err) {
|
22516
|
+
logger$1.error('Error processing message:', message, err);
|
22517
|
+
}
|
22518
|
+
}
|
22519
|
+
} catch (err) {
|
22520
|
+
logger$1.error('Failed to start transaction:', err);
|
22521
|
+
if (isDef(isEnd)) {
|
22522
|
+
this.updateDialogState(dialogId, isEnd).catch(stateErr => logger$1.error('Failed to update dialog state:', stateErr)).finally(() => resolve());
|
22523
|
+
} else {
|
22505
22524
|
resolve();
|
22506
22525
|
}
|
22507
|
-
}
|
22526
|
+
}
|
22508
22527
|
});
|
22509
|
-
await Promise.allSettled(insertPromises);
|
22510
22528
|
}
|
22511
22529
|
async getPreviousMessages(conversation, timestamp = "0", count = 20) {
|
22512
22530
|
const dialogId = getFullDialogId(conversation);
|
@@ -23586,7 +23604,6 @@ class Logger {
|
|
23586
23604
|
};
|
23587
23605
|
try {
|
23588
23606
|
if (level === LogLevel.ERROR) {
|
23589
|
-
debugger;
|
23590
23607
|
analyticsManager.trackEvent('error_log', {
|
23591
23608
|
timestamp: logEntry.timestamp,
|
23592
23609
|
content: logEntry.content
|
package/index.umd.js
CHANGED
@@ -22475,44 +22475,62 @@
|
|
22475
22475
|
return decryptedMessage;
|
22476
22476
|
}
|
22477
22477
|
async addMessages(messages, toConversation, isEnd = undefined) {
|
22478
|
-
const dialogId = getFullDialogId(toConversation);
|
22479
|
-
if (isDef(isEnd)) {
|
22480
|
-
await this.updateDialogState(dialogId, isEnd);
|
22481
|
-
}
|
22482
22478
|
if (!messages || messages.length === 0 || !this.db) {
|
22479
|
+
if (isDef(isEnd)) {
|
22480
|
+
const dialogId = getFullDialogId(toConversation);
|
22481
|
+
await this.updateDialogState(dialogId, isEnd);
|
22482
|
+
}
|
22483
22483
|
return;
|
22484
22484
|
}
|
22485
|
-
const
|
22486
|
-
|
22487
|
-
|
22488
|
-
|
22489
|
-
|
22490
|
-
|
22491
|
-
|
22492
|
-
|
22493
|
-
|
22494
|
-
|
22485
|
+
const dialogId = getFullDialogId(toConversation);
|
22486
|
+
return new Promise(resolve => {
|
22487
|
+
try {
|
22488
|
+
const transaction = this.db.transaction(this.STORE_NAME, 'readwrite');
|
22489
|
+
const store = transaction.objectStore(this.STORE_NAME);
|
22490
|
+
transaction.oncomplete = async () => {
|
22491
|
+
if (isDef(isEnd)) {
|
22492
|
+
try {
|
22493
|
+
await this.updateDialogState(dialogId, isEnd);
|
22494
|
+
} catch (err) {
|
22495
|
+
logger$1.error('Failed to update dialog state:', err);
|
22496
|
+
}
|
22495
22497
|
}
|
22496
|
-
|
22497
|
-
|
22498
|
+
resolve();
|
22499
|
+
};
|
22500
|
+
transaction.onerror = event => {
|
22501
|
+
logger$1.error('Transaction failed in addMessages:', messages, transaction.error);
|
22502
|
+
if (isDef(isEnd)) {
|
22503
|
+
this.updateDialogState(dialogId, isEnd).catch(err => logger$1.error('Failed to update dialog state after transaction error:', err)).finally(() => resolve());
|
22504
|
+
} else {
|
22505
|
+
resolve();
|
22498
22506
|
}
|
22499
|
-
|
22500
|
-
|
22501
|
-
|
22502
|
-
|
22503
|
-
|
22504
|
-
|
22505
|
-
|
22507
|
+
};
|
22508
|
+
for (const message of messages) {
|
22509
|
+
try {
|
22510
|
+
const messageToStore = {
|
22511
|
+
...message,
|
22512
|
+
dialogId
|
22513
|
+
};
|
22514
|
+
if (messageToStore.content) {
|
22515
|
+
messageToStore.content = this.encryptContent(messageToStore.content);
|
22506
22516
|
}
|
22507
|
-
|
22508
|
-
|
22509
|
-
|
22510
|
-
|
22517
|
+
if (messageToStore.quotedReply?.content) {
|
22518
|
+
messageToStore.quotedReply.content = this.encryptContent(messageToStore.quotedReply.content);
|
22519
|
+
}
|
22520
|
+
store.put(messageToStore);
|
22521
|
+
} catch (err) {
|
22522
|
+
logger$1.error('Error processing message:', message, err);
|
22523
|
+
}
|
22524
|
+
}
|
22525
|
+
} catch (err) {
|
22526
|
+
logger$1.error('Failed to start transaction:', err);
|
22527
|
+
if (isDef(isEnd)) {
|
22528
|
+
this.updateDialogState(dialogId, isEnd).catch(stateErr => logger$1.error('Failed to update dialog state:', stateErr)).finally(() => resolve());
|
22529
|
+
} else {
|
22511
22530
|
resolve();
|
22512
22531
|
}
|
22513
|
-
}
|
22532
|
+
}
|
22514
22533
|
});
|
22515
|
-
await Promise.allSettled(insertPromises);
|
22516
22534
|
}
|
22517
22535
|
async getPreviousMessages(conversation, timestamp = "0", count = 20) {
|
22518
22536
|
const dialogId = getFullDialogId(conversation);
|
@@ -23592,7 +23610,6 @@
|
|
23592
23610
|
};
|
23593
23611
|
try {
|
23594
23612
|
if (level === exports.LogLevel.ERROR) {
|
23595
|
-
debugger;
|
23596
23613
|
analyticsManager.trackEvent('error_log', {
|
23597
23614
|
timestamp: logEntry.timestamp,
|
23598
23615
|
content: logEntry.content
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@onyx-p/imlib-web",
|
3
|
-
"version": "2.
|
3
|
+
"version": "2.7.0",
|
4
4
|
"main": "index.umd.js",
|
5
5
|
"module": "index.esm.js",
|
6
6
|
"types": "types/index.d.ts",
|
@@ -13,12 +13,7 @@
|
|
13
13
|
"types/constants",
|
14
14
|
"README.md"
|
15
15
|
],
|
16
|
-
"keywords": [
|
17
|
-
"im"
|
18
|
-
],
|
16
|
+
"keywords": ["im"],
|
19
17
|
"author": "zimu",
|
20
|
-
"license": "MIT"
|
21
|
-
|
22
|
-
"@onyx-p/imlib-web": "^2.6.7"
|
23
|
-
}
|
24
|
-
}
|
18
|
+
"license": "MIT"
|
19
|
+
}
|