setPublicSource now marks convo active, make getPublicSendData use the lokiPublicChatAPI findOrCreateChannel, add some warnings

pull/679/head
Ryan Tharp 5 years ago
parent ca0e1f995c
commit 027bb76989

@ -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
);

Loading…
Cancel
Save