Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: endless initial loading spinner #11084

Merged
merged 1 commit into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ We have updated the loading spinner on the initial page load to run continuously
Additionally, we have aligned the spinner's design with our other loading spinners and reduced the delay before it appears from 1 second to 0.5 seconds.

https://github.com/owncloud/web/pull/11054
https://github.com/owncloud/web/pull/11084
https://github.com/owncloud/web/issues/11041
https://github.com/owncloud/web/issues/11083
13 changes: 12 additions & 1 deletion packages/web-runtime/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,22 @@ export default defineComponent({

const activeRoute = computed(() => router.resolve(unref(router.currentRoute)))

const { layout } = useLayout({ router })
const { layout, layoutType } = useLayout({ router })

watch(
() => unref(activeRoute),
(newRoute, oldRoute) => {
/**
* Hide global loading spinner. It usually gets hidden after all apps
* have been loaded, but in some scenarios (plain layouts) we never load them.
*/
if (unref(layoutType) !== 'application') {
const loader = document.getElementById('splash-loading')
if (!loader?.classList.contains('splash-hide')) {
loader.classList.add('splash-hide')
}
}

const getAppContextFromRoute = (route: RouteLocation): string[] => {
return route?.path?.split('/').slice(1, 4)
}
Expand Down
17 changes: 4 additions & 13 deletions packages/web-runtime/src/composables/layout/useLayout.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
import LayoutPlain from '../../layouts/Plain.vue'
import LayoutApplication from '../../layouts/Application.vue'
import LayoutLoading from '../../layouts/Loading.vue'
import { isPublicLinkContextRequired, isUserContextRequired } from '../../router'
import { computed, unref } from 'vue'
import { Router } from 'vue-router'
import { useRouter, useAuthStore, AuthStore } from '@ownclouders/web-pkg'
import { useRouter, AuthStore } from '@ownclouders/web-pkg'

export interface LayoutOptions {
authStore?: AuthStore
router?: Router
}

const layoutTypes = ['plain', 'loading', 'application'] as const
const layoutTypes = ['plain', 'application'] as const
type LayoutType = (typeof layoutTypes)[number]

export const useLayout = (options?: LayoutOptions) => {
const authStore = options?.authStore || useAuthStore()
const router = options?.router || useRouter()

const layoutType = computed<LayoutType>(() => {
Expand All @@ -33,28 +30,22 @@ export const useLayout = (options?: LayoutOptions) => {
) {
return 'plain'
}
if (isPublicLinkContextRequired(router, unref(router.currentRoute))) {
return authStore.publicLinkContextReady ? 'application' : 'loading'
}
if (isUserContextRequired(router, unref(router.currentRoute))) {
return authStore.userContextReady ? 'application' : 'loading'
}

return 'application'
})

const layout = computed(() => {
switch (unref(layoutType)) {
case 'application':
return LayoutApplication
case 'loading':
return LayoutLoading
case 'plain':
default:
return LayoutPlain
}
})

return {
layoutType,
layout
}
}
46 changes: 0 additions & 46 deletions packages/web-runtime/src/layouts/Loading.vue

This file was deleted.