mirror of
https://github.com/DJ2LS/FreeDATA
synced 2024-05-14 08:04:33 +00:00
Fix message sorting
This commit is contained in:
parent
c55595484b
commit
aa8abf021e
2 changed files with 19 additions and 4 deletions
|
@ -21,7 +21,7 @@ import chat_new_message from "./chat_new_message.vue";
|
|||
|
||||
import { updateAllChat, newMessage } from "../js/chatHandler";
|
||||
|
||||
updateAllChat();
|
||||
//updateAllChat();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
|
|
@ -232,13 +232,25 @@ function sortChatList() {
|
|||
reorderedData[dxcallsign] = [];
|
||||
}
|
||||
reorderedData[dxcallsign].push(obj);
|
||||
|
||||
reorderedData[dxcallsign] = reorderedData[dxcallsign].sort(sortByProperty("timestamp"));
|
||||
}
|
||||
});
|
||||
//console.log(reorderedData["DJ2LS-0"])
|
||||
//console.log(reorderedData["2LS-0"])
|
||||
return reorderedData;
|
||||
}
|
||||
|
||||
//https://medium.com/@asadise/sorting-a-json-array-according-one-property-in-javascript-18b1d22cd9e9
|
||||
function sortByProperty(property){
|
||||
return function(a,b){
|
||||
if(a[property] > b[property])
|
||||
return 1;
|
||||
else if(a[property] < b[property])
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export function getMessageAttachment(id) {
|
||||
|
@ -516,10 +528,13 @@ export async function updateAllChat(cleanup) {
|
|||
} else {
|
||||
|
||||
chat.unsorted_chat_list.push(item);
|
||||
}
|
||||
chat.sorted_chat_list = sortChatList();
|
||||
|
||||
}
|
||||
|
||||
chat.sorted_chat_list = sortChatList();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
if (typeof result !== "undefined") {
|
||||
|
|
Loading…
Reference in a new issue