fix selected server

This commit is contained in:
Anton Bracke 2022-02-22 17:56:57 +01:00
parent 4e243151dd
commit 732acb25df
No known key found for this signature in database
GPG Key ID: B1222603899C6B25
2 changed files with 5 additions and 3 deletions

View File

@ -10,7 +10,7 @@
const Settings = () => import("~/views/Settings.svelte");
const Server = () => import("~/views/Server.svelte");
let insideElectron = api.desktop;
let insideElectron = api?.desktop;
</script>
{#if insideElectron}

View File

@ -25,6 +25,8 @@
console.log("selected server changed", e);
});
$: serverWithSelection = $servers.map((s) => ({ ...s, isSelected: $selectedServer === s._id }))
onMount(async () => {
await loadServers();
isDevelopment = await api.isDevelopment();
@ -33,11 +35,11 @@
<aside class="flex flex-col bg-gray-700 items-center">
<div class="flex flex-col mt-4 space-y-4 overflow-y-auto pb-4">
{#each $servers as server, i}
{#each serverWithSelection as server, i}
<Link to="/server/{server._id}" class="flex flex-col items-center justify-center ">
<div
class={`w-16 h-16 p-1 rounded-md flex cursor-pointer text-light-50 border-4 border-transparent text-gray-200 hover:text-gray-500`}
class:border-gray-400={$selectedServer === server._id}
class:bg-gray-400={server.isSelected}
>
<div class={`flex w-full h-full text-center items-center justify-center rounded-md ${getServerColor(i)}`}>
{server.name.slice(0,2).toLocaleUpperCase()}