diff --git a/js/background.js b/js/background.js index 8950b48e1..9b27d064c 100644 --- a/js/background.js +++ b/js/background.js @@ -204,6 +204,31 @@ window.log.info('Storage fetch'); storage.fetch(); + const initSpecialConversations = async () => { + const rssFeedConversations = await window.Signal.Data.getAllRssFeedConversations( + { + ConversationCollection: Whisper.ConversationCollection, + } + ); + rssFeedConversations.forEach(conversation => { + window.feeds.push(new window.LokiRssAPI(conversation.getRssSettings())); + }); + const publicConversations = await window.Signal.Data.getAllPublicConversations( + { + ConversationCollection: Whisper.ConversationCollection, + } + ); + publicConversations.forEach(conversation => { + const settings = conversation.getPublicSource(); + const channel = window.lokiPublicChatAPI.findOrCreateChannel( + settings.server, + settings.channelId, + conversation.id + ); + channel.refreshModStatus(); + }); + } + const initAPIs = async () => { const ourKey = textsecure.storage.user.getNumber(); window.feeds = []; @@ -246,11 +271,6 @@ } first = false; - if (Whisper.Registration.isDone()) { - startLocalLokiServer(); - await initAPIs(); - } - const currentPoWDifficulty = storage.get('PoWDifficulty', null); if (!currentPoWDifficulty) { storage.put('PoWDifficulty', window.getDefaultPoWDifficulty()); @@ -583,8 +603,6 @@ Whisper.events.on('registration_done', async () => { window.log.info('handling registration event'); - startLocalLokiServer(); - // listeners Whisper.RotateSignedPreKeyListener.init(Whisper.events, newVersion); // window.Signal.RefreshSenderCertificate.initialize({ @@ -594,7 +612,6 @@ // logger: window.log, // }); - await initAPIs(); connect(true); }); @@ -868,6 +885,9 @@ Whisper.Notifications.disable(); // avoid notification flood until empty // initialize the socket and start listening for messages + startLocalLokiServer(); + await initAPIs(); + await initSpecialConversations(); messageReceiver = new textsecure.MessageReceiver( USERNAME, PASSWORD, diff --git a/js/conversation_controller.js b/js/conversation_controller.js index 3383e6e24..50b3aae33 100644 --- a/js/conversation_controller.js +++ b/js/conversation_controller.js @@ -247,17 +247,6 @@ conversation.resetPendingSend(), conversation.setFriendRequestExpiryTimeout(), ]); - if (conversation.isPublic()) { - const settings = conversation.getPublicSource(); - const channel = window.lokiPublicChatAPI.findOrCreateChannel( - settings.server, - settings.channelId, - conversation.id - ); - promises.push(channel.refreshModStatus()); - } else if (conversation.isRss()) { - window.feeds.push(new window.LokiRssAPI(conversation.getRssSettings())); - } }); await Promise.all(promises);