Skip to content

Commit 4ff8b3c

Browse files
authored
Add setting to collapse folders by default (#624)
<!-- Please read https://github.com/SableClient/Sable/blob/dev/CONTRIBUTING.md before submitting your pull request --> ### Description <!-- Please include a summary of the change. Please also include relevant motivation and context. List any dependencies that are required for this change. --> Adds a setting to visual tweaks that allows collapsing folders by default instead of the current behavior of saving the state of opened/closed folders Fixes #616 #### Type of change - [ ] Bug fix (non-breaking change which fixes an issue) - [x] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] This change requires a documentation update ### Checklist: - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings ### AI disclosure: - [ ] Partially AI assisted (clarify which code was AI assisted and briefly explain what it does). - [ ] Fully AI generated (explain what all the generated code does in moderate detail). <!-- Write any explanation required here, but do not generate the explanation using AI!! You must prove you understand what the code in this PR does. -->
2 parents 0ed196d + 81b0233 commit 4ff8b3c

File tree

4 files changed

+31
-3
lines changed

4 files changed

+31
-3
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
default: minor
3+
---
4+
5+
Add a setting to collapse sidebar folders by default.

src/app/features/settings/cosmetics/Themes.tsx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,10 @@ function PageZoomInput() {
482482
export function Appearance() {
483483
const [twitterEmoji, setTwitterEmoji] = useSetting(settingsAtom, 'twitterEmoji');
484484
const [showEasterEggs, setShowEasterEggs] = useSetting(settingsAtom, 'showEasterEggs');
485+
const [closeFoldersByDefault, setCloseFoldersByDefault] = useSetting(
486+
settingsAtom,
487+
'closeFoldersByDefault'
488+
);
485489

486490
return (
487491
<Box direction="Column" gap="700">
@@ -500,6 +504,21 @@ export function Appearance() {
500504
/>
501505
</SequenceCard>
502506

507+
<SequenceCard className={SequenceCardStyle} variant="SurfaceVariant" direction="Column">
508+
<SettingTile
509+
title="Close Space Folders by Default"
510+
focusId="collapse-folders-by-default"
511+
description="Collapse sidebar folders upon loading."
512+
after={
513+
<Switch
514+
variant="Primary"
515+
value={closeFoldersByDefault}
516+
onChange={setCloseFoldersByDefault}
517+
/>
518+
}
519+
/>
520+
</SequenceCard>
521+
503522
<SequenceCard className={SequenceCardStyle} variant="SurfaceVariant" direction="Column">
504523
<SettingTile
505524
title="Show Easter Eggs"

src/app/state/openedSidebarFolder.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
getLocalStorageItem,
66
setLocalStorageItem,
77
} from './utils/atomWithLocalStorage';
8+
import { getSettings } from './settings';
89

910
const OPENED_SIDEBAR_FOLDER = 'openedSidebarFolder';
1011

@@ -30,6 +31,10 @@ export const makeOpenedSidebarFolderAtom = (userId: string): OpenedSidebarFolder
3031
const baseOpenedSidebarFolderAtom = atomWithLocalStorage<Set<string>>(
3132
storeKey,
3233
(key) => {
34+
const settings = getSettings();
35+
if (settings.closeFoldersByDefault) {
36+
return new Set<string>();
37+
}
3338
const arrayValue = getLocalStorageItem<string[]>(key, []);
3439
return new Set(arrayValue);
3540
},

src/app/state/settings.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,11 @@ export interface Settings {
111111
alwaysShowCallButton: boolean;
112112
faviconForMentionsOnly: boolean;
113113
highlightMentions: boolean;
114-
/**
115-
* whether to enable pk compat
116-
*/
117114
pkCompat: boolean;
118115
pmpProxying: boolean;
119116
mentionInReplies: boolean;
120117
showPersonaSetting: boolean;
118+
closeFoldersByDefault: boolean;
121119

122120
// furry stuff
123121
renderAnimals: boolean;
@@ -216,6 +214,7 @@ const defaultSettings: Settings = {
216214
pmpProxying: false,
217215
mentionInReplies: true,
218216
showPersonaSetting: false,
217+
closeFoldersByDefault: false,
219218

220219
// furry stuff
221220
renderAnimals: true,

0 commit comments

Comments
 (0)