src/utils/skynet-ops.js
// Handle a user's proposal save action.
Handle a user's proposal save action.
Handle a user ' s proposal save action .
async function handleShareProposal(headlineText, detailText, imageFile, creatorPublicKey, mySkyInstance, dispatch) {
    try {
        let imageSkylinkUrl = null;
        if (imageFile) {
            console.debug(`Proposal has an image to be uploaded:\n\t${JSON.stringify(imageFile)}`);
            const {skylink} = await skynetClient.uploadFile(imageFile);
            imageSkylinkUrl = await skynetClient.getSkylinkUrl(skylink);
            console.debug(`Image uploaded to Skynet:\n\t${JSON.stringify(imageSkylinkUrl)}`);
        }
        const proposal = {
            text: detailText ?? "NOT_PROVIDED",
            imageSkylink: imageSkylinkUrl ?? null
        };
        const res = await writeJsonToMySky(mySkyInstance, MYSKY_PROPOSALS_FILE_PATH, proposal);
        await recordNew(res.dataLink);
        await storeHowAbout(res.dataLink, null, 0, headlineText, creatorPublicKey, dispatch);
    } catch (error) {
        console.error(`Error sharing proposal: ${error.message}`);
    }
}
async function handleShareProposal ( headlineText , detailText , imageFile , creatorPublicKey , mySkyInstance , dispatch ) { try { let imageSkylinkUrl = null ; if ( imageFile ) { console . debug ( ` \n \t ${ JSON . stringify ( imageFile ) } ` ) ; const { skylink } = await skynetClient . uploadFile ( imageFile ) ; imageSkylinkUrl = await skynetClient . getSkylinkUrl ( skylink ) ; console . debug ( ` \n \t ${ JSON . stringify ( imageSkylinkUrl ) } ` ) ; } const proposal = { text : detailText ?? "NOT_PROVIDED" , imageSkylink : imageSkylinkUrl ?? null } ; const res = await writeJsonToMySky ( mySkyInstance , MYSKY_PROPOSALS_FILE_PATH , proposal ) ; await recordNew ( res . dataLink ) ; await storeHowAbout ( res . dataLink , null , 0 , headlineText , creatorPublicKey , dispatch ) ; } catch ( error ) { console . error ( ` ${ error . message } ` ) ; } }
Handle a user's proposal save action.
Handle a user ' s proposal save action .
// When provided, upload image of proposal. // skylinks start with \`sia://\` and don't specify a portal URL // we can generate URLs for our current portal though.