From 027bb76989ac3b808bd98910417e35ab1e9b82b5 Mon Sep 17 00:00:00 2001 From: Ryan Tharp Date: Tue, 3 Dec 2019 02:36:03 -0800 Subject: [PATCH] setPublicSource now marks convo active, make getPublicSendData use the lokiPublicChatAPI findOrCreateChannel, add some warnings --- js/models/conversations.js | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/js/models/conversations.js b/js/models/conversations.js index af7c85828..7572682b3 100644 --- a/js/models/conversations.js +++ b/js/models/conversations.js @@ -1,5 +1,6 @@ /* global _, + log, i18n, Backbone, ConversationController, @@ -2346,14 +2347,21 @@ // maybe "Backend" instead of "Source"? async setPublicSource(newServer, newChannelId) { if (!this.isPublic()) { + log.warn( + `trying to setPublicSource on non public chat conversation ${this.id}` + ); return; } if ( this.get('server') !== newServer || this.get('channelId') !== newChannelId ) { - this.set({ server: newServer }); - this.set({ channelId: newChannelId }); + // mark active so it's not in the friends list but the conversation list + this.set({ + server: newServer, + channelId: newChannelId, + active_at: Date.now(), + }); await window.Signal.Data.updateConversation(this.id, this.attributes, { Conversation: Whisper.Conversation, }); @@ -2361,6 +2369,9 @@ }, getPublicSource() { if (!this.isPublic()) { + log.warn( + `trying to getPublicSource on non public chat conversation ${this.id}` + ); return null; } return { @@ -2370,18 +2381,8 @@ }; }, async getPublicSendData() { - const serverAPI = await lokiPublicChatAPI.findOrCreateServer( - this.get('server') - ); - if (!serverAPI) { - window.log.warn( - `Failed to get serverAPI (${this.get('server')}) for conversation (${ - this.id - })` - ); - return null; - } - const channelAPI = await serverAPI.findOrCreateChannel( + const channelAPI = await lokiPublicChatAPI.findOrCreateChannel( + this.get('server'), this.get('channelId'), this.id );