Skip to content

Commit 4cc8b5c

Browse files
committed
Add login check for cloning the theme
1 parent c5c2df5 commit 4cc8b5c

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

components/explore/PublishedThemeListing.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ const PublishedThemeListing = () => {
4040
};
4141

4242
useEffect(() => {
43-
if (!user) return;
4443
fetchPublishedThemes();
4544
}, [user]);
4645

components/profile/SnippngThemeItem.tsx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,13 @@ const SnippngThemeItem: React.FC<Props> = ({
9898
}
9999
};
100100

101-
const forkTheme = async () => {
101+
const cloneTheme = async () => {
102102
if (!db) return console.log(Error("Firebase is not configured")); // This is to handle error when there is no `.env` file. So, that app doesn't crash while developing without `.env` file.
103-
if (!user) return;
103+
if (!user)
104+
return addToast({
105+
message: "Login to clone the theme",
106+
type: "error",
107+
});
104108
try {
105109
let data = deepClone(theme);
106110
// delete original theme's uid and id to persist them as they are unique
@@ -135,8 +139,8 @@ const SnippngThemeItem: React.FC<Props> = ({
135139
LocalStorage.set("local_themes", previousThemes);
136140

137141
addToast({
138-
message: "Theme forked successfully!",
139-
description: "You can view your forked themes in your profile",
142+
message: "Theme cloned successfully!",
143+
description: "You can view your cloned themes in your profile",
140144
});
141145
}
142146
} catch (e) {
@@ -255,10 +259,10 @@ const SnippngThemeItem: React.FC<Props> = ({
255259
{theme?.ownerUid !== user?.uid ? (
256260
<Button
257261
className="ml-auto"
258-
aria-label="fork-theme"
259-
title="Fork theme"
262+
aria-label="clone-theme"
263+
title="Clone theme"
260264
StartIcon={ClipboardDocumentIcon}
261-
onClick={forkTheme}
265+
onClick={cloneTheme}
262266
>
263267
Clone theme
264268
</Button>

0 commit comments

Comments
 (0)