[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,7 +1,7 @@
|
||||
import { Map as ImmutableMap, List as ImmutableList } from 'immutable';
|
||||
import { Map as ImmutableMap, List as ImmutableList } from "immutable";
|
||||
|
||||
import { ACCOUNT_BLOCK_SUCCESS, ACCOUNT_MUTE_SUCCESS } from 'mastodon/actions/accounts';
|
||||
import { DOMAIN_BLOCK_SUCCESS } from 'mastodon/actions/domain_blocks';
|
||||
import { ACCOUNT_BLOCK_SUCCESS, ACCOUNT_MUTE_SUCCESS } from "mastodon/actions/accounts";
|
||||
import { DOMAIN_BLOCK_SUCCESS } from "mastodon/actions/domain_blocks";
|
||||
|
||||
import {
|
||||
CONVERSATIONS_MOUNT,
|
||||
@@ -12,8 +12,8 @@ import {
|
||||
CONVERSATIONS_UPDATE,
|
||||
CONVERSATIONS_READ,
|
||||
CONVERSATIONS_DELETE_SUCCESS,
|
||||
} from '../actions/conversations';
|
||||
import { compareId } from '../compare_id';
|
||||
} from "../actions/conversations";
|
||||
import { compareId } from "../compare_id";
|
||||
|
||||
const initialState = ImmutableMap({
|
||||
items: ImmutableList(),
|
||||
@@ -29,8 +29,8 @@ const conversationToMap = item => ImmutableMap({
|
||||
last_status: item.last_status ? item.last_status.id : null,
|
||||
});
|
||||
|
||||
const updateConversation = (state, item) => state.update('items', list => {
|
||||
const index = list.findIndex(x => x.get('id') === item.id);
|
||||
const updateConversation = (state, item) => state.update("items", list => {
|
||||
const index = list.findIndex(x => x.get("id") === item.id);
|
||||
const newItem = conversationToMap(item);
|
||||
|
||||
if (index === -1) {
|
||||
@@ -45,9 +45,9 @@ const expandNormalizedConversations = (state, conversations, next, isLoadingRece
|
||||
|
||||
return state.withMutations(mutable => {
|
||||
if (!items.isEmpty()) {
|
||||
mutable.update('items', list => {
|
||||
mutable.update("items", list => {
|
||||
list = list.map(oldItem => {
|
||||
const newItemIndex = items.findIndex(x => x.get('id') === oldItem.get('id'));
|
||||
const newItemIndex = items.findIndex(x => x.get("id") === oldItem.get("id"));
|
||||
|
||||
if (newItemIndex === -1) {
|
||||
return oldItem;
|
||||
@@ -61,7 +61,7 @@ const expandNormalizedConversations = (state, conversations, next, isLoadingRece
|
||||
|
||||
list = list.concat(items);
|
||||
|
||||
return list.sortBy(x => x.get('last_status'), (a, b) => {
|
||||
return list.sortBy(x => x.get("last_status"), (a, b) => {
|
||||
if(a === null || b === null) {
|
||||
return -1;
|
||||
}
|
||||
@@ -72,47 +72,47 @@ const expandNormalizedConversations = (state, conversations, next, isLoadingRece
|
||||
}
|
||||
|
||||
if (!next && !isLoadingRecent) {
|
||||
mutable.set('hasMore', false);
|
||||
mutable.set("hasMore", false);
|
||||
}
|
||||
|
||||
mutable.set('isLoading', false);
|
||||
mutable.set("isLoading", false);
|
||||
});
|
||||
};
|
||||
|
||||
const filterConversations = (state, accountIds) => {
|
||||
return state.update('items', list => list.filterNot(item => item.get('accounts').some(accountId => accountIds.includes(accountId))));
|
||||
return state.update("items", list => list.filterNot(item => item.get("accounts").some(accountId => accountIds.includes(accountId))));
|
||||
};
|
||||
|
||||
export default function conversations(state = initialState, action) {
|
||||
switch (action.type) {
|
||||
case CONVERSATIONS_FETCH_REQUEST:
|
||||
return state.set('isLoading', true);
|
||||
case CONVERSATIONS_FETCH_FAIL:
|
||||
return state.set('isLoading', false);
|
||||
case CONVERSATIONS_FETCH_SUCCESS:
|
||||
return expandNormalizedConversations(state, action.conversations, action.next, action.isLoadingRecent);
|
||||
case CONVERSATIONS_UPDATE:
|
||||
return updateConversation(state, action.conversation);
|
||||
case CONVERSATIONS_MOUNT:
|
||||
return state.update('mounted', count => count + 1);
|
||||
case CONVERSATIONS_UNMOUNT:
|
||||
return state.update('mounted', count => count - 1);
|
||||
case CONVERSATIONS_READ:
|
||||
return state.update('items', list => list.map(item => {
|
||||
if (item.get('id') === action.id) {
|
||||
return item.set('unread', false);
|
||||
}
|
||||
case CONVERSATIONS_FETCH_REQUEST:
|
||||
return state.set("isLoading", true);
|
||||
case CONVERSATIONS_FETCH_FAIL:
|
||||
return state.set("isLoading", false);
|
||||
case CONVERSATIONS_FETCH_SUCCESS:
|
||||
return expandNormalizedConversations(state, action.conversations, action.next, action.isLoadingRecent);
|
||||
case CONVERSATIONS_UPDATE:
|
||||
return updateConversation(state, action.conversation);
|
||||
case CONVERSATIONS_MOUNT:
|
||||
return state.update("mounted", count => count + 1);
|
||||
case CONVERSATIONS_UNMOUNT:
|
||||
return state.update("mounted", count => count - 1);
|
||||
case CONVERSATIONS_READ:
|
||||
return state.update("items", list => list.map(item => {
|
||||
if (item.get("id") === action.id) {
|
||||
return item.set("unread", false);
|
||||
}
|
||||
|
||||
return item;
|
||||
}));
|
||||
case ACCOUNT_BLOCK_SUCCESS:
|
||||
case ACCOUNT_MUTE_SUCCESS:
|
||||
return filterConversations(state, [action.relationship.id]);
|
||||
case DOMAIN_BLOCK_SUCCESS:
|
||||
return filterConversations(state, action.accounts);
|
||||
case CONVERSATIONS_DELETE_SUCCESS:
|
||||
return state.update('items', list => list.filterNot(item => item.get('id') === action.id));
|
||||
default:
|
||||
return state;
|
||||
return item;
|
||||
}));
|
||||
case ACCOUNT_BLOCK_SUCCESS:
|
||||
case ACCOUNT_MUTE_SUCCESS:
|
||||
return filterConversations(state, [action.relationship.id]);
|
||||
case DOMAIN_BLOCK_SUCCESS:
|
||||
return filterConversations(state, action.accounts);
|
||||
case CONVERSATIONS_DELETE_SUCCESS:
|
||||
return state.update("items", list => list.filterNot(item => item.get("id") === action.id));
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user