Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The sort event bundled networks and channels for no reason at all. They share none of the actual logic, so combining them just makes the typing poor but serves no benefit.
- Loading branch information
Showing
4 changed files
with
69 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,16 @@ | ||
import socket from "../socket"; | ||
import {store} from "../store"; | ||
|
||
socket.on("sync_sort", function (data) { | ||
const order = data.order; | ||
|
||
switch (data.type) { | ||
case "networks": | ||
store.commit( | ||
"sortNetworks", | ||
(a, b) => (order as string[]).indexOf(a.uuid) - (order as string[]).indexOf(b.uuid) | ||
); | ||
|
||
break; | ||
|
||
case "channels": { | ||
const network = store.getters.findNetwork(data.target); | ||
|
||
if (!network) { | ||
return; | ||
} | ||
socket.on("sync_sort:networks", function (data) { | ||
store.commit("sortNetworks", (a, b) => data.order.indexOf(a.uuid) - data.order.indexOf(b.uuid)); | ||
}); | ||
|
||
network.channels.sort( | ||
(a, b) => (order as number[]).indexOf(a.id) - (order as number[]).indexOf(b.id) | ||
); | ||
socket.on("sync_sort:channels", function (data) { | ||
const network = store.getters.findNetwork(data.network); | ||
|
||
break; | ||
} | ||
if (!network) { | ||
return; | ||
} | ||
|
||
network.channels.sort((a, b) => data.order.indexOf(a.id) - data.order.indexOf(b.id)); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters