mirror of
https://github.com/VueTubeApp/VueTube
synced 2024-11-22 11:15:14 +00:00
feat: better back button handling. Removed redundant redirect for embed links
This commit is contained in:
parent
041cc70cf5
commit
4f6fdddcad
3 changed files with 38 additions and 29 deletions
|
@ -94,18 +94,21 @@ export default {
|
||||||
|
|
||||||
mounted() {
|
mounted() {
|
||||||
//--- Back Button Listener ---//
|
//--- Back Button Listener ---//
|
||||||
CapacitorApp.addListener("backButton", ({ canGoBack }) => {
|
this.backHandler = CapacitorApp.addListener(
|
||||||
//--- Back Closes Search ---//
|
"backButton",
|
||||||
if (this.search) {
|
({ canGoBack }) => {
|
||||||
this.search = false;
|
//--- Back Closes Search ---//
|
||||||
|
if (this.search) {
|
||||||
|
this.search = false;
|
||||||
|
|
||||||
//--- Back Goes Back ---//
|
//--- Back Goes Back ---//
|
||||||
} else if (!canGoBack) {
|
} else if (!canGoBack) {
|
||||||
CapacitorApp.exitApp();
|
CapacitorApp.exitApp();
|
||||||
} else {
|
} else {
|
||||||
window.history.back();
|
window.history.back();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
);
|
||||||
|
|
||||||
// --- External URL Handling --- //
|
// --- External URL Handling --- //
|
||||||
CapacitorApp.addListener("appUrlOpen", (event) => {
|
CapacitorApp.addListener("appUrlOpen", (event) => {
|
||||||
|
@ -122,6 +125,10 @@ export default {
|
||||||
document.head.appendChild(plugin);
|
document.head.appendChild(plugin);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
beforeDestroy() {
|
||||||
|
if (this.backHandler) this.backHandler.remove();
|
||||||
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
textChanged(text) {
|
textChanged(text) {
|
||||||
if (text.length <= 0) {
|
if (text.length <= 0) {
|
||||||
|
|
|
@ -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>
|
|
|
@ -209,6 +209,8 @@ import ShelfRenderer from "~/components/SectionRenderers/shelfRenderer.vue";
|
||||||
import mainCommentRenderer from "~/components/Comments/mainCommentRenderer.vue";
|
import mainCommentRenderer from "~/components/Comments/mainCommentRenderer.vue";
|
||||||
import SwipeableBottomSheet from "~/components/ExtendedComponents/swipeableBottomSheet";
|
import SwipeableBottomSheet from "~/components/ExtendedComponents/swipeableBottomSheet";
|
||||||
|
|
||||||
|
import { App as CapacitorApp } from "@capacitor/app";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
ShelfRenderer,
|
ShelfRenderer,
|
||||||
|
@ -250,10 +252,29 @@ export default {
|
||||||
|
|
||||||
mounted() {
|
mounted() {
|
||||||
this.mountedInit();
|
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() {
|
beforeDestroy() {
|
||||||
clearInterval(this.interval);
|
clearInterval(this.interval);
|
||||||
|
if (this.backHandler) this.backHandler.remove();
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
|
|
Loading…
Reference in a new issue