Edit a comment

You can only edit your comments if the current page is using the Editable Comments Plugin.

Since comments are saved using versioned structured data (type 501), everyone will be able to see old comments by browsing the comment history.

Contents

Edit a comment

Edit comment modal

Get the comment from the appendable data

The plugin fetches a data identifier handle for the comment you want to edit.

Get data ID handle at index

GET /appendable-data/:handleId/:index
controller.js
window.safeAppendableData.getDataIdAt(
    this._authToken, this._currentPostHandleId, index)

Get a structured data handle

The plugin fetches a structured data handle using the data identifier handle previously obtained.

Get structured data handle

GET /structured-data/handle/:dataIdHandle
controller.js
window.safeStructuredData.getHandle(this._authToken, address)

Update the structured data

The plugin updates the structured data handle with the new version of the comment.

controller.js
const payload = new Buffer(JSON.stringify({
  name: original.name,
  comment: newText,
  time: original.time,  // we keep the original time so the order stays intact
  editedTime: (new Date()).getTime()
})).toString('base64')

Update structured data

PATCH /structured-data/:handleId
controller.js
window.safeStructuredData.updateData(this._authToken, handleId, payload)

Save the structured data

The plugin saves the new version of the comment by sending a POST request to the SAFE Network.

Save structured data

POST /structured-data/:handleId
controller.js
window.safeStructuredData.post(this._authToken, handleId)

Drop the structured data handle

The plugin drops the structured data handle of the comment.

Drop structured data handle

DELETE /structured-data/handle/:handleId
controller.js
window.safeStructuredData.dropHandle(this._authToken, dataIdHandle)

Drop the data identifier handle

The plugin drops the data identifier handle of the comment.

Drop data ID handle

DELETE /data-id/:handleId
controller.js
window.safeDataId.dropHandle(this._authToken, dataIdHandle)

results matching ""

    No results matching ""