Skip to content

Commit b2b8140

Browse files
committed
Handle update snippet button visibility due to ownerUid unhandled reset
1 parent 653b446 commit b2b8140

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

components/editor/SnippngCodeArea.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,11 @@ const SnippngCodeArea = () => {
112112
// if there is a uid means we are on edit page where we want to avoid persisting the editor config
113113
if (uid) return;
114114
// persist the editor config changes only when user is creating new snippet
115-
LocalStorage.set("config", { ...editorConfig, uid: undefined });
115+
LocalStorage.set("config", {
116+
...editorConfig,
117+
uid: undefined,
118+
ownerUid: undefined,
119+
});
116120
}, [editorConfig, uid]);
117121

118122
return (
@@ -255,7 +259,7 @@ const SnippngCodeArea = () => {
255259
? "Fork snippet"
256260
: "Save snippet"}
257261
</Button>
258-
{user && user.uid === ownerUid ? (
262+
{uid && user && user.uid === ownerUid ? (
259263
<Button
260264
StartIcon={ArrowPathIcon}
261265
disabled={updating}

pages/snippet/[uid].tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,12 @@ const SavedSnippet = () => {
4747
if (!router.isReady) return;
4848
fetchCodeSnippet();
4949
return () => {
50-
// set uid to undefined because we are leaving the snippet details page, the only page where uid is required
51-
setEditorConfig({ ...defaultEditorConfig, uid: undefined });
50+
// set uid & ownerUid to undefined because we are leaving the snippet details page, the only page where uid is required
51+
setEditorConfig({
52+
...defaultEditorConfig,
53+
uid: undefined,
54+
ownerUid: undefined,
55+
});
5256
};
5357
}, [router.isReady]);
5458

0 commit comments

Comments
 (0)