@bobfrankston/rmfmail 1.1.249 → 1.1.250

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -746,25 +746,32 @@ function getMessages2() {
746
746
  return messages;
747
747
  }
748
748
  function removeMessages(uids, currentlyFocused) {
749
- const removeSet = new Set(uids.map((u) => `${u.accountId}:${u.uid}`));
750
- const focusedKey = currentlyFocused ? `${currentlyFocused.accountId}:${currentlyFocused.uid}` : null;
751
- const focusedWasRemoved = focusedKey !== null && removeSet.has(focusedKey);
749
+ const fullSet = /* @__PURE__ */ new Set();
750
+ const looseSet = /* @__PURE__ */ new Set();
751
+ for (const u of uids) {
752
+ if (u.folderId != null)
753
+ fullSet.add(`${u.accountId}:${u.folderId}:${u.uid}`);
754
+ else
755
+ looseSet.add(`${u.accountId}:${u.uid}`);
756
+ }
757
+ const isRemoved = (m) => m.folderId != null && fullSet.has(`${m.accountId}:${m.folderId}:${m.uid}`) || looseSet.has(`${m.accountId}:${m.uid}`);
758
+ const focusedWasRemoved = currentlyFocused !== null && isRemoved(currentlyFocused);
752
759
  let nextSurvivor = null;
753
760
  if (focusedWasRemoved) {
754
761
  let lastRemovedIdx = -1;
755
762
  for (let i = 0; i < messages.length; i++) {
756
- if (removeSet.has(`${messages[i].accountId}:${messages[i].uid}`))
763
+ if (isRemoved(messages[i]))
757
764
  lastRemovedIdx = i;
758
765
  }
759
766
  for (let i = lastRemovedIdx + 1; i < messages.length; i++) {
760
- if (!removeSet.has(`${messages[i].accountId}:${messages[i].uid}`)) {
767
+ if (!isRemoved(messages[i])) {
761
768
  nextSurvivor = messages[i];
762
769
  break;
763
770
  }
764
771
  }
765
772
  if (!nextSurvivor) {
766
773
  for (let i = lastRemovedIdx - 1; i >= 0; i--) {
767
- if (!removeSet.has(`${messages[i].accountId}:${messages[i].uid}`)) {
774
+ if (!isRemoved(messages[i])) {
768
775
  nextSurvivor = messages[i];
769
776
  break;
770
777
  }
@@ -773,11 +780,11 @@ function removeMessages(uids, currentlyFocused) {
773
780
  }
774
781
  const removedIds = /* @__PURE__ */ new Set();
775
782
  for (const m of messages) {
776
- if (removeSet.has(`${m.accountId}:${m.uid}`) && m.messageId) {
783
+ if (isRemoved(m) && m.messageId) {
777
784
  removedIds.add(m.messageId);
778
785
  }
779
786
  }
780
- messages = messages.filter((m) => !removeSet.has(`${m.accountId}:${m.uid}`));
787
+ messages = messages.filter((m) => !isRemoved(m));
781
788
  if (removedIds.size > 0) {
782
789
  for (const m of messages) {
783
790
  if (m.messageId && removedIds.has(m.messageId) && typeof m.dupeCount === "number") {
@@ -3161,18 +3168,18 @@ function updateSortIndicators() {
3161
3168
  });
3162
3169
  }
3163
3170
  function removeMessagesAndReconcile(uids) {
3164
- const focusedIdent = focusedRow ? { accountId: focusedRow.accountId, uid: focusedRow.msg.uid } : null;
3171
+ const focusedIdent = focusedRow ? { accountId: focusedRow.accountId, uid: focusedRow.msg.uid, folderId: focusedRow.msg.folderId } : null;
3165
3172
  const outcome = removeMessages(uids, focusedIdent);
3166
3173
  listCache.clear();
3167
3174
  const body = document.getElementById("ml-body");
3168
3175
  if (body) {
3169
- const stateUids = new Set(getMessages2().map((m) => `${m.accountId}:${m.uid}`));
3176
+ const stateUids = new Set(getMessages2().map((m) => `${m.accountId}:${m.folderId}:${m.uid}`));
3170
3177
  for (const row of Array.from(body.querySelectorAll(".ml-row"))) {
3171
3178
  const el = row;
3172
- const key = `${el.dataset.accountId}:${el.dataset.uid}`;
3179
+ const key = `${el.dataset.accountId}:${el.dataset.folderId}:${el.dataset.uid}`;
3173
3180
  if (!stateUids.has(key)) {
3174
- const dead = rowByKey.get(key);
3175
- if (dead)
3181
+ const dead = rowByKey.get(rowKey(el.dataset.accountId || "", Number(el.dataset.uid)));
3182
+ if (dead && dead.el === el)
3176
3183
  dead.detach();
3177
3184
  else
3178
3185
  el.remove();