Skip to content

Commit

Permalink
Removed ability to join games on library items
Browse files Browse the repository at this point in the history
  • Loading branch information
Zequez committed Dec 8, 2024
1 parent 4fb7788 commit 66130f9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
2 changes: 1 addition & 1 deletion ui/src/GameSpace/topbar/PeopleBar.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
}}>Leave Game</button
>
{/if}
<PlayersSlots {pubKey} {playersSlots} onChange={onChangePlayersSlots} />
<PlayersSlots {pubKey} {playersSlots} {canJoinGame} onChange={onChangePlayersSlots} />
<button
class={cx('relative h14 w14 flexcc b b-black/10 ', {
'bg-black/30 text-white': showingParticipants,
Expand Down
27 changes: 15 additions & 12 deletions ui/src/GameSpace/topbar/PlayersSlots.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
export let pubKey: string;
export let playersSlots: PlayerSlot[];
export let onChange: (playersSlots: PlayerSlot[]) => void;
export let canJoinGame: boolean;
function handleMove(from: number, to: number) {
if (from !== to) {
Expand Down Expand Up @@ -94,18 +95,20 @@
Player {slot + 1}
{/if}
</div>
{#if playerSlot.pubKey}
<button
on:click={() => handleRemovePlayer(slot)}
class="text-xs bg-main-400 w-full rounded-md line-height-tight py1 text-white b b-black/10 hover:bg-main-500"
>Remove<br />Player</button
>
{:else}
<button
on:click={() => handleJoinSlot(slot)}
class="text-xs bg-main-400 w-full rounded-md line-height-tight py1 text-white b b-black/10 hover:bg-main-500"
>Join Here</button
>
{#if canJoinGame}
{#if playerSlot.pubKey}
<button
on:click={() => handleRemovePlayer(slot)}
class="text-xs bg-main-400 w-full rounded-md line-height-tight py1 text-white b b-black/10 hover:bg-main-500"
>Remove<br />Player</button
>
{:else}
<button
on:click={() => handleJoinSlot(slot)}
class="text-xs bg-main-400 w-full rounded-md line-height-tight py1 text-white b b-black/10 hover:bg-main-500"
>Join Here</button
>
{/if}
{/if}
</div>
</div>
Expand Down
1 change: 1 addition & 0 deletions ui/src/store/gameSpaceStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export function createGameSpaceSynStore(synDoc: SynDoc) {
// elements.subscribe(processElements)

const canJoinGame = derived(state, ($state) => {
if ($state.isLibraryItem) return false;
const alreadyJoined = !!$state.playersSlots.find((s) => s.pubKey === pubKey);
if (alreadyJoined) return false;
const freeSlot = $state.playersSlots.findIndex((p) => p.pubKey === null);
Expand Down

0 comments on commit 66130f9

Please sign in to comment.