Proposal: a modern & typed way of writing Redux actions doing API requests (#30270)

This commit is contained in:
Renaud Chaput 2024-05-23 11:50:13 +02:00 committed by GitHub
parent 3a862439df
commit 10ec421dd4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 281 additions and 125 deletions

View file

@ -11,7 +11,7 @@ const mapStateToProps = (state, { account }) => ({
const mapDispatchToProps = (dispatch, { account }) => ({
onSave (value) {
dispatch(submitAccountNote({ id: account.get('id'), value}));
dispatch(submitAccountNote(account.get('id'), value));
},
});

View file

@ -39,12 +39,12 @@ const mapDispatchToProps = dispatch => ({
},
onModalReblog (status, privacy) {
dispatch(reblog(status, privacy));
dispatch(reblog(status.id, privacy));
},
onReblog (status, e) {
if (status.get('reblogged')) {
dispatch(unreblog(status));
dispatch(unreblog(status.id));
} else {
if (e.shiftKey || !boostModal) {
this.onModalReblog(status);

View file

@ -123,7 +123,7 @@ class Footer extends ImmutablePureComponent {
_performReblog = (status, privacy) => {
const { dispatch } = this.props;
dispatch(reblog(status, privacy));
dispatch(reblog(status.id, privacy));
};
handleReblogClick = e => {
@ -132,7 +132,7 @@ class Footer extends ImmutablePureComponent {
if (signedIn) {
if (status.get('reblogged')) {
dispatch(unreblog(status));
dispatch(unreblog(status.id));
} else if ((e && e.shiftKey) || !boostModal) {
this._performReblog(status);
} else {

View file

@ -74,12 +74,12 @@ const mapDispatchToProps = (dispatch, { intl }) => ({
},
onModalReblog (status, privacy) {
dispatch(reblog(status, privacy));
dispatch(reblog(status.id, privacy));
},
onReblog (status, e) {
if (status.get('reblogged')) {
dispatch(unreblog(status));
dispatch(unreblog(status.id));
} else {
if (e.shiftKey || !boostModal) {
this.onModalReblog(status);

View file

@ -299,7 +299,7 @@ class Status extends ImmutablePureComponent {
};
handleModalReblog = (status, privacy) => {
this.props.dispatch(reblog(status, privacy));
this.props.dispatch(reblog(status.id, privacy));
};
handleReblogClick = (status, e) => {
@ -308,7 +308,7 @@ class Status extends ImmutablePureComponent {
if (signedIn) {
if (status.get('reblogged')) {
dispatch(unreblog(status));
dispatch(unreblog(status.id));
} else {
if ((e && e.shiftKey) || !boostModal) {
this.handleModalReblog(status);