Skip to content

Commit 89bcbd8

Browse files
wesbillmanBrain
andauthored
fix(desktop): keep Private toggle when picking a channel template (#2070)
Signed-off-by: Wes <[email protected]> Co-authored-by: Brain <21994759fc7a6fa6b965551d35cfd7897d262f2495467f2d78694ddcfa6a5c7e@sprout-oss.stage.blox.sqprod.co>
1 parent d7f918e commit 89bcbd8

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

‎desktop/src/features/sidebar/lib/useCreateChannelForm.ts‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ export function useCreateChannelForm({
7878
>(null);
7979
const [typePopoverOpen, setTypePopoverOpen] = React.useState(false);
8080
const nameInputRef = React.useRef<HTMLInputElement>(null);
81+
const visibilityTouchedRef = React.useRef(false);
8182

8283
const templatesQuery = useChannelTemplatesQuery();
8384
const templates = templatesQuery.data ?? [];
@@ -96,6 +97,7 @@ export function useCreateChannelForm({
9697
setErrorMessage(null);
9798
setSelectedTemplateId(null);
9899
setTypePopoverOpen(false);
100+
visibilityTouchedRef.current = false;
99101

100102
if (!autoFocusName) return;
101103

@@ -123,7 +125,7 @@ export function useCreateChannelForm({
123125
if (!templateId) {
124126
setSelectedTemplateId(null);
125127
setDescription("");
126-
setVisibility("open");
128+
if (!visibilityTouchedRef.current) setVisibility("open");
127129
setErrorMessage(null);
128130
return;
129131
}
@@ -135,7 +137,7 @@ export function useCreateChannelForm({
135137

136138
setSelectedTemplateId(templateId);
137139
setDescription(template.description ?? "");
138-
setVisibility(template.visibility);
140+
if (!visibilityTouchedRef.current) setVisibility(template.visibility);
139141
setErrorMessage(null);
140142
},
141143
[templates],
@@ -195,7 +197,10 @@ export function useCreateChannelForm({
195197
setErrorMessage(null);
196198
},
197199
visibility,
198-
setVisibility,
200+
setVisibility: (value: ChannelVisibility) => {
201+
visibilityTouchedRef.current = true;
202+
setVisibility(value);
203+
},
199204
ephemeral,
200205
setEphemeral,
201206
durationLabel,

0 commit comments

Comments
 (0)