[build] upgrade eslint to 9.37.0 (#88)
Co-authored-by: tobi <tobi.smethurst@protonmail.com> Reviewed-on: https://codeberg.org/superseriousbusiness/masto-fe-standalone/pulls/88 Co-authored-by: Zoë Bijl <moiety@noreply.codeberg.org> Co-committed-by: Zoë Bijl <moiety@noreply.codeberg.org>
This commit is contained in:
@@ -1,14 +1,14 @@
|
||||
import { List as ImmutableList, Map as ImmutableMap } from 'immutable';
|
||||
import { createSelector } from 'reselect';
|
||||
import { List as ImmutableList, Map as ImmutableMap } from "immutable";
|
||||
import { createSelector } from "reselect";
|
||||
|
||||
import { toServerSideType } from 'mastodon/utils/filters';
|
||||
import { toServerSideType } from "mastodon/utils/filters";
|
||||
|
||||
import { me } from '../initial_state';
|
||||
import { me } from "../initial_state";
|
||||
|
||||
const getAccountBase = (state, id) => state.getIn(['accounts', id], null);
|
||||
const getAccountCounters = (state, id) => state.getIn(['accounts_counters', id], null);
|
||||
const getAccountRelationship = (state, id) => state.getIn(['relationships', id], null);
|
||||
const getAccountMoved = (state, id) => state.getIn(['accounts', state.getIn(['accounts', id, 'moved'])]);
|
||||
const getAccountBase = (state, id) => state.getIn(["accounts", id], null);
|
||||
const getAccountCounters = (state, id) => state.getIn(["accounts_counters", id], null);
|
||||
const getAccountRelationship = (state, id) => state.getIn(["relationships", id], null);
|
||||
const getAccountMoved = (state, id) => state.getIn(["accounts", state.getIn(["accounts", id, "moved"])]);
|
||||
|
||||
export const makeGetAccount = () => {
|
||||
return createSelector([getAccountBase, getAccountCounters, getAccountRelationship, getAccountMoved], (base, counters, relationship, moved) => {
|
||||
@@ -17,58 +17,60 @@ export const makeGetAccount = () => {
|
||||
}
|
||||
|
||||
return base.merge(counters).withMutations(map => {
|
||||
map.set('relationship', relationship);
|
||||
map.set('moved', moved);
|
||||
map.set("relationship", relationship);
|
||||
map.set("moved", moved);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
const getFilters = (state, { contextType }) => {
|
||||
if (!contextType) return null;
|
||||
if (!contextType) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const serverSideType = toServerSideType(contextType);
|
||||
const now = new Date();
|
||||
|
||||
return state.get('filters').filter((filter) => filter.get('context').includes(serverSideType) && (filter.get('expires_at') === null || filter.get('expires_at') > now));
|
||||
return state.get("filters").filter((filter) => filter.get("context").includes(serverSideType) && (filter.get("expires_at") === null || filter.get("expires_at") > now));
|
||||
};
|
||||
|
||||
export const makeGetStatus = () => {
|
||||
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(["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"])]),
|
||||
getFilters,
|
||||
],
|
||||
|
||||
(statusBase, statusReblog, accountBase, accountReblog, filters) => {
|
||||
if (!statusBase || statusBase.get('isLoading')) {
|
||||
if (!statusBase || statusBase.get("isLoading")) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (statusReblog) {
|
||||
statusReblog = statusReblog.set('account', accountReblog);
|
||||
statusReblog = statusReblog.set("account", accountReblog);
|
||||
} else {
|
||||
statusReblog = null;
|
||||
}
|
||||
|
||||
let filtered = false;
|
||||
if ((accountReblog || accountBase).get('id') !== me && filters) {
|
||||
let filterResults = statusReblog?.get('filtered') || statusBase.get('filtered') || ImmutableList();
|
||||
if (filterResults.some((result) => filters.getIn([result.get('filter'), 'filter_action']) === 'hide')) {
|
||||
if ((accountReblog || accountBase).get("id") !== me && filters) {
|
||||
let filterResults = statusReblog?.get("filtered") || statusBase.get("filtered") || ImmutableList();
|
||||
if (filterResults.some((result) => filters.getIn([result.get("filter"), "filter_action"]) === "hide")) {
|
||||
return null;
|
||||
}
|
||||
filterResults = filterResults.filter(result => filters.has(result.get('filter')));
|
||||
filterResults = filterResults.filter(result => filters.has(result.get("filter")));
|
||||
if (!filterResults.isEmpty()) {
|
||||
filtered = filterResults.map(result => filters.getIn([result.get('filter'), 'title']));
|
||||
filtered = filterResults.map(result => filters.getIn([result.get("filter"), "title"]));
|
||||
}
|
||||
}
|
||||
|
||||
return statusBase.withMutations(map => {
|
||||
map.set('reblog', statusReblog);
|
||||
map.set('account', accountBase);
|
||||
map.set('matched_filters', filtered);
|
||||
map.set("reblog", statusReblog);
|
||||
map.set("account", accountBase);
|
||||
map.set("matched_filters", filtered);
|
||||
});
|
||||
},
|
||||
);
|
||||
@@ -76,8 +78,8 @@ export const makeGetStatus = () => {
|
||||
|
||||
export const makeGetPictureInPicture = () => {
|
||||
return createSelector([
|
||||
(state, { id }) => state.get('picture_in_picture').statusId === id,
|
||||
(state) => state.getIn(['meta', 'layout']) !== 'mobile',
|
||||
(state, { id }) => state.get("picture_in_picture").statusId === id,
|
||||
(state) => state.getIn(["meta", "layout"]) !== "mobile",
|
||||
], (inUse, available) => ImmutableMap({
|
||||
inUse: inUse && available,
|
||||
available,
|
||||
@@ -89,7 +91,7 @@ const ALERT_DEFAULTS = {
|
||||
style: false,
|
||||
};
|
||||
|
||||
export const getAlerts = createSelector(state => state.get('alerts'), alerts =>
|
||||
export const getAlerts = createSelector(state => state.get("alerts"), alerts =>
|
||||
alerts.map(item => ({
|
||||
...ALERT_DEFAULTS,
|
||||
...item,
|
||||
@@ -97,37 +99,37 @@ export const getAlerts = createSelector(state => state.get('alerts'), alerts =>
|
||||
|
||||
export const makeGetNotification = () => createSelector([
|
||||
(_, base) => base,
|
||||
(state, _, accountId) => state.getIn(['accounts', accountId]),
|
||||
], (base, account) => base.set('account', account));
|
||||
(state, _, accountId) => state.getIn(["accounts", accountId]),
|
||||
], (base, account) => base.set("account", account));
|
||||
|
||||
export const makeGetReport = () => createSelector([
|
||||
(_, base) => base,
|
||||
(state, _, targetAccountId) => state.getIn(['accounts', targetAccountId]),
|
||||
], (base, targetAccount) => base.set('target_account', targetAccount));
|
||||
(state, _, targetAccountId) => state.getIn(["accounts", targetAccountId]),
|
||||
], (base, targetAccount) => base.set("target_account", targetAccount));
|
||||
|
||||
export const getAccountGallery = createSelector([
|
||||
(state, id) => state.getIn(['timelines', `account:${id}:media`, 'items'], ImmutableList()),
|
||||
state => state.get('statuses'),
|
||||
(state, id) => state.getIn(['accounts', id]),
|
||||
(state, id) => state.getIn(["timelines", `account:${id}:media`, "items"], ImmutableList()),
|
||||
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)));
|
||||
const status = statuses.get(statusId).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) => 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']),
|
||||
(state, type) => state.getIn(["status_lists", type, "items"]),
|
||||
], (items) => items.toList());
|
||||
|
||||
Reference in New Issue
Block a user