Remove refs to appWindow

We only need the regular window, not the AppWindow interface, which is
specific to chrome apps.
This commit is contained in:
lilia 2016-10-07 10:43:02 +09:00
parent 9da4cdefd7
commit 674eeb8313
3 changed files with 25 additions and 27 deletions

View file

@ -19,23 +19,21 @@
function render() { function render() {
extension.windows.getBackground(function(bg) { extension.windows.getBackground(function(bg) {
extension.windows.getCurrent(function(appWindow) { bg.ConversationController.updateInbox().then(function() {
bg.ConversationController.updateInbox().then(function() { try {
try { if (view) { view.remove(); }
if (view) { view.remove(); } var $body = bg.$('body',document).empty();
var $body = bg.$('body',document).empty(); view = new bg.Whisper.InboxView({window: window});
view = new bg.Whisper.InboxView({appWindow: appWindow}); view.$el.prependTo($body);
view.$el.prependTo($body); window.openConversation = function(conversation) {
window.openConversation = function(conversation) { if (conversation) {
if (conversation) { view.openConversation(null, conversation);
view.openConversation(null, conversation); }
} };
}; openConversation(bg.getOpenConversation());
openConversation(bg.getOpenConversation()); } catch (e) {
} catch (e) { logError(e);
logError(e); }
}
});
}); });
}); });
} }

View file

@ -87,15 +87,15 @@
emoji_util.parse(this.$('.conversation-name')); emoji_util.parse(this.$('.conversation-name'));
this.appWindow = options.appWindow; this.window = options.window;
this.fileInput = new Whisper.FileInputView({ this.fileInput = new Whisper.FileInputView({
el: this.$('form.send'), el: this.$('form.send'),
window: this.appWindow.contentWindow window: this.window
}); });
this.view = new Whisper.MessageListView({ this.view = new Whisper.MessageListView({
collection: this.model.messageCollection, collection: this.model.messageCollection,
window: this.appWindow.contentWindow window: this.window
}); });
this.$('.discussion-container').append(this.view.el); this.$('.discussion-container').append(this.view.el);
this.view.render(); this.view.render();
@ -103,18 +103,18 @@
this.$messageField = this.$('.send-message'); this.$messageField = this.$('.send-message');
var onResize = this.forceUpdateMessageFieldSize.bind(this); var onResize = this.forceUpdateMessageFieldSize.bind(this);
this.appWindow.contentWindow.addEventListener('resize', onResize); this.window.addEventListener('resize', onResize);
var onFocus = function() { var onFocus = function() {
if (this.$el.css('display') !== 'none') { if (this.$el.css('display') !== 'none') {
this.markRead(); this.markRead();
} }
}.bind(this); }.bind(this);
this.appWindow.contentWindow.addEventListener('focus', onFocus); this.window.addEventListener('focus', onFocus);
extension.windows.onClosed(function () { extension.windows.onClosed(function () {
this.appWindow.contentWindow.removeEventListener('resize', onResize); this.window.removeEventListener('resize', onResize);
this.appWindow.contentWindow.removeEventListener('focus', onFocus); this.window.removeEventListener('focus', onFocus);
window.autosize.destroy(this.$messageField); window.autosize.destroy(this.$messageField);
this.remove(); this.remove();
this.model.messageCollection.reset([]); this.model.messageCollection.reset([]);
@ -313,7 +313,7 @@
newGroupUpdate: function() { newGroupUpdate: function() {
this.newGroupUpdateView = new Whisper.NewGroupUpdateView({ this.newGroupUpdateView = new Whisper.NewGroupUpdateView({
model: this.model, model: this.model,
window: this.appWindow.contentWindow window: this.window
}); });
this.listenBack(this.newGroupUpdateView); this.listenBack(this.newGroupUpdateView);
}, },

View file

@ -49,7 +49,7 @@
if ($el === null || $el.length === 0) { if ($el === null || $el.length === 0) {
var view = new Whisper.ConversationView({ var view = new Whisper.ConversationView({
model: conversation, model: conversation,
appWindow: this.model.appWindow window: this.model.window
}); });
$el = view.$el; $el = view.$el;
} }
@ -107,7 +107,7 @@
new Whisper.FontSizeView({ el: this.$el }); new Whisper.FontSizeView({ el: this.$el });
this.conversation_stack = new Whisper.ConversationStack({ this.conversation_stack = new Whisper.ConversationStack({
el: this.$('.conversation-stack'), el: this.$('.conversation-stack'),
model: { appWindow: options.appWindow } model: { window: options.window }
}); });
var inboxCollection = getInboxCollection(); var inboxCollection = getInboxCollection();