Skip to content

Commit

Permalink
feat(stateStore): checking the sidebar is collapsed
Browse files Browse the repository at this point in the history
  • Loading branch information
PleahMaCaka committed Nov 2, 2023
1 parent ea0d050 commit e46010a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/lib/components/Sidebar.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@
import Profile from "$lib/components/sidebar/Profile.svelte"
import SettingsButton from "$lib/components/sidebar/SettingsButton.svelte"
import SideButton from "$lib/components/sidebar/SideButton.svelte"
import { stateStore } from "$lib/stores/StateStore"
import { PageType } from "$lib/types/Chat"
import Icon from "@iconify/svelte"
let isCollapsed = (localStorage.getItem("isCollapsed") === "true")
function toggleCollapse() {
// TODO merge this state to stateStore
isCollapsed = !isCollapsed
localStorage.setItem("isCollapsed", isCollapsed.toString())
$stateStore.isSidebarCollapsed = isCollapsed
}
</script>

Expand Down
8 changes: 5 additions & 3 deletions src/lib/stores/StateStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ export interface StateStore {
},
debug: boolean,
delay: number,
translate: boolean
translate: boolean,
isSidebarCollapsed?: boolean
}


Expand All @@ -33,7 +34,7 @@ export const stateStore = writable<StateStore>({
appearance: Appearance.Dark,
pageType: PageType.Chat,
waiting: false, // is waiting AI response?
input: "", // it must be updating when send the message for avoid the bugs (and trash request),
input: "", // it must be updating when send the message for avoid the bugs (and trash request).
history: [{
author: Author.Assistant,
message: "Hello! I'm your private assistant! How can I help you today? 🤖",
Expand All @@ -44,5 +45,6 @@ export const stateStore = writable<StateStore>({
},
debug: false,
delay: 30,
translate: true
translate: true,
isSidebarCollapsed: false // only for checking; updating this will not change the UI.
})

0 comments on commit e46010a

Please sign in to comment.