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

View File

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

View File

@ -22,9 +22,17 @@ export const getters = {
}, },
isSidebarVisible: () => { isSidebarVisible: () => {
if (!getters.isLoggedIn()) { 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: () => { isStickySidebar: () => {
if (getters.isMobile()) { if (getters.isMobile()) {
@ -101,13 +109,15 @@ export const getters = {
currentPromptName: () => { currentPromptName: () => {
// Ensure state.prompts is an array // Ensure state.prompts is an array
if (!Array.isArray(state.prompts)) { if (!Array.isArray(state.prompts) || state.prompts.length === 0) {
return null; 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 null;
} }
return state.prompts[state.prompts.length - 1].name; return lastPrompt.name;
}, },
filesInUpload: () => { filesInUpload: () => {