Skip to content

Commit e1fc8b1

Browse files
authored
Merge pull request #4570 from nextcloud/ref/app-performance
Performance optimizations
2 parents 614df8e + 5888090 commit e1fc8b1

25 files changed

Lines changed: 220 additions & 271 deletions

src/App.vue

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ import {
1010
defineAsyncComponent,
1111
onMounted,
1212
onUnmounted,
13-
watchEffect,
13+
watch,
1414
} from 'vue'
15+
import { useRoute } from 'vue-router'
1516
import debounce from 'lodash/debounce'
1617
import { subscribe, unsubscribe } from '@nextcloud/event-bus'
1718
import { t } from '@nextcloud/l10n'
@@ -39,6 +40,7 @@ import './assets/scss/globals.scss'
3940
4041
usePollWatcher()
4142
43+
const route = useRoute()
4244
const sessionStore = useSessionStore()
4345
const pollStore = usePollStore()
4446
const pollGroupsStore = usePollGroupsStore()
@@ -61,8 +63,8 @@ const useSidebar = computed(
6163
() =>
6264
pollStore.permissions.edit
6365
|| pollStore.permissions.comment
64-
|| sessionStore.route.name === 'combo'
65-
|| (sessionStore.route.name === 'group'
66+
|| route.meta.comboPage
67+
|| (route.meta.groupPage
6668
&& pollGroupsStore.currentPollGroup?.owner.id
6769
=== sessionStore.currentUser.id),
6870
)
@@ -105,9 +107,9 @@ function onTransitionsOn() {
105107
transitionsOn()
106108
}
107109
108-
watchEffect(() => {
109-
document.title = sessionStore.windowTitle
110-
})
110+
watch(() => sessionStore.windowTitle, (title) => {
111+
document.title = title
112+
}, { immediate: true })
111113
112114
onMounted(() => {
113115
subscribe(Event.TransitionsOff, onTransitionsOff)

src/components/Actions/modules/ActionAddPoll.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
-->
55

66
<script setup lang="ts">
7-
import { computed, ref } from 'vue'
7+
import { computed, ref, shallowRef } from 'vue'
88
import { useRouter } from 'vue-router'
99
1010
import { useSessionStore } from '../../../stores/session'
@@ -35,7 +35,7 @@ const {
3535
const router = useRouter()
3636
const sessionStore = useSessionStore()
3737
38-
const newPoll = ref({
38+
const newPoll = shallowRef({
3939
id: 0,
4040
title: '',
4141
})

src/components/Cards/CardLocked.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55

66
<script setup lang="ts">
77
import { computed } from 'vue'
8+
import { useRoute } from 'vue-router'
89
import CardDiv from '../Base/modules/CardDiv.vue'
910
import { t } from '@nextcloud/l10n'
10-
import { useSessionStore } from '../../stores/session'
1111
12-
const sessionStore = useSessionStore()
12+
const route = useRoute()
1313
const cardType = 'warning'
1414
1515
const cardText = computed(() =>
16-
sessionStore.route.name === 'publicVote'
16+
route.meta.publicVotePage
1717
? t(
1818
'polls',
1919
'This share is locked and allows only read access. Registering is not possible.',

src/components/Poll/PollHeaderButtons.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const ExportPoll = defineAsyncComponent(() => import('../Export/ExportPoll.vue')
2727
2828
const showUserMenu = computed(
2929
() =>
30-
route.name !== 'publicVote'
30+
!route.meta.publicVotePage
3131
|| pollStore.permissions.vote
3232
|| pollStore.permissions.subscribe,
3333
)

src/components/Poll/PollInformation.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ const countUsedVotes = computed(
272272
</BadgeDiv>
273273
<BadgeDiv
274274
v-if="
275-
$route.name === 'publicVote' && sessionStore.currentUser.emailAddress
275+
$route.meta.publicVotePage && sessionStore.currentUser.emailAddress
276276
">
277277
<template #icon>
278278
<EmailIcon />

src/components/PollGroup/PollGroupEditDlg.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ async function updatePollGroup() {
2929
pollGroupsStore.updating = true
3030
const pollGroup = await pollGroupsStore.writeCurrentPollGroup()
3131
if (pollGroup) {
32-
if (route.name === 'group' && pollGroup.slug !== route.params.slug) {
32+
if (route.meta.groupPage && pollGroup.slug !== route.params.slug) {
3333
// if the slug has changed, we need to reroute
3434
router.push({
3535
name: 'group',

src/components/PollList/PollItemActions.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ async function removePollFromGroup(pollId: number, pollGroupId: number) {
9595
'The poll group was deleted by removing the last member.',
9696
),
9797
)
98-
if (route.name === 'group') {
98+
if (route.meta.groupPage) {
9999
router.push({ name: 'root' })
100100
}
101101
}

src/components/User/ActionInputDisplayName.vue

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
<script setup lang="ts">
77
import { ref } from 'vue'
8+
import { useRoute } from 'vue-router'
89
import debounce from 'lodash/debounce'
910
import { showSuccess, showError } from '@nextcloud/dialogs'
1011
import { t } from '@nextcloud/l10n'
@@ -16,6 +17,9 @@ import { ValidatorAPI } from '../../Api'
1617
import { StatusResults } from '../../Types'
1718
import { useSessionStore } from '../../stores/session'
1819
20+
const route = useRoute()
21+
const sessionStore = useSessionStore()
22+
1923
type InputProps = {
2024
success: boolean
2125
error: boolean
@@ -24,8 +28,6 @@ type InputProps = {
2428
label: string
2529
}
2630
27-
const sessionStore = useSessionStore()
28-
2931
const inputProps = ref<InputProps>({
3032
success: false,
3133
error: false,
@@ -59,7 +61,7 @@ const validatePublicUsername = debounce(async function () {
5961
6062
try {
6163
await ValidatorAPI.validateName(
62-
sessionStore.route.params.token,
64+
sessionStore.publicToken,
6365
sessionStore.share.user.displayName,
6466
)
6567
setStatus('success')
@@ -87,7 +89,7 @@ async function submit() {
8789

8890
<template>
8991
<NcActionInput
90-
v-if="sessionStore.route.name === 'publicVote'"
92+
v-if="route.meta.publicVotePage"
9193
v-bind="inputProps"
9294
v-model="sessionStore.share.user.displayName"
9395
@update:value="validatePublicUsername"

src/components/User/ActionInputEmailAddress.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
<script setup lang="ts">
77
import { ref } from 'vue'
8+
import { useRoute } from 'vue-router'
89
import debounce from 'lodash/debounce'
910
import { showSuccess, showError } from '@nextcloud/dialogs'
1011
import { t } from '@nextcloud/l10n'
@@ -16,6 +17,8 @@ import { ValidatorAPI } from '../../Api'
1617
import { StatusResults } from '../../Types'
1718
import { useSessionStore } from '../../stores/session'
1819
20+
const route = useRoute()
21+
1922
type InputProps = {
2023
success: boolean
2124
error: boolean
@@ -88,7 +91,7 @@ async function submit() {
8891

8992
<template>
9093
<NcActionInput
91-
v-if="sessionStore.route.name === 'publicVote'"
94+
v-if="route.meta.publicVotePage"
9295
v-bind="inputProps"
9396
v-model="sessionStore.share.user.emailAddress"
9497
@update:model-value="validate"

src/components/User/UserAvatar.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const {
3030
} = defineProps<Props>()
3131
3232
const computedIsGuest = computed(
33-
() => route.name === 'publicVote' || user.isNoUser !== false,
33+
() => route.meta.publicVotePage || user.isNoUser !== false,
3434
)
3535
3636
const avatarUserId = computed(() => {

0 commit comments

Comments
 (0)