-
Notifications
You must be signed in to change notification settings - Fork 448
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11311 from nextcloud/backport/11308/stable28
[stable28] fix(mixins): migrate sessionIssueHandler mixin to composable
- Loading branch information
Showing
7 changed files
with
107 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/** | ||
* @copyright Copyright (c) 2023 Maksim Sukharev <[email protected]> | ||
* | ||
* @author Maksim Sukharev <[email protected]> | ||
* @author Marco Ambrosini <[email protected]> | ||
* | ||
* @license AGPL-3.0-or-later | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
|
||
import { nextTick, onBeforeMount, onBeforeUnmount, ref } from 'vue' | ||
|
||
import { generateUrl } from '@nextcloud/router' | ||
|
||
import { EventBus } from '../services/EventBus.js' | ||
import SessionStorage from '../services/SessionStorage.js' | ||
|
||
/** | ||
* Check whether the conflicting session detected or not, and navigate to another page | ||
* | ||
* @return {import('vue').Ref<boolean>} | ||
*/ | ||
export function useSessionIssueHandler() { | ||
const isLeavingAfterSessionIssue = ref(false) | ||
|
||
onBeforeMount(() => { | ||
EventBus.$on('duplicate-session-detected', duplicateSessionTriggered) | ||
EventBus.$on('deleted-session-detected', deletedSessionTriggered) | ||
}) | ||
|
||
onBeforeUnmount(() => { | ||
EventBus.$off('duplicate-session-detected', duplicateSessionTriggered) | ||
EventBus.$off('deleted-session-detected', deletedSessionTriggered) | ||
}) | ||
|
||
const redirectTo = (url) => { | ||
isLeavingAfterSessionIssue.value = true | ||
SessionStorage.removeItem('joined_conversation') | ||
// Need to delay until next tick, otherwise the PreventUnload is still being triggered, | ||
// placing the warning window in the foreground and annoying the user | ||
if (!IS_DESKTOP) { | ||
nextTick(() => { | ||
// FIXME: can't use router push as it somehow doesn't clean up | ||
// fully and leads the other instance where "Join here" was clicked | ||
// to redirect to "not found" | ||
window.location = generateUrl(url) | ||
}) | ||
} else { | ||
window.location.hash = `#${url}` | ||
window.location.reload() | ||
} | ||
} | ||
|
||
const duplicateSessionTriggered = () => { | ||
// TODO: DESKTOP: should close the duplicated window instead of redirect | ||
redirectTo('/apps/spreed/duplicate-session') | ||
} | ||
|
||
const deletedSessionTriggered = () => { | ||
// workaround: force page refresh to kill stray WebRTC connections | ||
redirectTo('/apps/spreed/not-found') | ||
} | ||
|
||
return isLeavingAfterSessionIssue | ||
} |
This file was deleted.
Oops, something went wrong.