Fix race condition and remove redundant computed properties.

This commit is contained in:
Richard Lewis 2020-02-10 17:43:39 +02:00
parent 054760d49f
commit 9e76fe2a76
2 changed files with 16 additions and 12 deletions

View File

@ -67,6 +67,10 @@ export default {
return this.channel.name; return this.channel.name;
}, },
click() { click() {
if (this.isFiltering) {
return;
}
this.$root.switchToChannel(this.channel); this.$root.switchToChannel(this.channel);
}, },
openContextMenu(event) { openContextMenu(event) {

View File

@ -1,5 +1,5 @@
<template> <template>
<div v-if="networks.length === 0" class="empty"> <div v-if="$store.state.networks.length === 0" class="empty">
You are not connected to any networks yet. You are not connected to any networks yet.
</div> </div>
<div v-else ref="networklist"> <div v-else ref="networklist">
@ -52,7 +52,7 @@
</div> </div>
<Draggable <Draggable
v-else v-else
:list="networks" :list="$store.state.networks"
:filter="isCurrentlyInTouch" :filter="isCurrentlyInTouch"
:prevent-on-filter="false" :prevent-on-filter="false"
handle=".channel-list-item[data-type='lobby']" handle=".channel-list-item[data-type='lobby']"
@ -66,7 +66,7 @@
@end="onDragEnd" @end="onDragEnd"
> >
<div <div
v-for="network in networks" v-for="network in $store.state.networks"
:id="'network-' + network.uuid" :id="'network-' + network.uuid"
:key="network.uuid" :key="network.uuid"
:class="{ :class="{
@ -80,7 +80,10 @@
<NetworkLobby <NetworkLobby
:network="network" :network="network"
:is-join-channel-shown="network.isJoinChannelShown" :is-join-channel-shown="network.isJoinChannelShown"
:active="activeChannel && network.channels[0] === activeChannel.channel" :active="
$store.state.activeChannel &&
network.channels[0] === $store.state.activeChannel.channel
"
@toggleJoinChannel="network.isJoinChannelShown = !network.isJoinChannelShown" @toggleJoinChannel="network.isJoinChannelShown = !network.isJoinChannelShown"
/> />
<JoinChannel <JoinChannel
@ -109,7 +112,10 @@
:key="channel.id" :key="channel.id"
:channel="channel" :channel="channel"
:network="network" :network="network"
:active="activeChannel && channel === activeChannel.channel" :active="
$store.state.activeChannel &&
channel === $store.state.activeChannel.channel
"
/> />
</Draggable> </Draggable>
</div> </div>
@ -203,12 +209,6 @@ export default {
}; };
}, },
computed: { computed: {
activeChannel() {
return this.$store.state.activeChannel;
},
networks() {
return this.$store.state.networks;
},
items() { items() {
const items = []; const items = [];
@ -278,7 +278,7 @@ export default {
socket.emit("sort", { socket.emit("sort", {
type: "networks", type: "networks",
order: this.networks.map((n) => n.uuid), order: this.$store.state.networks.map((n) => n.uuid),
}); });
}, },
onChannelSort(e) { onChannelSort(e) {