<script>
    import { activeChannel } from '../store';

    export let id;
    export let name;
    let active = false;

    activeChannel.subscribe((value) => {
        active = value ? value.id == id : false;
    });

    function activate() {
        activeChannel.update(() => ({ id, name }));
    }
</script>

<li
    class="cursor-pointer hover:bg-slate-300"
    class:bg-slate-400={active}
    on:click={activate}
>
    #{name}
</li>
