thelounge/client/js/socket-events/sync_sort.js

28 lines
508 B
JavaScript
Raw Normal View History

2017-05-18 20:08:54 +00:00
"use strict";
2019-11-16 17:24:03 +00:00
import socket from "../socket";
import store from "../store";
2017-05-18 20:08:54 +00:00
socket.on("sync_sort", function(data) {
const order = data.order;
switch (data.type) {
2019-07-17 09:33:59 +00:00
case "networks":
store.commit("sortNetworks", (a, b) => order.indexOf(a.uuid) - order.indexOf(b.uuid));
2017-05-18 20:08:54 +00:00
2019-07-17 09:33:59 +00:00
break;
2017-05-18 20:08:54 +00:00
2019-07-17 09:33:59 +00:00
case "channels": {
const network = store.getters.findNetwork(data.target);
2017-05-18 20:08:54 +00:00
2019-07-17 09:33:59 +00:00
if (!network) {
return;
}
2017-05-18 20:08:54 +00:00
2019-07-17 09:33:59 +00:00
network.channels.sort((a, b) => order.indexOf(a.id) - order.indexOf(b.id));
2017-05-18 20:08:54 +00:00
2019-07-17 09:33:59 +00:00
break;
}
2017-05-18 20:08:54 +00:00
}
});