Get conversations loading through localStorage
This commit is contained in:
parent
2cbcb28ee3
commit
7ec27f814f
3 changed files with 28 additions and 21 deletions
|
@ -222,4 +222,7 @@
|
||||||
console.log('got delivery receipt for unknown message', pushMessage.source, timestamp);
|
console.log('got delivery receipt for unknown message', pushMessage.source, timestamp);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
extension.on('log', console.log.bind(console));
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|
|
@ -24,31 +24,33 @@
|
||||||
conversation.fetch().then(function () {
|
conversation.fetch().then(function () {
|
||||||
new Whisper.ConversationView({ model: conversation}).render().$el.appendTo($('#conversation-container'));
|
new Whisper.ConversationView({ model: conversation}).render().$el.appendTo($('#conversation-container'));
|
||||||
});
|
});
|
||||||
|
|
||||||
// clean 'er up
|
|
||||||
conversationInfo = undefined;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var conversationInfo = {
|
var windowId, windowMap = {};
|
||||||
id: '',
|
|
||||||
idPairs: {}
|
|
||||||
};
|
|
||||||
|
|
||||||
extension.on('loadConversation', function (message) {
|
extension.trigger('log', 'loaded page');
|
||||||
debugger;
|
|
||||||
if (conversationInfo.id) {
|
window.addEventListener('storage', function (e) {
|
||||||
if (message.windowId === conversationInfo.id) {
|
extension.trigger('log', 'got storage event');
|
||||||
loadConversation(message.conversationId);
|
if (e.key = 'idPairs') {
|
||||||
|
windowMap = JSON.parse(e.newValue);
|
||||||
|
|
||||||
|
if (windowId) {
|
||||||
|
var conversationId = windowMap[windowId];
|
||||||
|
|
||||||
|
if (conversationId) {
|
||||||
|
loadConversation(conversationId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
conversationInfo.idPairs[message.windowId] = message.conversationId;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
chrome.windows.getCurrent(function (windowInfo) {
|
chrome.windows.getCurrent(function (windowInfo) {
|
||||||
window.document.title = conversationInfo.id = windowInfo.id;
|
window.document.title = windowId = windowInfo.id;
|
||||||
|
|
||||||
var conversationId = conversationInfo.idPairs[conversationInfo.id];
|
extension.trigger('log', 'got page id');
|
||||||
|
|
||||||
|
var conversationId = windowMap[windowId];
|
||||||
|
|
||||||
if (typeof conversationId !== 'undefined') {
|
if (typeof conversationId !== 'undefined') {
|
||||||
loadConversation(conversationId);
|
loadConversation(conversationId);
|
||||||
|
|
|
@ -52,11 +52,13 @@ var Whisper = Whisper || {};
|
||||||
width: 280,
|
width: 280,
|
||||||
height: 420
|
height: 420
|
||||||
}, function (windowInfo) {
|
}, function (windowInfo) {
|
||||||
debugger;
|
extension.trigger('log', 'maybe up here?');
|
||||||
extension.trigger('loadConversation', {
|
extension.trigger('log', localStorage.getItem('idPairs'));
|
||||||
windowId: windowInfo.id,
|
|
||||||
conversationId: modelId
|
var idPairs = JSON.parse(localStorage.getItem('idPairs') || '{}');
|
||||||
});
|
idPairs[windowInfo.id] = modelId;
|
||||||
|
localStorage.setItem('idPairs', JSON.stringify(idPairs));
|
||||||
|
extension.trigger('log', 'set idPairs item');
|
||||||
});
|
});
|
||||||
|
|
||||||
this.model.collection.trigger('selected', this.view);
|
this.model.collection.trigger('selected', this.view);
|
||||||
|
|
Loading…
Reference in a new issue