Explorar el Código

updateOrAdd: Re-sort conversations when necessary

Danilo Bargen hace 7 años
padre
commit
384cd5d067
Se han modificado 1 ficheros con 7 adiciones y 0 borrados
  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;
             }
         }