State fix (#183)

This commit is contained in:
Graham Steffaniak 2024-08-04 14:02:09 -05:00 committed by GitHub
parent c7cce0694b
commit 5ebaf2a45b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 18 additions and 14 deletions

View File

@ -29,12 +29,7 @@
</div>
<!-- Search results for mobile -->
<div
v-if="state.isMobile && active"
id="result"
:class="{ hidden: !active }"
ref="result"
>
<div v-if="isMobile && active" id="result" :class="{ hidden: !active }" ref="result">
<div id="result-list">
<div class="button" style="width: 100%">Search Context: {{ getContext }}</div>
<!-- List of search results -->
@ -102,7 +97,7 @@
</div>
<!-- Search results for desktop -->
<div v-show="!state.isMobile && active" id="result-desktop" ref="result">
<div v-show="!isMobile && active" id="result-desktop" ref="result">
<div class="searchContext">Search Context: {{ getContext }}</div>
<div id="result-list">
<div>
@ -306,7 +301,6 @@ export default {
return this.isTypeSelectDisabled;
},
active() {
console.log("calling active ", getters.currentPromptName());
return getters.currentPromptName() == "search";
},
showOverlay() {

View File

@ -221,7 +221,7 @@ export default {
return getters.currentPrompt();
},
active() {
return getters.isSidebarVisible() && getters.currentPromptName() == null;
return getters.isSidebarVisible();
},
signup: () => signup,
version: () => version,

View File

@ -22,9 +22,17 @@ export const getters = {
},
isSidebarVisible: () => {
if (!getters.isLoggedIn()) {
return false
return false;
}
return state.showSidebar || getters.isStickySidebar()
console.log(getters.currentPromptName());
if (typeof getters.currentPromptName() === "string" && !getters.isStickySidebar()) {
return false;
}
console.log(getters.currentView());
if (getters.currentView() !== "listingView") {
return false;
}
return state.showSidebar || getters.isStickySidebar();
},
isStickySidebar: () => {
if (getters.isMobile()) {
@ -101,13 +109,15 @@ export const getters = {
currentPromptName: () => {
// Ensure state.prompts is an array
if (!Array.isArray(state.prompts)) {
if (!Array.isArray(state.prompts) || state.prompts.length === 0) {
return null;
}
if (state.prompts.length === 0) {
// Check if the name property is a string
const lastPrompt = state.prompts[state.prompts.length - 1];
if (typeof lastPrompt?.name !== "string") {
return null;
}
return state.prompts[state.prompts.length - 1].name;
return lastPrompt.name;
},
filesInUpload: () => {