mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2025-12-24 12:19:41 +00:00
Consolidate window logic in panel controller
Previously the conversation window would query the background page for a model id and then fetch the conversation. Instead, we can fetch the conversation before opening the window, which simplifies the front end scripts and avoids creating multiple copies of the same model.
This commit is contained in:
@@ -19,28 +19,12 @@
|
||||
|
||||
window.Whisper = window.Whisper || {};
|
||||
|
||||
function loadConversation (id) {
|
||||
var conversation = new Whisper.Conversation({ id: id });
|
||||
conversation.fetch().then(function () {
|
||||
window.document.title = conversation.getTitle();
|
||||
new Whisper.ConversationView({
|
||||
model: conversation
|
||||
}).render().$el.prependTo($('body'));
|
||||
window.conversation = conversation;
|
||||
});
|
||||
};
|
||||
|
||||
var bg = extension.windows.getBackground();
|
||||
|
||||
extension.windows.getCurrent(function (windowInfo) {
|
||||
var windowId = windowInfo.id;
|
||||
|
||||
// close the panel if background.html is refreshed
|
||||
bg.addEventListener('beforeunload', function () {
|
||||
// TODO: reattach after reload instead of closing.
|
||||
extension.windows.remove(windowId);
|
||||
});
|
||||
|
||||
loadConversation(bg.Whisper.windowMap.modelIdFrom(windowId));
|
||||
var bg = extension.windows.getBackground();
|
||||
var conversation = bg.getConversationForWindow(windowInfo.id);
|
||||
window.document.title = conversation.getTitle();
|
||||
new Whisper.ConversationView({
|
||||
model: conversation
|
||||
}).render().$el.prependTo($('body'));
|
||||
});
|
||||
}());
|
||||
|
||||
Reference in New Issue
Block a user