try potential optimisation of SSR in profiles

This commit is contained in:
Andrea Vos 2021-06-17 22:24:15 +02:00
parent b0ad6b8d0d
commit cdda7248a2
2 changed files with 18 additions and 13 deletions

View File

@ -1,5 +1,10 @@
<template> <template>
<div v-if="profile"> <div v-if="profile">
<ClientOnly>
<div slot="placeholder" class="my-5 text-center">
<Spinner size="5rem"/>
</div>
<div class="mb-3 d-flex justify-content-between flex-column flex-md-row"> <div class="mb-3 d-flex justify-content-between flex-column flex-md-row">
<h2 class="text-nowrap"> <h2 class="text-nowrap">
<Avatar :user="profile"/> <Avatar :user="profile"/>
@ -31,17 +36,15 @@
</div> </div>
</div> </div>
<client-only> <section v-if="$isGranted('users') && profile.bannedReason">
<section v-if="$isGranted('users') && profile.bannedReason"> <div class="alert alert-warning">
<div class="alert alert-warning"> <p class="h4">
<p class="h4"> <Icon v="ban"/>
<Icon v="ban"/> {{$t('ban.banned')}}
{{$t('ban.banned')}} </p>
</p> <p class="mb-0">{{profile.bannedReason}}</p>
<p class="mb-0">{{profile.bannedReason}}</p> </div>
</div> </section>
</section>
</client-only>
<section v-if="profile.age ||profile.description.trim().length"> <section v-if="profile.age ||profile.description.trim().length">
<p v-for="line in profile.description.split('\n')" class="mb-1"> <p v-for="line in profile.description.split('\n')" class="mb-1">
@ -140,6 +143,7 @@
<section> <section>
<Share/> <Share/>
</section> </section>
</ClientOnly>
</div> </div>
<div v-else-if="Object.keys(profiles).length"> <div v-else-if="Object.keys(profiles).length">
<h2 class="text-nowrap mb-3"> <h2 class="text-nowrap mb-3">

View File

@ -32,11 +32,12 @@ app.use(async function (req, res, next) {
req.isGranted = (area, locale = global.config.locale) => req.user && isGranted(req.user, locale, area); req.isGranted = (area, locale = global.config.locale) => req.user && isGranted(req.user, locale, area);
req.db = await dbConnection(); req.db = await dbConnection();
res.on('finish', async () => { res.on('finish', async () => {
await req.db.close(); try {
await req.db.close();
} catch {}
}); });
next(); next();
} catch (err) { } catch (err) {
console.log('aaa', err);
next(err); next(err);
} }
}); });