move main application view over to messageReceiver namespace
The goal here is to allow synchronous property lookup between objects and mvc/backbone semantics. // FREEBIE
This commit is contained in:
parent
ef4b4da2a3
commit
e4a21d1a53
3 changed files with 45 additions and 18 deletions
|
@ -11,7 +11,7 @@
|
||||||
<link href="/stylesheets/manifest.css" rel="stylesheet" type="text/css" />
|
<link href="/stylesheets/manifest.css" rel="stylesheet" type="text/css" />
|
||||||
<script type="text/javascript" src="js/chromium.js"></script>
|
<script type="text/javascript" src="js/chromium.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body class='signal index'>
|
<body id="signal-container" class='signal index'>
|
||||||
<script type="text/javascript" src="js/index.js"></script>
|
<script type="text/javascript" src="js/index.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -120,6 +120,9 @@
|
||||||
window.textsecure.messaging = new textsecure.MessageSender(
|
window.textsecure.messaging = new textsecure.MessageSender(
|
||||||
SERVER_URL, SERVER_PORTS, USERNAME, PASSWORD
|
SERVER_URL, SERVER_PORTS, USERNAME, PASSWORD
|
||||||
);
|
);
|
||||||
|
|
||||||
|
deferredInit.resolve(owsDesktopApp);
|
||||||
|
|
||||||
if (firstRun === true && textsecure.storage.user.getDeviceId() != '1') {
|
if (firstRun === true && textsecure.storage.user.getDeviceId() != '1') {
|
||||||
if (!storage.get('theme-setting') && textsecure.storage.get('userAgent') === 'OWI') {
|
if (!storage.get('theme-setting') && textsecure.storage.get('userAgent') === 'OWI') {
|
||||||
storage.put('theme-setting', 'ios');
|
storage.put('theme-setting', 'ios');
|
||||||
|
@ -293,4 +296,38 @@
|
||||||
timestamp: timestamp, source: pushMessage.source
|
timestamp: timestamp, source: pushMessage.source
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var App = Backbone.Model.extend({
|
||||||
|
initialize: function(opts) {
|
||||||
|
this.inboxView = null;
|
||||||
|
},
|
||||||
|
getAppView: function(destWindow) {
|
||||||
|
|
||||||
|
var self = this;
|
||||||
|
|
||||||
|
return ConversationController.updateInbox().then(function() {
|
||||||
|
try {
|
||||||
|
if (self.inboxView) { self.inboxView.remove(); }
|
||||||
|
self.inboxView = new Whisper.InboxView({model: self, window: destWindow});
|
||||||
|
destWindow.openConversation = function(conversation) {
|
||||||
|
if (conversation) {
|
||||||
|
self.inboxView.openConversation(null, conversation);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
destWindow.openConversation(getOpenConversation());
|
||||||
|
|
||||||
|
return self.inboxView;
|
||||||
|
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
window.owsDesktopApp = new App();
|
||||||
|
|
||||||
|
var deferredInit = $.Deferred();
|
||||||
|
window.initLoading = deferredInit.promise();
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|
24
js/index.js
24
js/index.js
|
@ -15,25 +15,15 @@
|
||||||
logError(error);
|
logError(error);
|
||||||
};
|
};
|
||||||
|
|
||||||
var view;
|
|
||||||
|
|
||||||
function render() {
|
function render() {
|
||||||
extension.windows.getBackground(function(bg) {
|
extension.windows.getBackground(function(bg) {
|
||||||
bg.ConversationController.updateInbox().then(function() {
|
|
||||||
try {
|
var inboxPromise = bg.initLoading.done(function(owsDesktopApp) {
|
||||||
if (view) { view.remove(); }
|
owsDesktopApp.getAppView(window).then(function(appView) {
|
||||||
var $body = bg.$('body',document).empty();
|
var bodyEl = document.getElementById('signal-container');
|
||||||
view = new bg.Whisper.InboxView({window: window});
|
bodyEl.innerHTML = "";
|
||||||
view.$el.prependTo($body);
|
bodyEl.append(appView.el);
|
||||||
window.openConversation = function(conversation) {
|
});
|
||||||
if (conversation) {
|
|
||||||
view.openConversation(null, conversation);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
openConversation(bg.getOpenConversation());
|
|
||||||
} catch (e) {
|
|
||||||
logError(e);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue