Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hackathon: Kingdom royale #46

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
List rooms asynchronously
akrolsmir committed Dec 20, 2020

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 3ebacbbafe9f786e467f3b50778cdd89ebff2e74
31 changes: 18 additions & 13 deletions index.html
Original file line number Diff line number Diff line change
@@ -118,17 +118,19 @@
</template>

<br /><br />
<h2 class="fancy">Private Rooms</h2>
<p v-for="privateRoom in privateRooms">
<a @click="console.log('TODO')"><b>{{ "Private room" }} with {{ privateRoom.players[0] }}</b></a>
<span v-if="privateRoom.players.length > 1"> and {{ privateRoom.players.length }} others</span>
({{ moment(privateRoom.lastUpdateTime).fromNow() }})
</p>
<h2 class="fancy">Open Rooms</h2>
<p v-for="openRoom in allRooms">
<a @click="room.name = openRoom.name; enterRoom()"><b>{{ openRoom.name }}</b></a
>, with {{ openRoom.players.join(', ') }} ({{ moment(openRoom.lastUpdateTime).fromNow() }})
</p>
<div v-cloak>
<h2 class="fancy">Private Rooms</h2>
<p v-for="privateRoom in privateRooms">
<a @click="console.log('TODO')"><b>{{ "Private room" }} with {{ privateRoom.players[0] }}</b></a>
<span v-if="privateRoom.players.length > 1"> and {{ privateRoom.players.length }} others</span>
({{ moment(privateRoom.lastUpdateTime).fromNow() }})
</p>
<h2 class="fancy">Open Rooms</h2>
<p v-for="openRoom in allRooms">
<a @click="room.name = openRoom.name; enterRoom()"><b>{{ openRoom.name }}</b></a
>, with {{ openRoom.players.join(', ') }} ({{ moment(openRoom.lastUpdateTime).fromNow() }})
</p>
</div>
<br /><br /><br /><br /><br />
</div>
<!-- In game -->
@@ -496,8 +498,7 @@ <h2 v-if="room.history.length > 0" class="fancy">History</h2>
this.CATEGORY_ORDER = ['nouns', 'verbs', 'adjectives', 'compounds', 'custom'];
},
async mounted() {
this.allRooms = (await listRooms(20, true)).filter((room) => room.players.length > 0);
this.privateRooms = (await listRooms(5, false)).filter((room) => room.players.length > 0);
this.populateHome(); // Begin listing rooms, but don't wait for the result to mount
const parsedUrl = new URL(window.location.href);
const roomName = parsedUrl.searchParams.get('room');
const playerName = parsedUrl.searchParams.get('player');
@@ -541,6 +542,10 @@ <h2 v-if="room.history.length > 0" class="fancy">History</h2>
moment,
listRooms,
dedupe,
async populateHome() {
this.privateRooms = (await listRooms(5, false)).filter((room) => room.players.length > 0);
this.allRooms = (await listRooms(20, true)).filter((room) => room.players.length > 0);
},
async enterRoom() {
if (!this.player.name) {
this.$refs.navbar.logIn();