src/utils/skynet-ops.js
// Dispatch a user's comment action.
Dispatch a user's comment action.
Dispatch a user ' s comment action .
async function handleShareProposalComment(commentText, proposalCommentsSkylink, proposalSkylink, proposalHeader, proposalCreator, mySkyUserPublicKey, mySkyInstance, dispatch) {
    try {
        const commentJson = {
            comment: commentText,
            author: mySkyUserPublicKey,
            creationDate: new Date().toUTCString()
        }
        let comments = await lazyLoadFromSkylink(proposalCommentsSkylink);
        if (!comments) {
            comments = [];
        }
        console.debug(`Sharing proposal comment: comment=${JSON.stringify(commentJson)} into ${JSON.stringify(comments)}`);
        comments.push(commentJson);
        const resSkylink = await writeProposalCommentsToSkyDB(comments, mySkyInstance, dispatch);
        if (resSkylink) {
            const resUpdatedComments = await lazyLoadFromSkylink(resSkylink.dataLink);
            const res = await storeHowAbout(proposalSkylink, resSkylink.dataLink, null, proposalHeader, proposalCreator, dispatch)
            console.debug(`Updating HowAbouts's comments:\n\t->res=${JSON.stringify(res)}`);
            dispatch({type: SET_PROPOSAL_COMMENTS_SKYLINK, payload: resSkylink});
            return resUpdatedComments;
        }
    } catch (e) {
        console.error(`Error sharing proposal comment: ${e.message}`);
    }
}
async function handleShareProposalComment ( commentText , proposalCommentsSkylink , proposalSkylink , proposalHeader , proposalCreator , mySkyUserPublicKey , mySkyInstance , dispatch ) { try { const commentJson = { comment : commentText , author : mySkyUserPublicKey , creationDate : new Date ( ) . toUTCString ( ) } let comments = await lazyLoadFromSkylink ( proposalCommentsSkylink ) ; if ( ! comments ) { comments = [ ] ; } console . debug ( ` ${ JSON . stringify ( commentJson ) } ${ JSON . stringify ( comments ) } ` ) ; comments . push ( commentJson ) ; const resSkylink = await writeProposalCommentsToSkyDB ( comments , mySkyInstance , dispatch ) ; if ( resSkylink ) { const resUpdatedComments = await lazyLoadFromSkylink ( resSkylink . dataLink ) ; const res = await storeHowAbout ( proposalSkylink , resSkylink . dataLink , null , proposalHeader , proposalCreator , dispatch ) console . debug ( ` \n \t ${ JSON . stringify ( res ) } ` ) ; dispatch ( { type : SET_PROPOSAL_COMMENTS_SKYLINK , payload : resSkylink } ) ; return resUpdatedComments ; } } catch ( e ) { console . error ( ` ${ e . message } ` ) ; } }
Dispatch a user's comment action.
Dispatch a user ' s comment action .