Skip to content
Open
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
13 changes: 13 additions & 0 deletions src/RoundCubeWrapper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,21 @@ const frameWrapper = ref<null|HTMLDivElement>(null)
const externalFrame = ref<null|HTMLIFrameElement>(null)
let iFrameBody: undefined | HTMLBodyElement

// Flag to track if URL change originates from iframe navigation (to prevent reload loop)
let changeFromIframe = false

const contentObserver = new MutationObserver((entries) => {
logger.info('MUTATION OBSERVED', { entries })
const iFrame = externalFrame.value!
emitLoaded(iFrame)
})

watch(queryString, (_value) => {
if (changeFromIframe) {
logger.debug('SKIP IFRAME REFRESH (change from iframe)', { request: requestedLocation.value, current: currentLocation.value })
changeFromIframe = false
return
}
if (requestedLocation.value !== currentLocation.value) {
logger.debug('TRIGGER IFRAME REFRESH', { request: requestedLocation.value, current: currentLocation.value })
loading.value = true
Expand Down Expand Up @@ -182,6 +190,11 @@ const emitLoaded = (iFrame: HTMLIFrameElement) => {
currentLocation.value = iFrameWindow.location.href
const search = iFrameWindow.location.search
const query = Object.fromEntries((new URLSearchParams(search)).entries())

// Set flag to prevent watch from triggering iframe reload
// when the URL change originates from iframe navigation
changeFromIframe = true

emit('iframe-loaded', {
query,
iFrame,
Expand Down