diff --git a/components/editor/SnippngCodeArea.tsx b/components/editor/SnippngCodeArea.tsx index 6ed76c7..4b97339 100644 --- a/components/editor/SnippngCodeArea.tsx +++ b/components/editor/SnippngCodeArea.tsx @@ -83,6 +83,11 @@ const SnippngCodeArea: React.FC = ({ underConstructionTheme }) => { const savedDoc = await addDoc(collection(db, "snippets"), { ...dataToBeAdded, ownerUid: user.uid, + owner: { + displayName: user.displayName, + photoURL: user.photoURL, + email: user.email, + }, }); if (savedDoc.id) { addToast({ @@ -148,6 +153,7 @@ const SnippngCodeArea: React.FC = ({ underConstructionTheme }) => { ...editorConfig, uid: undefined, ownerUid: undefined, + owner: undefined, }); }, [editorConfig, uid, underConstructionTheme]); diff --git a/components/explore/PublishedThemeListing.tsx b/components/explore/PublishedThemeListing.tsx index b8623b2..804877a 100644 --- a/components/explore/PublishedThemeListing.tsx +++ b/components/explore/PublishedThemeListing.tsx @@ -25,7 +25,6 @@ const PublishedThemeListing = () => { ); docRef.forEach((doc) => { const theme = doc.data(); - if (theme.ownerUid === user?.uid) return; // filter the own themes _themes.push({ ...theme, uid: doc.id, diff --git a/pages/snippet/[uid].tsx b/pages/snippet/[uid].tsx index ea68a07..f3efe3d 100644 --- a/pages/snippet/[uid].tsx +++ b/pages/snippet/[uid].tsx @@ -13,7 +13,7 @@ import { useEffect, useState } from "react"; // TODO: implement SSR const SavedSnippet = () => { const router = useRouter(); - const { setEditorConfig } = useSnippngEditor(); + const { editorConfig, setEditorConfig } = useSnippngEditor(); const [notFound, setNotFound] = useState(false); const [loadingConfig, setLoadingConfig] = useState(true); @@ -53,6 +53,7 @@ const SavedSnippet = () => { ...defaultEditorConfig, uid: undefined, ownerUid: undefined, + owner: undefined, }); }; }, [router.isReady]); @@ -83,7 +84,45 @@ const SavedSnippet = () => { ); - return {loadingConfig ? : }; + return ( + + {loadingConfig ? ( + + ) : ( + <> +
+
+
+
+ +
+
+
+

+ {editorConfig?.owner?.displayName || "Snippng user"}{" "} + + Author + +

+

+ {editorConfig?.owner?.email || "Snippng user email"} +

+
+
+
+ + + )} +
+ ); }; export default SavedSnippet; diff --git a/types/editor.ts b/types/editor.ts index 5da13f2..1196aab 100644 --- a/types/editor.ts +++ b/types/editor.ts @@ -54,6 +54,7 @@ export type SnippngWindowControlsType = export interface SnippngEditorConfigInterface { ownerUid?: string; + owner?: Pick; uid?: string; watermark?: boolean; code: string; diff --git a/utils/index.ts b/utils/index.ts index 90423d3..e75ea58 100644 --- a/utils/index.ts +++ b/utils/index.ts @@ -175,6 +175,7 @@ export const getExportableConfig = ( deepClonedConfig.bgImageVisiblePatch = null; delete deepClonedConfig.uid; delete deepClonedConfig.ownerUid; + delete deepClonedConfig.owner; const exportableConfig: SnippngExportableConfig = deepClonedConfig; return exportableConfig; };