Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
canifa_note
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vũ Hoàng Anh
canifa_note
Commits
ac377381
Commit
ac377381
authored
Jan 05, 2026
by
Steven
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: default visibility setting
parent
86013d6c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
6 deletions
+23
-6
user_service.go
server/router/api/v1/user_service.go
+1
-1
useMemoInit.ts
web/src/components/MemoEditor/hooks/useMemoInit.ts
+7
-1
index.tsx
web/src/components/MemoEditor/index.tsx
+9
-1
PreferencesSection.tsx
web/src/components/Settings/PreferencesSection.tsx
+6
-3
No files found.
server/router/api/v1/user_service.go
View file @
ac377381
...
@@ -421,7 +421,7 @@ func (s *APIV1Service) UpdateUserSetting(ctx context.Context, request *v1pb.Upda
...
@@ -421,7 +421,7 @@ func (s *APIV1Service) UpdateUserSetting(ctx context.Context, request *v1pb.Upda
incomingGeneral
:=
request
.
Setting
.
GetGeneralSetting
()
incomingGeneral
:=
request
.
Setting
.
GetGeneralSetting
()
for
_
,
field
:=
range
request
.
UpdateMask
.
Paths
{
for
_
,
field
:=
range
request
.
UpdateMask
.
Paths
{
switch
field
{
switch
field
{
case
"memo
V
isibility"
:
case
"memo
_v
isibility"
:
updatedGeneral
.
MemoVisibility
=
incomingGeneral
.
MemoVisibility
updatedGeneral
.
MemoVisibility
=
incomingGeneral
.
MemoVisibility
case
"theme"
:
case
"theme"
:
updatedGeneral
.
Theme
=
incomingGeneral
.
Theme
updatedGeneral
.
Theme
=
incomingGeneral
.
Theme
...
...
web/src/components/MemoEditor/hooks/useMemoInit.ts
View file @
ac377381
import
{
useEffect
,
useRef
}
from
"react"
;
import
{
useEffect
,
useRef
}
from
"react"
;
import
type
{
Visibility
}
from
"@/types/proto/api/v1/memo_service_pb"
;
import
type
{
EditorRefActions
}
from
"../Editor"
;
import
type
{
EditorRefActions
}
from
"../Editor"
;
import
{
cacheService
,
memoService
}
from
"../services"
;
import
{
cacheService
,
memoService
}
from
"../services"
;
import
{
useEditorContext
}
from
"../state"
;
import
{
useEditorContext
}
from
"../state"
;
...
@@ -9,6 +10,7 @@ export const useMemoInit = (
...
@@ -9,6 +10,7 @@ export const useMemoInit = (
cacheKey
:
string
|
undefined
,
cacheKey
:
string
|
undefined
,
username
:
string
,
username
:
string
,
autoFocus
?:
boolean
,
autoFocus
?:
boolean
,
defaultVisibility
?:
Visibility
,
)
=>
{
)
=>
{
const
{
actions
,
dispatch
}
=
useEditorContext
();
const
{
actions
,
dispatch
}
=
useEditorContext
();
const
initializedRef
=
useRef
(
false
);
const
initializedRef
=
useRef
(
false
);
...
@@ -37,6 +39,10 @@ export const useMemoInit = (
...
@@ -37,6 +39,10 @@ export const useMemoInit = (
if
(
cachedContent
)
{
if
(
cachedContent
)
{
dispatch
(
actions
.
updateContent
(
cachedContent
));
dispatch
(
actions
.
updateContent
(
cachedContent
));
}
}
// Apply default visibility for new memos
if
(
defaultVisibility
!==
undefined
)
{
dispatch
(
actions
.
setMetadata
({
visibility
:
defaultVisibility
}));
}
}
}
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
error
(
"Failed to initialize editor:"
,
error
);
console
.
error
(
"Failed to initialize editor:"
,
error
);
...
@@ -52,5 +58,5 @@ export const useMemoInit = (
...
@@ -52,5 +58,5 @@ export const useMemoInit = (
};
};
init
();
init
();
},
[
memoName
,
cacheKey
,
username
,
autoFocus
,
actions
,
dispatch
,
editorRef
]);
},
[
memoName
,
cacheKey
,
username
,
autoFocus
,
defaultVisibility
,
actions
,
dispatch
,
editorRef
]);
};
};
web/src/components/MemoEditor/index.tsx
View file @
ac377381
import
{
useQueryClient
}
from
"@tanstack/react-query"
;
import
{
useQueryClient
}
from
"@tanstack/react-query"
;
import
{
useRef
}
from
"react"
;
import
{
useRef
}
from
"react"
;
import
{
toast
}
from
"react-hot-toast"
;
import
{
toast
}
from
"react-hot-toast"
;
import
{
useAuth
}
from
"@/contexts/AuthContext"
;
import
useCurrentUser
from
"@/hooks/useCurrentUser"
;
import
useCurrentUser
from
"@/hooks/useCurrentUser"
;
import
{
memoKeys
}
from
"@/hooks/useMemoQueries"
;
import
{
memoKeys
}
from
"@/hooks/useMemoQueries"
;
import
{
userKeys
}
from
"@/hooks/useUserQueries"
;
import
{
userKeys
}
from
"@/hooks/useUserQueries"
;
import
{
handleError
}
from
"@/lib/error"
;
import
{
handleError
}
from
"@/lib/error"
;
import
{
cn
}
from
"@/lib/utils"
;
import
{
cn
}
from
"@/lib/utils"
;
import
{
useTranslate
}
from
"@/utils/i18n"
;
import
{
useTranslate
}
from
"@/utils/i18n"
;
import
{
convertVisibilityFromString
}
from
"@/utils/memo"
;
import
{
EditorContent
,
EditorMetadata
,
EditorToolbar
,
FocusModeExitButton
,
FocusModeOverlay
}
from
"./components"
;
import
{
EditorContent
,
EditorMetadata
,
EditorToolbar
,
FocusModeExitButton
,
FocusModeOverlay
}
from
"./components"
;
import
{
FOCUS_MODE_STYLES
}
from
"./constants"
;
import
{
FOCUS_MODE_STYLES
}
from
"./constants"
;
import
type
{
EditorRefActions
}
from
"./Editor"
;
import
type
{
EditorRefActions
}
from
"./Editor"
;
...
@@ -49,8 +51,14 @@ const MemoEditorImpl: React.FC<MemoEditorProps> = ({
...
@@ -49,8 +51,14 @@ const MemoEditorImpl: React.FC<MemoEditorProps> = ({
const
currentUser
=
useCurrentUser
();
const
currentUser
=
useCurrentUser
();
const
editorRef
=
useRef
<
EditorRefActions
>
(
null
);
const
editorRef
=
useRef
<
EditorRefActions
>
(
null
);
const
{
state
,
actions
,
dispatch
}
=
useEditorContext
();
const
{
state
,
actions
,
dispatch
}
=
useEditorContext
();
const
{
userGeneralSetting
}
=
useAuth
();
useMemoInit
(
editorRef
,
memoName
,
cacheKey
,
currentUser
?.
name
??
""
,
autoFocus
);
// Get default visibility from user settings
const
defaultVisibility
=
userGeneralSetting
?.
memoVisibility
?
convertVisibilityFromString
(
userGeneralSetting
.
memoVisibility
)
:
undefined
;
useMemoInit
(
editorRef
,
memoName
,
cacheKey
,
currentUser
?.
name
??
""
,
autoFocus
,
defaultVisibility
);
// Auto-save content to localStorage
// Auto-save content to localStorage
useAutoSave
(
state
.
content
,
currentUser
?.
name
??
""
,
cacheKey
);
useAutoSave
(
state
.
content
,
currentUser
?.
name
??
""
,
cacheKey
);
...
...
web/src/components/Settings/PreferencesSection.tsx
View file @
ac377381
...
@@ -34,9 +34,9 @@ const PreferencesSection = () => {
...
@@ -34,9 +34,9 @@ const PreferencesSection = () => {
);
);
};
};
const
handleDefaultMemoVisibilityChanged
=
async
(
value
:
string
)
=>
{
const
handleDefaultMemoVisibilityChanged
=
(
value
:
string
)
=>
{
updateUserGeneralSetting
(
updateUserGeneralSetting
(
{
generalSetting
:
{
memoVisibility
:
value
},
updateMask
:
[
"memo
V
isibility"
]
},
{
generalSetting
:
{
memoVisibility
:
value
},
updateMask
:
[
"memo
_v
isibility"
]
},
{
{
onSuccess
:
()
=>
{
onSuccess
:
()
=>
{
refetchSettings
();
refetchSettings
();
...
@@ -82,7 +82,10 @@ const PreferencesSection = () => {
...
@@ -82,7 +82,10 @@ const PreferencesSection = () => {
<
SettingGroup
title=
{
t
(
"setting.preference"
)
}
showSeparator
>
<
SettingGroup
title=
{
t
(
"setting.preference"
)
}
showSeparator
>
<
SettingRow
label=
{
t
(
"setting.preference-section.default-memo-visibility"
)
}
>
<
SettingRow
label=
{
t
(
"setting.preference-section.default-memo-visibility"
)
}
>
<
Select
value=
{
setting
.
memoVisibility
}
onValueChange=
{
handleDefaultMemoVisibilityChanged
}
>
<
Select
value=
{
setting
.
memoVisibility
||
"PRIVATE"
}
onValueChange=
{
handleDefaultMemoVisibilityChanged
}
>
<
SelectTrigger
className=
"min-w-fit"
>
<
SelectTrigger
className=
"min-w-fit"
>
<
div
className=
"flex items-center gap-2"
>
<
div
className=
"flex items-center gap-2"
>
<
VisibilityIcon
visibility=
{
convertVisibilityFromString
(
setting
.
memoVisibility
)
}
/>
<
VisibilityIcon
visibility=
{
convertVisibilityFromString
(
setting
.
memoVisibility
)
}
/>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment