Added elaborate template switching.

This commit is contained in:
2024-08-26 06:15:22 +02:00
parent fa991c0294
commit 80d8a8109a
29 changed files with 617 additions and 180 deletions

View File

@@ -31,19 +31,19 @@
<StashDialog
v-if="showStashDialog"
@created="showStashDialog = false; reloadProfile();"
@created="showStashDialog = false; reloadStashes();"
@close="showStashDialog = false"
/>
<ul class="stashes nolist">
<li
v-for="stash in profile.stashes"
v-for="stash in stashes"
:key="`stash-${stash.id}`"
>
<StashTile
:stash="stash"
:profile="profile"
@reload="reloadProfile"
@reload="reloadStashes"
/>
</li>
</ul>
@@ -224,14 +224,16 @@ import AlertDialog from '#/components/alerts/create.vue';
const pageContext = inject('pageContext');
const user = pageContext.user;
const profile = ref(pageContext.pageProps.profile);
const stashes = ref(pageContext.pageProps.stashes);
const alerts = ref(pageContext.pageProps.alerts);
const done = ref(true);
const showStashDialog = ref(false);
const showAlertDialog = ref(false);
async function reloadProfile() {
profile.value = await get(`/users/${profile.value.id}`);
async function reloadStashes() {
// profile.value = await get(`/users/${profile.value.id}`);
stashes.value = await get(`/users/${profile.value.id}/stashes`);
}
async function reloadAlerts() {

View File

@@ -1,6 +1,7 @@
import { render } from 'vike/abort'; /* eslint-disable-line import/extensions */
import { fetchUser } from '#/src/users.js';
import { fetchUserStashes } from '#/src/stashes.js';
import { fetchAlerts } from '#/src/alerts.js';
export async function onBeforeRender(pageContext) {
@@ -15,11 +16,14 @@ export async function onBeforeRender(pageContext) {
throw render(404, `Cannot find user '${pageContext.routeParams.username}'.`);
}
const stashes = await fetchUserStashes(profile.id, pageContext.user);
return {
pageContext: {
title: profile.username,
pageProps: {
profile, // differentiate from authed 'user'
stashes,
alerts,
},
},