mirror of
https://github.com/glitch-soc/mastodon.git
synced 2025-12-28 13:47:23 +00:00
Refactor <Header> into TypeScript (#33956)
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { createSelector } from '@reduxjs/toolkit';
|
||||
import { Record as ImmutableRecord } from 'immutable';
|
||||
|
||||
import { me } from 'mastodon/initial_state';
|
||||
import { accountDefaultValues } from 'mastodon/models/account';
|
||||
import type { Account, AccountShape } from 'mastodon/models/account';
|
||||
import type { Relationship } from 'mastodon/models/relationship';
|
||||
@@ -45,3 +46,16 @@ export function makeGetAccount() {
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
export const getAccountHidden = createSelector(
|
||||
[
|
||||
(state: RootState, id: string) => state.accounts.get(id)?.hidden,
|
||||
(state: RootState, id: string) =>
|
||||
state.relationships.get(id)?.following ||
|
||||
state.relationships.get(id)?.requested,
|
||||
(state: RootState, id: string) => id === me,
|
||||
],
|
||||
(hidden, followingOrRequested, isSelf) => {
|
||||
return hidden && !(isSelf || followingOrRequested);
|
||||
},
|
||||
);
|
||||
|
||||
@@ -93,27 +93,23 @@ export const makeGetReport = () => createSelector([
|
||||
|
||||
export const getAccountGallery = createSelector([
|
||||
(state, id) => state.getIn(['timelines', `account:${id}:media`, 'items'], ImmutableList()),
|
||||
state => state.get('statuses'),
|
||||
state => state.get('statuses'),
|
||||
(state, id) => state.getIn(['accounts', id]),
|
||||
], (statusIds, statuses, account) => {
|
||||
let medias = ImmutableList();
|
||||
|
||||
statusIds.forEach(statusId => {
|
||||
const status = statuses.get(statusId).set('account', account);
|
||||
medias = medias.concat(status.get('media_attachments').map(media => media.set('status', status)));
|
||||
let status = statuses.get(statusId);
|
||||
|
||||
if (status) {
|
||||
status = status.set('account', account);
|
||||
medias = medias.concat(status.get('media_attachments').map(media => media.set('status', status)));
|
||||
}
|
||||
});
|
||||
|
||||
return medias;
|
||||
});
|
||||
|
||||
export const getAccountHidden = createSelector([
|
||||
(state, id) => state.getIn(['accounts', id, 'hidden']),
|
||||
(state, id) => state.getIn(['relationships', id, 'following']) || state.getIn(['relationships', id, 'requested']),
|
||||
(state, id) => id === me,
|
||||
], (hidden, followingOrRequested, isSelf) => {
|
||||
return hidden && !(isSelf || followingOrRequested);
|
||||
});
|
||||
|
||||
export const getStatusList = createSelector([
|
||||
(state, type) => state.getIn(['status_lists', type, 'items']),
|
||||
], (items) => items.toList());
|
||||
|
||||
Reference in New Issue
Block a user