2019-11-16 17:24:03 +00:00
|
|
|
import socket from "../socket";
|
2022-06-19 00:25:21 +00:00
|
|
|
import {store} from "../store";
|
2017-05-18 20:08:54 +00:00
|
|
|
|
2020-03-21 20:55:36 +00:00
|
|
|
socket.on("sync_sort", function (data) {
|
2017-05-18 20:08:54 +00:00
|
|
|
const order = data.order;
|
|
|
|
|
2019-07-12 16:47:29 +00:00
|
|
|
switch (data.type) {
|
2019-07-17 09:33:59 +00:00
|
|
|
case "networks":
|
2022-06-19 00:25:21 +00:00
|
|
|
store.commit(
|
|
|
|
"sortNetworks",
|
|
|
|
(a, b) => (order as string[]).indexOf(a.uuid) - (order as string[]).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": {
|
2019-11-03 14:59:43 +00:00
|
|
|
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
|
|
|
|
2022-06-19 00:25:21 +00:00
|
|
|
network.channels.sort(
|
|
|
|
(a, b) => (order as number[]).indexOf(a.id) - (order as number[]).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
|
|
|
}
|
|
|
|
});
|