Fixes bug where comments would be incorrectly marked as updated & adds user-friendly messages

This commit is contained in:
Oleg Silkin 2020-01-28 17:20:23 -05:00
parent 0a4e0ca33f
commit 50528607e7
3 changed files with 64 additions and 40 deletions

57
dist/bundle.es.js vendored
View file

@ -15,7 +15,6 @@ const CHANNEL_NEW = 'new';
const PAGE_SIZE = 20; const PAGE_SIZE = 20;
var claim = /*#__PURE__*/Object.freeze({ var claim = /*#__PURE__*/Object.freeze({
__proto__: null,
MINIMUM_PUBLISH_BID: MINIMUM_PUBLISH_BID, MINIMUM_PUBLISH_BID: MINIMUM_PUBLISH_BID,
CHANNEL_ANONYMOUS: CHANNEL_ANONYMOUS, CHANNEL_ANONYMOUS: CHANNEL_ANONYMOUS,
CHANNEL_NEW: CHANNEL_NEW, CHANNEL_NEW: CHANNEL_NEW,
@ -286,8 +285,7 @@ const TOGGLE_BLOCK_CHANNEL = 'TOGGLE_BLOCK_CHANNEL';
// Sync // Sync
const USER_STATE_POPULATE = 'USER_STATE_POPULATE'; const USER_STATE_POPULATE = 'USER_STATE_POPULATE';
var action_types = /*#__PURE__*/Object.freeze({ var ACTIONS = /*#__PURE__*/Object.freeze({
__proto__: null,
WINDOW_FOCUSED: WINDOW_FOCUSED, WINDOW_FOCUSED: WINDOW_FOCUSED,
DAEMON_READY: DAEMON_READY, DAEMON_READY: DAEMON_READY,
DAEMON_VERSION_MATCH: DAEMON_VERSION_MATCH, DAEMON_VERSION_MATCH: DAEMON_VERSION_MATCH,
@ -542,7 +540,6 @@ const OTHER = 'other';
const COPYRIGHT = 'copyright'; const COPYRIGHT = 'copyright';
var licenses = /*#__PURE__*/Object.freeze({ var licenses = /*#__PURE__*/Object.freeze({
__proto__: null,
CC_LICENSES: CC_LICENSES, CC_LICENSES: CC_LICENSES,
NONE: NONE, NONE: NONE,
PUBLIC_DOMAIN: PUBLIC_DOMAIN, PUBLIC_DOMAIN: PUBLIC_DOMAIN,
@ -573,7 +570,6 @@ const HISTORY = 'user_history';
const WALLET = 'wallet'; const WALLET = 'wallet';
var pages = /*#__PURE__*/Object.freeze({ var pages = /*#__PURE__*/Object.freeze({
__proto__: null,
AUTH: AUTH, AUTH: AUTH,
BACKUP: BACKUP, BACKUP: BACKUP,
CHANNEL: CHANNEL, CHANNEL: CHANNEL,
@ -623,7 +619,6 @@ const RECEIVE_INTERESTS_NOTIFICATIONS = 'receiveInterestsNotifications';
const RECEIVE_CREATOR_NOTIFICATIONS = 'receiveCreatorNotifications'; const RECEIVE_CREATOR_NOTIFICATIONS = 'receiveCreatorNotifications';
var settings = /*#__PURE__*/Object.freeze({ var settings = /*#__PURE__*/Object.freeze({
__proto__: null,
CREDIT_REQUIRED_ACKNOWLEDGED: CREDIT_REQUIRED_ACKNOWLEDGED, CREDIT_REQUIRED_ACKNOWLEDGED: CREDIT_REQUIRED_ACKNOWLEDGED,
NEW_USER_ACKNOWLEDGED: NEW_USER_ACKNOWLEDGED, NEW_USER_ACKNOWLEDGED: NEW_USER_ACKNOWLEDGED,
EMAIL_COLLECTION_ACKNOWLEDGED: EMAIL_COLLECTION_ACKNOWLEDGED, EMAIL_COLLECTION_ACKNOWLEDGED: EMAIL_COLLECTION_ACKNOWLEDGED,
@ -651,7 +646,6 @@ const TITLE = 'title';
const FILENAME = 'filename'; const FILENAME = 'filename';
var sort_options = /*#__PURE__*/Object.freeze({ var sort_options = /*#__PURE__*/Object.freeze({
__proto__: null,
DATE_NEW: DATE_NEW, DATE_NEW: DATE_NEW,
DATE_OLD: DATE_OLD, DATE_OLD: DATE_OLD,
TITLE: TITLE, TITLE: TITLE,
@ -665,7 +659,6 @@ const COMPLETE = 'complete';
const MANUAL = 'manual'; const MANUAL = 'manual';
var thumbnail_upload_statuses = /*#__PURE__*/Object.freeze({ var thumbnail_upload_statuses = /*#__PURE__*/Object.freeze({
__proto__: null,
API_DOWN: API_DOWN, API_DOWN: API_DOWN,
READY: READY, READY: READY,
IN_PROGRESS: IN_PROGRESS, IN_PROGRESS: IN_PROGRESS,
@ -685,7 +678,6 @@ const UPDATE = 'update';
const ABANDON = 'abandon'; const ABANDON = 'abandon';
var transaction_types = /*#__PURE__*/Object.freeze({ var transaction_types = /*#__PURE__*/Object.freeze({
__proto__: null,
ALL: ALL, ALL: ALL,
SPEND: SPEND, SPEND: SPEND,
RECEIVE: RECEIVE, RECEIVE: RECEIVE,
@ -702,7 +694,6 @@ const PAGE_SIZE$1 = 50;
const LATEST_PAGE_SIZE = 20; const LATEST_PAGE_SIZE = 20;
var transaction_list = /*#__PURE__*/Object.freeze({ var transaction_list = /*#__PURE__*/Object.freeze({
__proto__: null,
PAGE_SIZE: PAGE_SIZE$1, PAGE_SIZE: PAGE_SIZE$1,
LATEST_PAGE_SIZE: LATEST_PAGE_SIZE LATEST_PAGE_SIZE: LATEST_PAGE_SIZE
}); });
@ -711,7 +702,6 @@ const SPEECH_STATUS = 'https://spee.ch/api/config/site/publishing';
const SPEECH_PUBLISH = 'https://spee.ch/api/claim/publish'; const SPEECH_PUBLISH = 'https://spee.ch/api/claim/publish';
var speech_urls = /*#__PURE__*/Object.freeze({ var speech_urls = /*#__PURE__*/Object.freeze({
__proto__: null,
SPEECH_STATUS: SPEECH_STATUS, SPEECH_STATUS: SPEECH_STATUS,
SPEECH_PUBLISH: SPEECH_PUBLISH SPEECH_PUBLISH: SPEECH_PUBLISH
}); });
@ -757,7 +747,6 @@ const WALLET_DIR = 'wallet_dir';
const WALLETS = 'wallets'; const WALLETS = 'wallets';
var daemon_settings = /*#__PURE__*/Object.freeze({ var daemon_settings = /*#__PURE__*/Object.freeze({
__proto__: null,
ANNOUNCE_HEAD_AND_SD_ONLY: ANNOUNCE_HEAD_AND_SD_ONLY, ANNOUNCE_HEAD_AND_SD_ONLY: ANNOUNCE_HEAD_AND_SD_ONLY,
API: API, API: API,
BLOB_DOWNLOAD_TIMEOUT: BLOB_DOWNLOAD_TIMEOUT, BLOB_DOWNLOAD_TIMEOUT: BLOB_DOWNLOAD_TIMEOUT,
@ -811,7 +800,6 @@ var daemon_settings = /*#__PURE__*/Object.freeze({
const WALLET_SERVERS = LBRYUM_SERVERS; const WALLET_SERVERS = LBRYUM_SERVERS;
var shared_preferences = /*#__PURE__*/Object.freeze({ var shared_preferences = /*#__PURE__*/Object.freeze({
__proto__: null,
WALLET_SERVERS: WALLET_SERVERS WALLET_SERVERS: WALLET_SERVERS
}); });
@ -1264,6 +1252,18 @@ function buildURI(UrlObj, includeProto = true, protoDefault = 'lbry://') {
deprecatedParts = _objectWithoutProperties(UrlObj, ['streamName', 'streamClaimId', 'channelName', 'channelClaimId', 'primaryClaimSequence', 'primaryBidPosition', 'secondaryClaimSequence', 'secondaryBidPosition']); deprecatedParts = _objectWithoutProperties(UrlObj, ['streamName', 'streamClaimId', 'channelName', 'channelClaimId', 'primaryClaimSequence', 'primaryBidPosition', 'secondaryClaimSequence', 'secondaryBidPosition']);
const { claimId, claimName, contentName } = deprecatedParts; const { claimId, claimName, contentName } = deprecatedParts;
{
if (claimId) {
console.error(__("'claimId' should no longer be used. Use 'streamClaimId' or 'channelClaimId' instead"));
}
if (claimName) {
console.error(__("'claimName' should no longer be used. Use 'streamClaimName' or 'channelClaimName' instead"));
}
if (contentName) {
console.error(__("'contentName' should no longer be used. Use 'streamName' instead"));
}
}
if (!claimName && !channelName && !streamName) { if (!claimName && !channelName && !streamName) {
console.error(__("'claimName', 'channelName', and 'streamName' are all empty. One must be present to build a url.")); console.error(__("'claimName', 'channelName', and 'streamName' are all empty. One must be present to build a url."));
} }
@ -4269,7 +4269,7 @@ function doCommentCreate(comment = '', claim_id = '', channel, parent_id) {
data: error data: error
}); });
dispatch(doToast({ dispatch(doToast({
message: 'Oops, someone broke comments.', message: 'Unable to create comment, please try again later.',
isError: true isError: true
})); }));
}); });
@ -4294,7 +4294,7 @@ function doCommentHide(comment_id) {
data: error data: error
}); });
dispatch(doToast({ dispatch(doToast({
message: 'There was an error hiding this comment. Please try again later.', message: 'Unable to hide this comment, please try again later.',
isError: true isError: true
})); }));
}); });
@ -4329,7 +4329,7 @@ function doCommentAbandon(comment_id) {
data: error data: error
}); });
dispatch(doToast({ dispatch(doToast({
message: 'There was an error hiding this comment. Please try again later.', message: 'Unable to delete this comment, please try again later.',
isError: true isError: true
})); }));
}); });
@ -4349,16 +4349,30 @@ function doCommentUpdate(comment_id, comment) {
comment_id: comment_id, comment_id: comment_id,
comment: comment comment: comment
}).then(result => { }).then(result => {
if (result != null) {
dispatch({ dispatch({
type: COMMENT_UPDATE_COMPLETED, type: COMMENT_UPDATE_COMPLETED,
data: { data: {
comment: result comment: result
} }
}); });
}).catch(error => { } else {
dispatch({ type: COMMENT_UPDATE_FAILED, data: error }); // the result will return null
dispatch({
type: undefined
});
dispatch(doToast({ dispatch(doToast({
message: 'There was an error hiding this comment. Please try again later.', message: 'Your channel is still being setup, try again in a few moments.',
isError: true
}));
}
}).catch(error => {
dispatch({
type: COMMENT_UPDATE_FAILED,
data: error
});
dispatch(doToast({
message: 'Unable to edit this comment, please try again later.',
isError: true isError: true
})); }));
}); });
@ -4890,10 +4904,7 @@ const commentReducer = handleActions({
[COMMENT_UPDATE_COMPLETED]: (state, action) => { [COMMENT_UPDATE_COMPLETED]: (state, action) => {
const { comment } = action.data; const { comment } = action.data;
const commentById = Object.assign({}, state.commentById); const commentById = Object.assign({}, state.commentById);
if (comment) {
commentById[comment.comment_id] = comment; commentById[comment.comment_id] = comment;
}
return _extends$8({}, state, { return _extends$8({}, state, {
commentById, commentById,
@ -5913,7 +5924,7 @@ const selectChannelIsBlocked = uri => reselect.createSelector(selectBlockedChann
return state.includes(uri); return state.includes(uri);
}); });
exports.ACTIONS = action_types; exports.ACTIONS = ACTIONS;
exports.CLAIM_VALUES = claim; exports.CLAIM_VALUES = claim;
exports.DAEMON_SETTINGS = daemon_settings; exports.DAEMON_SETTINGS = daemon_settings;
exports.DEFAULT_FOLLOWED_TAGS = DEFAULT_FOLLOWED_TAGS; exports.DEFAULT_FOLLOWED_TAGS = DEFAULT_FOLLOWED_TAGS;

View file

@ -166,15 +166,31 @@ export function doCommentUpdate(comment_id: string, comment: string) {
comment: comment, comment: comment,
}) })
.then((result: CommentUpdateResponse) => { .then((result: CommentUpdateResponse) => {
if (result != null) {
dispatch({ dispatch({
type: ACTIONS.COMMENT_UPDATE_COMPLETED, type: ACTIONS.COMMENT_UPDATE_COMPLETED,
data: { data: {
comment: result, comment: result,
}, },
}); });
} else {
// the result will return null
dispatch({
type: ACTIONS.COMENT_UPDATE_FAILED,
});
dispatch(
doToast({
message: 'Your channel is still being setup, try again in a few moments.',
isError: true,
})
);
}
}) })
.catch(error => { .catch(error => {
dispatch({ type: ACTIONS.COMMENT_UPDATE_FAILED, data: error }); dispatch({
type: ACTIONS.COMMENT_UPDATE_FAILED,
data: error,
});
dispatch( dispatch(
doToast({ doToast({
message: 'Unable to edit this comment, please try again later.', message: 'Unable to edit this comment, please try again later.',

View file

@ -121,10 +121,7 @@ export const commentReducer = handleActions(
[ACTIONS.COMMENT_UPDATE_COMPLETED]: (state: CommentsState, action: any) => { [ACTIONS.COMMENT_UPDATE_COMPLETED]: (state: CommentsState, action: any) => {
const { comment } = action.data; const { comment } = action.data;
const commentById = Object.assign({}, state.commentById); const commentById = Object.assign({}, state.commentById);
if (comment) {
commentById[comment.comment_id] = comment; commentById[comment.comment_id] = comment;
}
return { return {
...state, ...state,