mirror of
https://github.com/glitch-soc/mastodon.git
synced 2025-12-15 08:48:53 +00:00
[Glitch] Refactor code for reblogging and favouriting
Port 03dea64b79 to glitch-soc
Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
@@ -12,11 +12,9 @@ import {
|
||||
initAddFilter,
|
||||
} from 'flavours/glitch/actions/filters';
|
||||
import {
|
||||
reblog,
|
||||
favourite,
|
||||
toggleReblog,
|
||||
toggleFavourite,
|
||||
bookmark,
|
||||
unreblog,
|
||||
unfavourite,
|
||||
unbookmark,
|
||||
pin,
|
||||
unpin,
|
||||
@@ -37,7 +35,7 @@ import {
|
||||
undoStatusTranslation,
|
||||
} from 'flavours/glitch/actions/statuses';
|
||||
import Status from 'flavours/glitch/components/status';
|
||||
import { boostModal, favouriteModal, deleteModal } from 'flavours/glitch/initial_state';
|
||||
import { deleteModal } from 'flavours/glitch/initial_state';
|
||||
import { makeGetStatus, makeGetPictureInPicture } from 'flavours/glitch/selectors';
|
||||
|
||||
import { showAlertForError } from '../actions/alerts';
|
||||
@@ -113,25 +111,8 @@ const mapDispatchToProps = (dispatch, { intl, contextType }) => ({
|
||||
});
|
||||
},
|
||||
|
||||
onModalReblog (status, privacy) {
|
||||
if (status.get('reblogged')) {
|
||||
dispatch(unreblog({ statusId: status.get('id') }));
|
||||
} else {
|
||||
dispatch(reblog({ statusId: status.get('id'), visibility: privacy }));
|
||||
}
|
||||
},
|
||||
|
||||
onReblog (status, e) {
|
||||
dispatch((_, getState) => {
|
||||
let state = getState();
|
||||
if (state.getIn(['local_settings', 'confirm_boost_missing_media_description']) && status.get('media_attachments').some(item => !item.get('description')) && !status.get('reblogged')) {
|
||||
dispatch(openModal({ modalType: 'BOOST', modalProps: { status, onReblog: this.onModalReblog, missingMediaDescription: true } }));
|
||||
} else if (e.shiftKey || !boostModal) {
|
||||
this.onModalReblog(status);
|
||||
} else {
|
||||
dispatch(openModal({ modalType: 'BOOST', modalProps: { status, onReblog: this.onModalReblog } }));
|
||||
}
|
||||
});
|
||||
dispatch(toggleReblog(status.get('id'), e.shiftKey));
|
||||
},
|
||||
|
||||
onBookmark (status) {
|
||||
@@ -142,26 +123,8 @@ const mapDispatchToProps = (dispatch, { intl, contextType }) => ({
|
||||
}
|
||||
},
|
||||
|
||||
onModalFavourite (status) {
|
||||
dispatch(favourite(status));
|
||||
},
|
||||
|
||||
onFavourite (status, e) {
|
||||
if (status.get('favourited')) {
|
||||
dispatch(unfavourite(status));
|
||||
} else {
|
||||
if (e.shiftKey || !favouriteModal) {
|
||||
this.onModalFavourite(status);
|
||||
} else {
|
||||
dispatch(openModal({
|
||||
modalType: 'FAVOURITE',
|
||||
modalProps: {
|
||||
status,
|
||||
onFavourite: this.onModalFavourite,
|
||||
},
|
||||
}));
|
||||
}
|
||||
}
|
||||
dispatch(toggleFavourite(status.get('id'), e.shiftKey));
|
||||
},
|
||||
|
||||
onPin (status) {
|
||||
|
||||
Reference in New Issue
Block a user