Use two way binding in server list

This commit is contained in:
James Lyne 2021-05-28 00:13:11 +01:00
parent e3f64e720c
commit 97111f3bbc

View File

@ -15,8 +15,7 @@
--> -->
<template> <template>
<input :id="`server-${server.id}`" type="radio" name="server" :value="server.id" v-model="currentServer" <input :id="`server-${server.id}`" type="radio" name="server" v-bind:value="server" v-model="currentServer">
@click="setCurrentServer(server.id)">
<label :for="`server-${server.id}`">{{ server.label || server.id }}</label> <label :for="`server-${server.id}`">{{ server.label || server.id }}</label>
</template> </template>
@ -36,15 +35,14 @@ export default defineComponent({
}, },
computed: { computed: {
currentServer(): string | undefined { currentServer: {
return useStore().state.currentServer ? useStore().state.currentServer.id : undefined; get() {
return useStore().state.currentServer;
},
set(value) {
useStore().commit(MutationTypes.SET_CURRENT_SERVER, value.id);
}
} }
}, },
methods: {
setCurrentServer(serverId: string) {
useStore().commit(MutationTypes.SET_CURRENT_SERVER, serverId);
}
}
}); });
</script> </script>