start/stop on vue activation

This commit is contained in:
tamaina 2025-08-31 17:21:48 +09:00
parent 78570ffaff
commit 83016acd3e
1 changed files with 11 additions and 3 deletions

View File

@ -57,7 +57,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<script lang="ts" setup>
import QrScanner from 'qr-scanner';
import { onMounted, onUnmounted, ref, shallowRef, watch } from 'vue';
import { onActivated, onDeactivated, onMounted, onUnmounted, ref, shallowRef, watch } from 'vue';
import * as misskey from 'misskey-js';
import { getScrollContainer } from '@@/js/scroll.js';
import type { ApShowResponse } from 'misskey-js/entities.js';
@ -206,12 +206,20 @@ async function startQr() {
qrStarted.value = true;
}
async function stopQr() {
function stopQr() {
if (!scannerInstance.value) return;
await scannerInstance.value.stop();
scannerInstance.value.stop();
qrStarted.value = false;
}
onActivated(() => {
startQr;
});
onDeactivated(() => {
stopQr;
});
const alertLock = ref(false);
onMounted(() => {