From 8ce21b13fe20937466658a1ba2b9485471821ebb Mon Sep 17 00:00:00 2001 From: sachaaaaa Date: Thu, 26 Sep 2019 16:37:57 +1000 Subject: [PATCH] Remove only private conversation during secondary registrations steps to keep public chats in db --- app/sql.js | 5 +++++ js/modules/data.js | 5 +++++ js/views/standalone_registration_view.js | 2 +- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/app/sql.js b/app/sql.js index 3d2fe1bae..71b00ab41 100644 --- a/app/sql.js +++ b/app/sql.js @@ -115,6 +115,7 @@ module.exports = { getAllPrivateConversations, getAllGroupsInvolvingId, removeAllConversations, + removeAllPrivateConversations, searchConversations, searchMessages, @@ -2657,6 +2658,10 @@ async function removeAllConversations() { await removeAllFromTable(CONVERSATIONS_TABLE); } +async function removeAllPrivateConversations() { + await db.run(`DELETE FROM ${CONVERSATIONS_TABLE} WHERE type = 'private'`); +} + async function getMessagesNeedingUpgrade(limit, { maxVersion }) { const rows = await db.all( `SELECT json FROM messages diff --git a/js/modules/data.js b/js/modules/data.js index c2dca9695..44cd5e1d6 100644 --- a/js/modules/data.js +++ b/js/modules/data.js @@ -188,6 +188,7 @@ module.exports = { removeAll, removeAllConfiguration, removeAllConversations, + removeAllPrivateConversations, removeOtherData, cleanupOrphanedAttachments, @@ -1203,6 +1204,10 @@ async function removeAllConversations() { await channels.removeAllConversations(); } +async function removeAllPrivateConversations() { + await channels.removeAllPrivateConversations(); +} + async function cleanupOrphanedAttachments() { await callChannel(CLEANUP_ORPHANED_ATTACHMENTS_KEY); } diff --git a/js/views/standalone_registration_view.js b/js/views/standalone_registration_view.js index 6cf43b501..6d2734a7a 100644 --- a/js/views/standalone_registration_view.js +++ b/js/views/standalone_registration_view.js @@ -145,7 +145,7 @@ }, async resetRegistration() { await window.Signal.Data.removeAllIdentityKeys(); - await window.Signal.Data.removeAllConversations(); + await window.Signal.Data.removeAllPrivateConversations(); Whisper.Registration.remove(); // Do not remove all items since they are only set // at startup.