a tool for shared writing and social publishing

fix type errors

+21 -26
+1 -2
actions/publishToPublication.ts
··· 49 49 ColorToRGB, 50 50 ColorToRGBA, 51 51 } from "components/ThemeManager/colorToLexicons"; 52 - import Color from "colorjs.io/types"; 53 - import { parseColor } from "react-aria-components"; 52 + import { parseColor } from "@react-stately/color"; 54 53 55 54 export async function publishToPublication({ 56 55 root_entity,
+10 -12
app/(home-pages)/home/LeafletList/LeafletOptions.tsx
··· 15 15 import { TemplateSmall } from "components/Icons/TemplateSmall"; 16 16 import { MoreOptionsVerticalTiny } from "components/Icons/MoreOptionsVerticalTiny"; 17 17 import { addLeafletToHome } from "actions/addLeafletToHome"; 18 + import { produce } from "immer"; 18 19 19 20 export const LeafletOptions = (props: { 20 21 leaflet: PermissionToken; ··· 143 144 await mutate( 144 145 (identity) => { 145 146 if (!identity) return; 146 - return { 147 - ...identity, 148 - permission_token_on_homepage: [ 149 - ...identity.permission_token_on_homepage, 150 - { 151 - created_at: props.added_at || new Date().toISOString(), 152 - permission_tokens: { 153 - ...props.leaflet, 154 - leaflets_in_publications: [], 155 - }, 147 + return produce<typeof identity>((draft) => { 148 + draft.permission_token_on_homepage.push({ 149 + created_at: props.added_at || new Date().toISOString(), 150 + permission_tokens: { 151 + ...props.leaflet, 152 + leaflets_to_documents: [], 153 + leaflets_in_publications: [], 156 154 }, 157 - ], 158 - }; 155 + }); 156 + })(identity); 159 157 }, 160 158 { revalidate: false }, 161 159 );
+10 -12
app/[leaflet_id]/actions/HomeButton.tsx
··· 9 9 import { useSmoker } from "../../../components/Toast"; 10 10 import { AddToHomeSmall } from "../../../components/Icons/AddToHomeSmall"; 11 11 import { HomeSmall } from "../../../components/Icons/HomeSmall"; 12 + import { produce } from "immer"; 12 13 13 14 export function HomeButton() { 14 15 let { permissions } = useEntitySetContext(); ··· 46 47 await addLeafletToHome(permission_token.id); 47 48 mutate((identity) => { 48 49 if (!identity) return; 49 - return { 50 - ...identity, 51 - permission_token_on_homepage: [ 52 - ...identity.permission_token_on_homepage, 53 - { 54 - created_at: new Date().toISOString(), 55 - permission_tokens: { 56 - ...permission_token, 57 - leaflets_in_publications: [], 58 - }, 50 + return produce<typeof identity>((draft) => { 51 + draft.permission_token_on_homepage.push({ 52 + created_at: new Date().toISOString(), 53 + permission_tokens: { 54 + ...permission_token, 55 + leaflets_to_documents: [], 56 + leaflets_in_publications: [], 59 57 }, 60 - ], 61 - }; 58 + }); 59 + })(identity); 62 60 }); 63 61 smoker({ 64 62 position: {