Skip to content

Commit d40b60a

Browse files
committed
whattheduck: Fix toolbar disappearing after exiting camera preview
1 parent ab983b5 commit d40b60a

File tree

3 files changed

+26
-8
lines changed

3 files changed

+26
-8
lines changed

apps/whattheduck/src/components/CameraPreviewOverlay.vue

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,7 @@
2828
<ion-button ref="takePhotoButton" size="large" :disabled="isSearching" @click="takePhoto()">
2929
<ion-icon :ios="apertureOutline" :md="apertureSharp" />
3030
</ion-button>
31-
<ion-button
32-
size="large"
33-
color="danger"
34-
:disabled="isSearching"
35-
@click="CameraPreview.stop().finally(() => (isCameraPreviewShown = false))"
36-
>
31+
<ion-button size="large" color="danger" :disabled="isSearching" @click="closeCamera">
3732
<ion-icon :ios="closeOutline" :md="closeSharp" />
3833
</ion-button>
3934
<div
@@ -106,6 +101,12 @@ const { coverId: coverIdEvents, storySearch: storySearchEvents } = inject(dmSock
106101
const { takePhoto, isSearching } = useCoverSearch(useRouter(), coverIdEvents, storySearchEvents);
107102
const { isCameraPreviewShown } = storeToRefs(app());
108103
104+
const closeCamera = () => {
105+
CameraPreview.stop().finally(() => {
106+
isCameraPreviewShown.value = false;
107+
});
108+
};
109+
109110
onIonViewWillLeave(() => {
110111
isCameraPreviewShown.value = false;
111112
});

apps/whattheduck/src/components/Collection.vue

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<CopyListButton />
55
<ViewModesButton v-if="!isIOS" />
66
</ion-buttons>
7-
<ion-header :translucent="true" :class="{ hidden: isCameraPreviewShown }">
7+
<ion-header :key="headerKey" :translucent="true" :class="{ hidden: isCameraPreviewShown }">
88
<ion-toolbar>
99
<ion-buttons slot="start">
1010
<ion-menu-button color="primary" />
@@ -88,6 +88,15 @@ watch(componentName, () => {
8888
filterText.value = '';
8989
});
9090
91+
// Force header re-render when camera preview is closed
92+
const headerKey = ref(0);
93+
watch(isCameraPreviewShown, async (shown, wasShown) => {
94+
if (wasShown && !shown) {
95+
await nextTick();
96+
headerKey.value++;
97+
}
98+
});
99+
91100
const showOfflineToast = async () => {
92101
const toast = await toastController.create({
93102
message: t(

apps/whattheduck/src/views/CoverSearchResults.vue

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<ion-page>
3-
<ion-header :translucent="true">
3+
<ion-header :key="headerKey" :translucent="true">
44
<ion-toolbar>
55
<ion-buttons slot="start">
66
<ion-menu-button color="primary" />
@@ -81,6 +81,14 @@ const { issuecodeDetails, publicationNames, issuePopularities, issueQuotations }
8181
const { fetchPublicationNames, fetchIssuecodeDetails, fetchIssuePopularities, fetchIssueQuotations } = webStores.coa();
8282
const { currentNavigationItem, isCameraPreviewShown } = storeToRefs(app());
8383
84+
const headerKey = ref(0);
85+
watch(isCameraPreviewShown, async (shown, wasShown) => {
86+
if (wasShown && !shown) {
87+
await nextTick();
88+
headerKey.value++;
89+
}
90+
});
91+
8492
const { IssueQuotation } = webComponents;
8593
8694
const cover = shallowRef<(typeof covers)['value'][0]>();

0 commit comments

Comments
 (0)