mirror of
https://github.com/glitch-soc/mastodon.git
synced 2025-12-24 19:37:26 +00:00
[WIP] Initial status work
This commit is contained in:
7
app/javascript/glitch/selectors/intl.js
Normal file
7
app/javascript/glitch/selectors/intl.js
Normal file
@@ -0,0 +1,7 @@
|
||||
import { createStructuredSelector } from 'reselect';
|
||||
|
||||
const makeIntlSelector = () => createStructuredSelector({
|
||||
intl: ({ intl }) => intl,
|
||||
});
|
||||
|
||||
export default makeIntlSelector;
|
||||
33
app/javascript/glitch/selectors/status.js
Normal file
33
app/javascript/glitch/selectors/status.js
Normal file
@@ -0,0 +1,33 @@
|
||||
import { createSelector } from 'reselect';
|
||||
|
||||
const makeStatusSelector = () => {
|
||||
return createSelector(
|
||||
[
|
||||
(state, id) => state.getIn(['statuses', id]),
|
||||
(state, id) => state.getIn(['statuses', state.getIn(['statuses', id, 'reblog'])]),
|
||||
(state, id) => state.getIn(['accounts', state.getIn(['statuses', id, 'account'])]),
|
||||
(state, id) => state.getIn(['accounts', state.getIn(['statuses', state.getIn(['statuses', id, 'reblog']), 'account'])]),
|
||||
(state, id) => state.getIn(['cards', id], null),
|
||||
],
|
||||
|
||||
(statusBase, statusReblog, accountBase, accountReblog, card) => {
|
||||
if (!statusBase) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (statusReblog) {
|
||||
statusReblog = statusReblog.set('account', accountReblog);
|
||||
} else {
|
||||
statusReblog = null;
|
||||
}
|
||||
|
||||
return statusBase.withMutations(map => {
|
||||
map.set('reblog', statusReblog);
|
||||
map.set('account', accountBase);
|
||||
map.set('card', card);
|
||||
});
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
export default makeStatusSelector;
|
||||
Reference in New Issue
Block a user