Skip to content

Commit

Permalink
Fix loading error when there are no matches
Browse files Browse the repository at this point in the history
  • Loading branch information
toblu96 committed Oct 29, 2023
1 parent 2529c0a commit 5c4ad53
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions frontend/pages/index.vue
Expand Up @@ -88,13 +88,6 @@
</div>
</div>
</div>

<!-- Show all user details in a list -->
<!-- <ul>
<li v-for="user in users" :key="user.id">
{{ user.name }} : {{ user.preferences }}
</li>
</ul> -->
</template>

<script setup lang="ts">
Expand Down Expand Up @@ -132,20 +125,28 @@ const docsSnap = await getDocs(
);
// Get the latest match
let matchedUserId = undefined
let matchedUser = {}
let matchedUserFs = undefined
const lastDoc = docsSnap.docs[docsSnap.docs.length - 1];
const participants = lastDoc.data().participants;
let matchedUser = participants[0];
if (matchedUser.id === userId) {
matchedUser = participants[1];
}
if (lastDoc) {
console.log("MATCHED USER", matchedUser);
const participants = lastDoc.data().participants;
matchedUser = participants[0];
if (matchedUser.id === userId) {
matchedUser = participants[1];
}
matchedUserId = matchedUser.id
matchedUserFs = useDocument<User>(
doc(collection(firestore, "users"), matchedUserId)
);
const body = computed(() => `Hi, ${matchedUser?.name} %0D%0A%0D%0A How about grabbing a coffee sometime this week%3F %0D%0A%0D%0A Best, %0D%0A ${username}`)
}
const matchedUserFs = useDocument<User>(
doc(collection(firestore, "users"), matchedUser.id)
);
const body = computed(() => `Hi, ${matchedUser.name} %0D%0A%0D%0A How about grabbing a coffee sometime this week%3F %0D%0A%0D%0A Best, %0D%0A ${username}`)
</script>

0 comments on commit 5c4ad53

Please sign in to comment.