a tool for shared writing and social publishing
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

if on mobile open new doc in same tab

+14 -5
+2 -2
actions/createNewLeafletFromTemplate.ts
··· 35 35 .eq("id", template_id) 36 36 .single(); 37 37 let rootEntity = res.data?.root_entity; 38 - if (!rootEntity || !res.data) return { title: "Leaflet not found" }; 38 + if (!rootEntity || !res.data) return { error: "Leaflet not found" } as const; 39 39 let { data } = await supabase.rpc("get_facts", { 40 40 root: rootEntity, 41 41 }); ··· 123 123 124 124 client.end(); 125 125 if (redirectUser) redirect(`/${permissionToken.id}`); 126 - return permissionToken.id; 126 + return { id: permissionToken.id, error: null } as const; 127 127 }
+12 -3
app/home/CreateNewButton.tsx
··· 10 10 TemplateSmall, 11 11 } from "components/Icons"; 12 12 import { Menu, MenuItem } from "components/Layout"; 13 + import { useIsMobile } from "src/hooks/isMobile"; 13 14 import { create } from "zustand"; 14 15 import { combine, createJSONStorage, persist } from "zustand/middleware"; 15 16 ··· 42 43 export const CreateNewLeafletButton = (props: { 43 44 noLabelOnMobile?: boolean; 44 45 }) => { 46 + let isMobile = useIsMobile(); 45 47 let templates = useTemplateState((s) => s.templates); 48 + let openNewLeaflet = (id: string) => { 49 + if (isMobile) { 50 + window.location.href = `/${id}?focusFirstBlock`; 51 + } else { 52 + window.open(`/${id}?focusFirstBlock`, "_blank"); 53 + } 54 + }; 46 55 return ( 47 56 <Menu 48 57 trigger={ ··· 59 68 <MenuItem 60 69 onSelect={async () => { 61 70 let id = await createNewLeaflet("doc", false); 62 - window.open(`/${id}?focusFirstBlock`, "_blank"); 71 + openNewLeaflet(id); 63 72 }} 64 73 > 65 74 <BlockDocPageSmall />{" "} ··· 73 82 <MenuItem 74 83 onSelect={async () => { 75 84 let id = await createNewLeaflet("canvas", false); 76 - window.open(`/${id}?focusFirstBlock`, "_blank"); 85 + openNewLeaflet(id); 77 86 }} 78 87 > 79 88 <BlockCanvasPageSmall /> ··· 93 102 key={t.id} 94 103 onSelect={async () => { 95 104 let id = await createNewLeafletFromTemplate(t.id, false); 96 - window.open(`/${id}`, "_blank"); 105 + if (!id.error) openNewLeaflet(id.id); 97 106 }} 98 107 > 99 108 <TemplateSmall />