0
0
Fork 0
mirror of https://github.com/VueTubeApp/VueTube synced 2024-11-25 20:55:17 +00:00

feat: better back button handling. Removed redundant redirect for embed links

This commit is contained in:
Alex 2022-04-24 18:44:32 +12:00
parent 041cc70cf5
commit 4f6fdddcad
3 changed files with 38 additions and 29 deletions

View file

@ -94,18 +94,21 @@ export default {
mounted() {
//--- Back Button Listener ---//
CapacitorApp.addListener("backButton", ({ canGoBack }) => {
//--- Back Closes Search ---//
if (this.search) {
this.search = false;
this.backHandler = CapacitorApp.addListener(
"backButton",
({ canGoBack }) => {
//--- Back Closes Search ---//
if (this.search) {
this.search = false;
//--- Back Goes Back ---//
} else if (!canGoBack) {
CapacitorApp.exitApp();
} else {
window.history.back();
//--- Back Goes Back ---//
} else if (!canGoBack) {
CapacitorApp.exitApp();
} else {
window.history.back();
}
}
});
);
// --- External URL Handling --- //
CapacitorApp.addListener("appUrlOpen", (event) => {
@ -122,6 +125,10 @@ export default {
document.head.appendChild(plugin);
},
beforeDestroy() {
if (this.backHandler) this.backHandler.remove();
},
methods: {
textChanged(text) {
if (text.length <= 0) {

View file

@ -1,19 +0,0 @@
<template>
<div>
Redirecting...
</div>
</template>
<script>
export default {
layout: "empty",
mounted() {
this.$router.push(
"/watch?v="
+ $nuxt.$route.params.redirect_
);
}
}
</script>

View file

@ -209,6 +209,8 @@ import ShelfRenderer from "~/components/SectionRenderers/shelfRenderer.vue";
import mainCommentRenderer from "~/components/Comments/mainCommentRenderer.vue";
import SwipeableBottomSheet from "~/components/ExtendedComponents/swipeableBottomSheet";
import { App as CapacitorApp } from "@capacitor/app";
export default {
components: {
ShelfRenderer,
@ -250,10 +252,29 @@ export default {
mounted() {
this.mountedInit();
this.backHandler = CapacitorApp.addListener(
"backButton",
({ canGoBack }) => {
//--- Back Closes Search ---//
if (this.showComments) {
this.showComments = false;
//--- Back Goes Back ---//
} else if (!canGoBack) {
this.$router.replace(
`/${localStorage.getItem("startPage") || "home"}`
);
} else {
window.history.back();
}
}
);
},
beforeDestroy() {
clearInterval(this.interval);
if (this.backHandler) this.backHandler.remove();
},
methods: {