2017-05-18 20:08:54 +00:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
const socket = require("../socket");
|
2019-07-12 16:47:29 +00:00
|
|
|
const {vueApp} = require("../vue");
|
2017-05-18 20:08:54 +00:00
|
|
|
|
|
|
|
socket.on("sync_sort", function(data) {
|
|
|
|
const order = data.order;
|
|
|
|
|
2019-07-12 16:47:29 +00:00
|
|
|
switch (data.type) {
|
|
|
|
case "networks":
|
|
|
|
vueApp.networks.sort((a, b) => order.indexOf(a.uuid) - order.indexOf(b.uuid));
|
2017-05-18 20:08:54 +00:00
|
|
|
|
2019-07-12 16:47:29 +00:00
|
|
|
break;
|
2017-05-18 20:08:54 +00:00
|
|
|
|
2019-07-12 16:47:29 +00:00
|
|
|
case "channels": {
|
|
|
|
const network = vueApp.networks.find((n) => n.uuid === data.target);
|
2017-05-18 20:08:54 +00:00
|
|
|
|
2019-07-12 16:47:29 +00:00
|
|
|
if (!network) {
|
|
|
|
return;
|
|
|
|
}
|
2017-05-18 20:08:54 +00:00
|
|
|
|
2019-07-12 16:47:29 +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-12 16:47:29 +00:00
|
|
|
break;
|
|
|
|
}
|
2017-05-18 20:08:54 +00:00
|
|
|
}
|
|
|
|
});
|