Save incoming messages and pass to frontend asynchronously
After a message is saved asynchronsly, fire an event and pass the message attributes to frontend listeners via the chrome-runtime API. This behavior is similar to the 'storage' event fired by localStorage.
This commit is contained in:
parent
ced295a630
commit
470346c9c4
9 changed files with 110 additions and 85 deletions
20
test/test.js
20
test/test.js
|
@ -10957,3 +10957,23 @@ function hexToArrayBuffer(str) {
|
|||
array[i] = parseInt(str.substr(i*2, 2), 16);
|
||||
return ret;
|
||||
};
|
||||
|
||||
function deleteDatabase(done) {
|
||||
indexedDB.deleteDatabase('test').then(done);
|
||||
};
|
||||
|
||||
function clearDatabase(done) {
|
||||
var convos = new Whisper.ConversationCollection();
|
||||
return convos.fetch().then(function() {
|
||||
convos.destroyAll().then(function() {
|
||||
var messages = new Whisper.MessageCollection();
|
||||
return messages.fetch().then(function() {
|
||||
messages.destroyAll().then(function() {
|
||||
if (done) {
|
||||
done();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue