mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2025-12-24 20:26:24 +00:00
Better handle large numbers of messages in cache on startup
This commit is contained in:
11
app/sql.js
11
app/sql.js
@@ -42,6 +42,7 @@ module.exports = {
|
||||
getNextExpiringMessage,
|
||||
getMessagesByConversation,
|
||||
|
||||
getUnprocessedCount,
|
||||
getAllUnprocessed,
|
||||
saveUnprocessed,
|
||||
getUnprocessedById,
|
||||
@@ -962,6 +963,16 @@ async function getUnprocessedById(id) {
|
||||
return jsonToObject(row.json);
|
||||
}
|
||||
|
||||
async function getUnprocessedCount() {
|
||||
const row = await db.get('SELECT count(*) from unprocessed;');
|
||||
|
||||
if (!row) {
|
||||
throw new Error('getMessageCount: Unable to get count of unprocessed');
|
||||
}
|
||||
|
||||
return row['count(*)'];
|
||||
}
|
||||
|
||||
async function getAllUnprocessed() {
|
||||
const rows = await db.all(
|
||||
'SELECT json FROM unprocessed ORDER BY timestamp ASC;'
|
||||
|
||||
Reference in New Issue
Block a user