Jelajahi Sumber

updateOrAdd: Re-sort conversations when necessary

Danilo Bargen 7 tahun lalu
induk
melakukan
384cd5d067
1 mengubah file dengan 7 tambahan dan 0 penghapusan
  1. 7 0
      src/threema/container.ts

+ 7 - 0
src/threema/container.ts

@@ -333,6 +333,13 @@ export class Conversations implements threema.Container.Conversations {
                 }
                 // Copy properties from new conversation to old conversation
                 Object.assign(this.conversations[i], conversation);
+
+                // If the position changed, re-sort.
+                if (this.conversations[i].position !== i) {
+                    const tmp = this.conversations.splice(i, 1)[0];
+                    this.conversations.splice(conversation.position, 0, tmp);
+                }
+
                 return previousConversation;
             }
         }