WIP
This commit is contained in:
parent
27dd9c0063
commit
cf426c24e5
2 changed files with 29 additions and 21 deletions
|
@ -257,16 +257,19 @@ define([
|
||||||
if (!$ticket.length) {
|
if (!$ticket.length) {
|
||||||
$ticket = APP.support.makeTicket($div, content, function () {
|
$ticket = APP.support.makeTicket($div, content, function () {
|
||||||
var error = false;
|
var error = false;
|
||||||
|
nThen(function (w) {
|
||||||
hashesById[id].forEach(function (d) {
|
hashesById[id].forEach(function (d) {
|
||||||
common.mailbox.dismiss(d, function (err) {
|
common.mailbox.dismiss(d, w(function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
error = true;
|
error = true;
|
||||||
console.error(err);
|
console.error(err);
|
||||||
}
|
}
|
||||||
|
}));
|
||||||
});
|
});
|
||||||
});
|
}).nThen(function () {
|
||||||
if (!error) { $ticket.remove(); }
|
if (!error) { $ticket.remove(); }
|
||||||
});
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
$ticket.append(APP.support.makeMessage(content, hash));
|
$ticket.append(APP.support.makeMessage(content, hash));
|
||||||
reorder();
|
reorder();
|
||||||
|
|
|
@ -134,13 +134,8 @@ proxy.mailboxes = {
|
||||||
// If the hash in in our history, get the index from the history:
|
// If the hash in in our history, get the index from the history:
|
||||||
// - if the index is 0, we can change our lastKnownHash
|
// - if the index is 0, we can change our lastKnownHash
|
||||||
// - otherwise, just push to view
|
// - otherwise, just push to view
|
||||||
var idx;
|
var idx = box.history.indexOf(hash);
|
||||||
if (box.history.some(function (el, i) {
|
if (idx !== -1) {
|
||||||
if (hash === el) {
|
|
||||||
idx = i;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
})) {
|
|
||||||
if (idx === 0) {
|
if (idx === 0) {
|
||||||
m.lastKnownHash = hash;
|
m.lastKnownHash = hash;
|
||||||
box.history.shift();
|
box.history.shift();
|
||||||
|
@ -153,15 +148,25 @@ proxy.mailboxes = {
|
||||||
// Check the "viewed" array to see if we're able to bump lastKnownhash more
|
// Check the "viewed" array to see if we're able to bump lastKnownhash more
|
||||||
var sliceIdx;
|
var sliceIdx;
|
||||||
var lastKnownHash;
|
var lastKnownHash;
|
||||||
|
var toForget = [];
|
||||||
box.history.some(function (hash, i) {
|
box.history.some(function (hash, i) {
|
||||||
|
// naming here is confusing... isViewed implies it's a boolean
|
||||||
|
// when in fact it's an index
|
||||||
var isViewed = m.viewed.indexOf(hash);
|
var isViewed = m.viewed.indexOf(hash);
|
||||||
if (isViewed !== -1) {
|
|
||||||
|
// iterate over your history until you hit an element you haven't viewed
|
||||||
|
if (isViewed === -1) { return true; }
|
||||||
|
// update the index that you'll use to slice off viewed parts of history
|
||||||
sliceIdx = i + 1;
|
sliceIdx = i + 1;
|
||||||
m.viewed.splice(isViewed, 1);
|
// keep track of which hashes you should remove from your 'viewed' array
|
||||||
|
toForget.push(hash);
|
||||||
|
// prevent fetching dismissed messages on (re)connect
|
||||||
lastKnownHash = hash;
|
lastKnownHash = hash;
|
||||||
return false;
|
});
|
||||||
}
|
|
||||||
return true;
|
// remove all elements in 'toForget' from the 'viewed' array in one step
|
||||||
|
m.viewed = m.viewed.filter(function (hash) {
|
||||||
|
return toForget.indexOf(hash) === -1;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (sliceIdx) {
|
if (sliceIdx) {
|
||||||
|
|
Loading…
Reference in a new issue