Skip to content

Commit

Permalink
fix: drop Viewer+ViewerOverlay re-parenting
Browse files Browse the repository at this point in the history
- Viewer is always mounted next to the #content-vue, so it will be visible on body fullscreen-ed

Signed-off-by: Maksim Sukharev <[email protected]>
  • Loading branch information
Antreesy committed Sep 16, 2024
1 parent ce91a74 commit 0ba8d03
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 52 deletions.
16 changes: 1 addition & 15 deletions src/components/CallView/shared/ViewerOverlayCallView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,7 @@

<template>
<div ref="ghost" class="viewer-overlay-ghost">
<!--
Viewer Overlay should be teleported to be to the top of DOM to be on top of the Viewer,
because by default Viewer is on top of an entire Talk (#content-vue).
In the fullscreen mode Viewer is manually moved to #content-vue which is top layer by Fullscreen API.
FIXME: this is not correct to use Portal/Teleport to move something inside the Vue app.
Alternative solutions could be:
- Use full version of the Portal library (doesn't solve the same problem with Viewer)
- Use a new child of #content-vue as Talk Vue app
-->
<!-- Also Portal's selector is not reactive. We need to re-mount the node on selector change using key -->
<Portal :key="portalSelector" :selector="portalSelector">
<Portal>
<!-- Add .app-talk to use Talk icon classes outside of #content-vue -->
<div class="viewer-overlay app-talk"
:style="{
Expand Down Expand Up @@ -207,10 +197,6 @@ export default {
return this.$store.getters.conversation(this.token)
},
portalSelector() {
return this.$store.getters.getMainContainerSelector()
},
hasLocalScreen() {
return !!this.localModel.attributes.localScreen
},
Expand Down
37 changes: 0 additions & 37 deletions src/composables/useViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,32 +57,6 @@ function generatePermissions(filePermissions) {
return permissions
}

/**
* FIXME Remove this hack once it is possible to set the parent
* element of the viewer.
* By default the viewer is a sibling of the fullscreen element, so
* it is not visible when in fullscreen mode. It is not possible to
* specify the parent nor to know when the viewer was actually
* opened, so for the time being it is reparented if needed shortly
* after calling it.
*
* @see https://github.com/nextcloud/viewer/issues/995
*
* @param {boolean} isFullscreen - is currently in fullscreen mode
*/
function reparentViewer(isFullscreen) {
const viewerElement = document.getElementById('viewer')

if (isFullscreen) {
// When changed to the fullscreen mode, Viewer should be moved to the talk app
document.getElementById('content-vue')?.appendChild(viewerElement)
} else {
// In normal mode if it was in fullscreen before, move back to body
// Otherwise it will be overlapped by web-page's header
document.body.appendChild(viewerElement)
}
}

/**
* Is Viewer currently opened
*
Expand All @@ -99,15 +73,8 @@ const isViewerOpen = ref(false)
export function useViewer(fileAPI) {
const store = useStore()
const isInCall = useIsInCall()
const isFullscreen = useDocumentFullscreen()
const sidebarStore = useSidebarStore()

watch(isFullscreen, () => {
if (isViewerOpen.value) {
reparentViewer(isFullscreen.value)
}
})

/**
* Map object to be used by Viewer
* @param {object} file file object (from Files API or Talk API)
Expand Down Expand Up @@ -164,10 +131,6 @@ export function useViewer(fileAPI) {
await nextTick()

isViewerOpen.value = true

if (isFullscreen.value) {
reparentViewer(true)
}
}

return {
Expand Down

0 comments on commit 0ba8d03

Please sign in to comment.