Cached some model properties and remove useless eager loading (#253)

* Cached some model properties and remove useless eager loading

* Remove ray call

* Remove double loading of forms

* Add disableCache feature when needed
This commit is contained in:
Julien Nahum
2023-12-02 14:51:08 +01:00
committed by GitHub
parent 8fd85776c6
commit a18077934c
10 changed files with 291 additions and 95 deletions

View File

@@ -10,34 +10,37 @@
>
{{ appName }}</span>
</router-link>
<workspace-dropdown class="ml-6"/>
<workspace-dropdown class="ml-6" />
</div>
<div v-if="showAuth" class="hidden md:block ml-auto relative">
<router-link :to="{name:'templates'}" v-if="$route.name !== 'templates'"
class="text-sm text-gray-600 dark:text-white hover:text-gray-800 cursor-pointer mt-1 mr-8">
<router-link v-if="$route.name !== 'templates'" :to="{name:'templates'}"
class="text-sm text-gray-600 dark:text-white hover:text-gray-800 cursor-pointer mt-1 mr-8"
>
Templates
</router-link>
<router-link :to="{name:'aiformbuilder'}" v-if="$route.name !== 'aiformbuilder'"
class="text-sm text-gray-600 dark:text-white hidden lg:inline hover:text-gray-800 cursor-pointer mt-1 mr-8">
<router-link v-if="$route.name !== 'aiformbuilder'" :to="{name:'aiformbuilder'}"
class="text-sm text-gray-600 dark:text-white hidden lg:inline hover:text-gray-800 cursor-pointer mt-1 mr-8"
>
AI Form Builder
</router-link>
<router-link :to="{name:'pricing'}" v-if="paidPlansEnabled && (user===null || (user && workspace && !workspace.is_pro)) && $route.name !== 'pricing'"
class="text-sm text-gray-600 dark:text-white hover:text-gray-800 cursor-pointer mt-1 mr-8">
<router-link v-if="paidPlansEnabled && (user===null || (user && workspace && !workspace.is_pro)) && $route.name !== 'pricing'" :to="{name:'pricing'}"
class="text-sm text-gray-600 dark:text-white hover:text-gray-800 cursor-pointer mt-1 mr-8"
>
<span v-if="user">Upgrade</span>
<span v-else>Pricing</span>
</router-link>
<a href="#" class="text-sm text-gray-600 dark:text-white hover:text-gray-800 cursor-pointer mt-1"
@click.prevent="openCrisp" v-if="hasCrisp"
<a v-if="hasCrisp" href="#"
class="text-sm text-gray-600 dark:text-white hover:text-gray-800 cursor-pointer mt-1" @click.prevent="openCrisp"
>
Help
</a>
<a :href="helpUrl" class="text-sm text-gray-600 dark:text-white hover:text-gray-800 cursor-pointer mt-1"
target="_blank" v-else
<a v-else :href="helpUrl"
class="text-sm text-gray-600 dark:text-white hover:text-gray-800 cursor-pointer mt-1" target="_blank"
>
Help
</a>
</div>
<div v-if="showAuth" class="hidden md:block pl-5 border-gray-300 border-r h-5"></div>
<div v-if="showAuth" class="hidden md:block pl-5 border-gray-300 border-r h-5" />
<div v-if="showAuth" class="block">
<div class="flex items-center">
<div class="ml-3 mr-4 relative">
@@ -107,7 +110,7 @@
{{ $t('logout') }}
</a>
</dropdown>
<div class="flex gap-2" v-else>
<div v-else class="flex gap-2">
<router-link v-if="$route.name !== 'login'" :to="{ name: 'login' }"
class="text-gray-600 dark:text-white hover:text-gray-800 dark:hover:text-white px-0 sm:px-3 py-2 rounded-md text-sm"
active-class="text-gray-800 dark:text-white"
@@ -115,10 +118,9 @@
{{ $t('login') }}
</router-link>
<v-button size="small" :to="{ name: 'forms.create.guest' }" color="outline-blue" v-track.nav_create_form_click :arrow="true">
<v-button v-track.nav_create_form_click size="small" :to="{ name: 'forms.create.guest' }" color="outline-blue" :arrow="true">
Create a form
</v-button>
</div>
</div>
</div>
@@ -130,7 +132,7 @@
</template>
<script>
import {mapGetters} from 'vuex'
import { mapGetters, mapState } from 'vuex'
import Dropdown from './common/Dropdown.vue'
import WorkspaceDropdown from './WorkspaceDropdown.vue'
@@ -141,13 +143,13 @@ export default {
},
data: () => ({
appName: window.config.appName,
appName: window.config.appName
}),
computed: {
githubUrl: () => window.config.links.github_url,
helpUrl: () => window.config.links.help_url,
form() {
form () {
if (this.$route.name && this.$route.name.startsWith('forms.show_public')) {
return this.$store.getters['open/forms/getBySlug'](this.$route.params.slug)
}
@@ -156,13 +158,13 @@ export default {
workspace () {
return this.$store.getters['open/workspaces/getCurrent']()
},
paidPlansEnabled() {
paidPlansEnabled () {
return window.config.paid_plans_enabled
},
showAuth() {
showAuth () {
return this.$route.name && !this.$route.name.startsWith('forms.show_public')
},
hasNavbar() {
hasNavbar () {
if (this.isIframe) return false
if (this.$route.name && this.$route.name.startsWith('forms.show_public')) {
@@ -177,22 +179,25 @@ export default {
}
return !this.$root.navbarHidden
},
isIframe() {
isIframe () {
return window.location !== window.parent.location || window.frameElement
},
...mapGetters({
user: 'auth/user'
}),
userOnboarded() {
return this.user && this.user.workspaces_count > 0
...mapState({
workspacesLoading: state => state['open/workspaces'].loading
}),
userOnboarded () {
return this.user && (this.workspacesLoading || this.workspace)
},
hasCrisp() {
hasCrisp () {
return window.config.crisp_website_id
},
}
},
methods: {
async logout() {
async logout () {
// Log out the user.
await this.$store.dispatch('auth/logout')
@@ -201,7 +206,7 @@ export default {
this.$store.dispatch('open/forms/resetState')
// Redirect to login.
this.$router.push({name: 'login'})
this.$router.push({ name: 'login' })
},
openCrisp () {
window.$crisp.push(['do', 'chat:show'])