Skip to content
Snippets Groups Projects
Commit 84c8ec69 authored by Jason Salyers's avatar Jason Salyers
Browse files

[JES] Temporary workaround to immediately refresh an edited comment

parent 9e6ab577
No related branches found
No related tags found
3 merge requests!146Develop,!145Jsalyers add delay to edit comment,!144Jsalyers add delay to edit comment
......@@ -32,6 +32,7 @@ const FETCH_JSON_RESULT = 'global/FETCH_JSON_RESULT';
const SHOW_DIALOG = 'global/SHOW_DIALOG';
const HIDE_DIALOG = 'global/HIDE_DIALOG';
const RECEIVE_REWARDS = 'global/RECEIVE_REWARDS';
const LAZY_UPDATE = 'global/LAZY_UPDATE';
const postKey = (author, permlink) => {
if ((author || '') === '' || (permlink || '') === '') return null;
......@@ -77,6 +78,18 @@ export default function reducer(state = defaultState, action = {}) {
});
}
case LAZY_UPDATE:
// update edited post/comment in state
let key = payload.author + '/' + payload.permlink;
let update = {
body: payload.body,
title: payload.title,
category: payload.category,
};
return state.updateIn(['content', key], Map(), c =>
c.mergeDeep(update)
);
case RECEIVE_STATE: {
console.log(
'Merging state',
......@@ -488,3 +501,8 @@ export const hideDialog = payload => ({
type: HIDE_DIALOG,
payload,
});
export const lazyUpdate = payload => ({
type: LAZY_UPDATE,
payload,
});
......@@ -55,9 +55,7 @@ export function* getAccount(username, force = false) {
account.account_is_witness = true;
}
console.log('*****DEBUG***** raw account:', account);
account = fromJS(account);
console.log('*****DEBUG***** account fromJS: ', account);
yield put(globalActions.receiveAccount({ account }));
}
}
......
......@@ -55,6 +55,10 @@ function* preBroadcast_vote({ operation, username }) {
return operation;
}
export function* lazyUpdate(payload) {
yield put(globalActions.lazyUpdate(payload));
}
/** Keys, username, and password are not needed for the initial call. This will check the login and may trigger an action to prompt for the password / key. */
export function* broadcastOperation({
payload: {
......@@ -387,9 +391,13 @@ function* broadcastPayload({
function* accepted_comment({ operation }) {
const { author, permlink } = operation;
//sleep for a few seconds so we can get the latest info from hivemind once it updates (this is a temporary workaround)
yield call(wait, 9000);
yield call(getContent, { author, permlink });
//yield call(getContent, { author, permlink });
if (operation.title === '') {
yield call(lazyUpdate, operation);
} else {
yield call(wait, 9000);
yield call(getContent, { author, permlink });
}
yield put(globalActions.linkReply(operation));
}
......@@ -478,8 +486,8 @@ export function* preBroadcast_comment({ operation, username }) {
if (originalBody) {
const patch = createPatch(originalBody, body);
// Putting body into buffer will expand Unicode characters into their true length
if (patch && patch.length < new Buffer(body, 'utf-8').length)
body2 = patch;
//if (patch && patch.length < new Buffer(body, 'utf-8').length)
// body2 = patch;
}
if (!body2) body2 = body;
if (!permlink) permlink = yield createPermlink(title, author);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment