the problem of synchronizing the two commentServer of the application was solved

This commit is contained in:
ByronEricPerez 2022-08-15 12:27:11 -03:00
parent ef27cb5a9b
commit fd2d817ba7
2 changed files with 7 additions and 1 deletions

View file

@ -15,6 +15,7 @@ import { selectActiveChannelClaim } from 'redux/selectors/app';
import { selectSettingsByChannelId } from 'redux/selectors/comments'; import { selectSettingsByChannelId } from 'redux/selectors/comments';
import { makeSelectClientSetting } from 'redux/selectors/settings'; import { makeSelectClientSetting } from 'redux/selectors/settings';
import * as SETTINGS from 'constants/settings'; import * as SETTINGS from 'constants/settings';
import { doSetClientSetting } from 'redux/actions/settings';
const select = (state, props) => { const select = (state, props) => {
const claim = selectClaimForUri(state, props.uri); const claim = selectClaimForUri(state, props.uri);
@ -27,6 +28,7 @@ const select = (state, props) => {
settingsByChannelId: selectSettingsByChannelId(state), settingsByChannelId: selectSettingsByChannelId(state),
supportDisabled: makeSelectTagInClaimOrChannelForUri(props.uri, DISABLE_SUPPORT_TAG)(state), supportDisabled: makeSelectTagInClaimOrChannelForUri(props.uri, DISABLE_SUPPORT_TAG)(state),
customCommentServers: makeSelectClientSetting(SETTINGS.CUSTOM_COMMENTS_SERVERS)(state), customCommentServers: makeSelectClientSetting(SETTINGS.CUSTOM_COMMENTS_SERVERS)(state),
commentServer: makeSelectClientSetting(SETTINGS.CUSTOM_COMMENTS_SERVER_URL)(state),
}; };
}; };
@ -37,6 +39,7 @@ const perform = (dispatch, ownProps) => ({
doToast: (options) => dispatch(doToast(options)), doToast: (options) => dispatch(doToast(options)),
fetchComment: (commentId) => dispatch(doCommentById(commentId, false)), fetchComment: (commentId) => dispatch(doCommentById(commentId, false)),
sendTip: (params, callback, errorCallback) => dispatch(doSendTip(params, false, callback, errorCallback, false)), sendTip: (params, callback, errorCallback) => dispatch(doSendTip(params, false, callback, errorCallback, false)),
setCommentServer: (url) => dispatch(doSetClientSetting(SETTINGS.CUSTOM_COMMENTS_SERVER_URL, url, true)),
}); });
export default connect(select, perform)(CommentCreate); export default connect(select, perform)(CommentCreate);

View file

@ -65,6 +65,8 @@ type Props = {
setQuickReply: (any) => void, setQuickReply: (any) => void,
toast: (string) => void, toast: (string) => void,
customCommentServers: Array<CommentServerDetails>, customCommentServers: Array<CommentServerDetails>,
setCommentServer: (string) => void,
commentServer: string,
}; };
export function CommentCreate(props: Props) { export function CommentCreate(props: Props) {
@ -90,6 +92,8 @@ export function CommentCreate(props: Props) {
sendTip, sendTip,
setQuickReply, setQuickReply,
customCommentServers, customCommentServers,
setCommentServer,
commentServer,
} = props; } = props;
const defaultServer = { name: COMMENT_SERVER_NAME, url: COMMENT_SERVER_API }; const defaultServer = { name: COMMENT_SERVER_NAME, url: COMMENT_SERVER_API };
@ -102,7 +106,6 @@ export function CommentCreate(props: Props) {
location: { pathname }, location: { pathname },
} = useHistory(); } = useHistory();
const [commentServer, setCommentServer] = React.useState(defaultServer.url);
const [isSubmitting, setSubmitting] = React.useState(false); const [isSubmitting, setSubmitting] = React.useState(false);
const [commentFailure, setCommentFailure] = React.useState(false); const [commentFailure, setCommentFailure] = React.useState(false);
const [successTip, setSuccessTip] = React.useState({ txid: undefined, tipAmount: undefined }); const [successTip, setSuccessTip] = React.useState({ txid: undefined, tipAmount: undefined });