kopia lustrzana https://gitlab.com/soapbox-pub/soapbox
Types improvements, mostly
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>types
rodzic
b7c1d7d44a
commit
44d794b3cf
|
@ -110,6 +110,7 @@ module.exports = {
|
|||
'no-irregular-whitespace': 'error',
|
||||
'no-loop-func': 'error',
|
||||
'no-mixed-spaces-and-tabs': 'error',
|
||||
'no-multiple-empty-lines': ['error', { max: 1 }],
|
||||
'no-nested-ternary': 'warn',
|
||||
'no-restricted-imports': ['error', {
|
||||
patterns: [{
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
import { staticClient } from '../api';
|
||||
|
||||
import type { AnyAction } from 'redux';
|
||||
import type { AppDispatch } from 'soapbox/store';
|
||||
|
||||
const FETCH_ABOUT_PAGE_REQUEST = 'FETCH_ABOUT_PAGE_REQUEST';
|
||||
const FETCH_ABOUT_PAGE_SUCCESS = 'FETCH_ABOUT_PAGE_SUCCESS';
|
||||
const FETCH_ABOUT_PAGE_FAIL = 'FETCH_ABOUT_PAGE_FAIL';
|
||||
|
||||
const fetchAboutPage = (slug = 'index', locale?: string) => (dispatch: React.Dispatch<AnyAction>) => {
|
||||
const fetchAboutPage = (slug = 'index', locale?: string) => (dispatch: AppDispatch) => {
|
||||
dispatch({ type: FETCH_ABOUT_PAGE_REQUEST, slug, locale });
|
||||
|
||||
const filename = `${slug}${locale ? `.${locale}` : ''}.html`;
|
||||
|
|
|
@ -3,9 +3,8 @@ import api from '../api';
|
|||
import { openModal, closeModal } from './modals';
|
||||
|
||||
import type { AxiosError } from 'axios';
|
||||
import type { AnyAction } from 'redux';
|
||||
import type { RootState } from 'soapbox/store';
|
||||
import type { Account } from 'soapbox/types/entities';
|
||||
import type { AppDispatch, RootState } from 'soapbox/store';
|
||||
import type { APIEntity, Account } from 'soapbox/types/entities';
|
||||
|
||||
const ACCOUNT_NOTE_SUBMIT_REQUEST = 'ACCOUNT_NOTE_SUBMIT_REQUEST';
|
||||
const ACCOUNT_NOTE_SUBMIT_SUCCESS = 'ACCOUNT_NOTE_SUBMIT_SUCCESS';
|
||||
|
@ -15,7 +14,7 @@ const ACCOUNT_NOTE_INIT_MODAL = 'ACCOUNT_NOTE_INIT_MODAL';
|
|||
|
||||
const ACCOUNT_NOTE_CHANGE_COMMENT = 'ACCOUNT_NOTE_CHANGE_COMMENT';
|
||||
|
||||
const submitAccountNote = () => (dispatch: React.Dispatch<AnyAction>, getState: () => RootState) => {
|
||||
const submitAccountNote = () => (dispatch: AppDispatch, getState: () => RootState) => {
|
||||
dispatch(submitAccountNoteRequest());
|
||||
|
||||
const id = getState().account_notes.edit.account;
|
||||
|
@ -37,7 +36,7 @@ function submitAccountNoteRequest() {
|
|||
};
|
||||
}
|
||||
|
||||
function submitAccountNoteSuccess(relationship: any) {
|
||||
function submitAccountNoteSuccess(relationship: APIEntity) {
|
||||
return {
|
||||
type: ACCOUNT_NOTE_SUBMIT_SUCCESS,
|
||||
relationship,
|
||||
|
@ -51,7 +50,7 @@ function submitAccountNoteFail(error: AxiosError) {
|
|||
};
|
||||
}
|
||||
|
||||
const initAccountNoteModal = (account: Account) => (dispatch: React.Dispatch<AnyAction>, getState: () => RootState) => {
|
||||
const initAccountNoteModal = (account: Account) => (dispatch: AppDispatch, getState: () => RootState) => {
|
||||
const comment = getState().relationships.get(account.id)!.note;
|
||||
|
||||
dispatch({
|
||||
|
|
|
@ -599,7 +599,7 @@ const fetchUserIndex = () =>
|
|||
dispatch({ type: ADMIN_USER_INDEX_FETCH_REQUEST });
|
||||
|
||||
dispatch(fetchUsers(filters.toJS() as string[], page + 1, query, pageSize))
|
||||
.then((data: any) => {
|
||||
.then((data: APIEntity) => {
|
||||
if (data.error) {
|
||||
dispatch({ type: ADMIN_USER_INDEX_FETCH_FAIL });
|
||||
} else {
|
||||
|
@ -620,7 +620,7 @@ const expandUserIndex = () =>
|
|||
dispatch({ type: ADMIN_USER_INDEX_EXPAND_REQUEST });
|
||||
|
||||
dispatch(fetchUsers(filters.toJS() as string[], page + 1, query, pageSize, next))
|
||||
.then((data: any) => {
|
||||
.then((data: APIEntity) => {
|
||||
if (data.error) {
|
||||
dispatch({ type: ADMIN_USER_INDEX_EXPAND_FAIL });
|
||||
} else {
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
import { baseClient } from '../api';
|
||||
|
||||
import type { AnyAction } from 'redux';
|
||||
import type { AppDispatch } from 'soapbox/store';
|
||||
|
||||
export const APP_CREATE_REQUEST = 'APP_CREATE_REQUEST';
|
||||
export const APP_CREATE_SUCCESS = 'APP_CREATE_SUCCESS';
|
||||
|
@ -19,7 +19,7 @@ export const APP_VERIFY_CREDENTIALS_SUCCESS = 'APP_VERIFY_CREDENTIALS_SUCCESS';
|
|||
export const APP_VERIFY_CREDENTIALS_FAIL = 'APP_VERIFY_CREDENTIALS_FAIL';
|
||||
|
||||
export function createApp(params?: Record<string, string>, baseURL?: string) {
|
||||
return (dispatch: React.Dispatch<AnyAction>) => {
|
||||
return (dispatch: AppDispatch) => {
|
||||
dispatch({ type: APP_CREATE_REQUEST, params });
|
||||
return baseClient(null, baseURL).post('/api/v1/apps', params).then(({ data: app }) => {
|
||||
dispatch({ type: APP_CREATE_SUCCESS, params, app });
|
||||
|
@ -32,7 +32,7 @@ export function createApp(params?: Record<string, string>, baseURL?: string) {
|
|||
}
|
||||
|
||||
export function verifyAppCredentials(token: string) {
|
||||
return (dispatch: React.Dispatch<AnyAction>) => {
|
||||
return (dispatch: AppDispatch) => {
|
||||
dispatch({ type: APP_VERIFY_CREDENTIALS_REQUEST, token });
|
||||
return baseClient(token).get('/api/v1/apps/verify_credentials').then(({ data: app }) => {
|
||||
dispatch({ type: APP_VERIFY_CREDENTIALS_SUCCESS, token, app });
|
||||
|
|
|
@ -30,6 +30,7 @@ import { importFetchedAccount } from './importer';
|
|||
|
||||
import type { AxiosError } from 'axios';
|
||||
import type { AppDispatch, RootState } from 'soapbox/store';
|
||||
import type { APIEntity } from 'soapbox/types/entities';
|
||||
|
||||
export const SWITCH_ACCOUNT = 'SWITCH_ACCOUNT';
|
||||
|
||||
|
@ -185,10 +186,10 @@ export const logIn = (username: string, password: string) =>
|
|||
(dispatch: AppDispatch) => dispatch(getAuthApp()).then(() => {
|
||||
return dispatch(createUserToken(normalizeUsername(username), password));
|
||||
}).catch((error: AxiosError) => {
|
||||
if ((error.response?.data as any)?.error === 'mfa_required') {
|
||||
if ((error.response?.data as APIEntity)?.error === 'mfa_required') {
|
||||
// If MFA is required, throw the error and handle it in the component.
|
||||
throw error;
|
||||
} else if ((error.response?.data as any)?.identifier === 'awaiting_approval') {
|
||||
} else if ((error.response?.data as APIEntity)?.identifier === 'awaiting_approval') {
|
||||
toast.error(messages.awaitingApproval);
|
||||
} else {
|
||||
// Return "wrong password" message.
|
||||
|
|
|
@ -6,9 +6,9 @@ import api, { getLinks } from '../api';
|
|||
import { fetchRelationships } from './accounts';
|
||||
import { importFetchedAccounts } from './importer';
|
||||
|
||||
import type { AnyAction } from '@reduxjs/toolkit';
|
||||
import type { AxiosError } from 'axios';
|
||||
import type { RootState } from 'soapbox/store';
|
||||
import type { AppDispatch, RootState } from 'soapbox/store';
|
||||
import type { APIEntity } from 'soapbox/types/entities';
|
||||
|
||||
const BLOCKS_FETCH_REQUEST = 'BLOCKS_FETCH_REQUEST';
|
||||
const BLOCKS_FETCH_SUCCESS = 'BLOCKS_FETCH_SUCCESS';
|
||||
|
@ -18,7 +18,7 @@ const BLOCKS_EXPAND_REQUEST = 'BLOCKS_EXPAND_REQUEST';
|
|||
const BLOCKS_EXPAND_SUCCESS = 'BLOCKS_EXPAND_SUCCESS';
|
||||
const BLOCKS_EXPAND_FAIL = 'BLOCKS_EXPAND_FAIL';
|
||||
|
||||
const fetchBlocks = () => (dispatch: React.Dispatch<AnyAction>, getState: () => RootState) => {
|
||||
const fetchBlocks = () => (dispatch: AppDispatch, getState: () => RootState) => {
|
||||
if (!isLoggedIn(getState)) return null;
|
||||
const nextLinkName = getNextLinkName(getState);
|
||||
|
||||
|
@ -30,7 +30,7 @@ const fetchBlocks = () => (dispatch: React.Dispatch<AnyAction>, getState: () =>
|
|||
const next = getLinks(response).refs.find(link => link.rel === nextLinkName);
|
||||
dispatch(importFetchedAccounts(response.data));
|
||||
dispatch(fetchBlocksSuccess(response.data, next ? next.uri : null));
|
||||
dispatch(fetchRelationships(response.data.map((item: any) => item.id)) as any);
|
||||
dispatch(fetchRelationships(response.data.map((item: APIEntity) => item.id)));
|
||||
})
|
||||
.catch(error => dispatch(fetchBlocksFail(error)));
|
||||
};
|
||||
|
@ -39,7 +39,7 @@ function fetchBlocksRequest() {
|
|||
return { type: BLOCKS_FETCH_REQUEST };
|
||||
}
|
||||
|
||||
function fetchBlocksSuccess(accounts: any, next: any) {
|
||||
function fetchBlocksSuccess(accounts: APIEntity[], next: string | null) {
|
||||
return {
|
||||
type: BLOCKS_FETCH_SUCCESS,
|
||||
accounts,
|
||||
|
@ -54,7 +54,7 @@ function fetchBlocksFail(error: AxiosError) {
|
|||
};
|
||||
}
|
||||
|
||||
const expandBlocks = () => (dispatch: React.Dispatch<AnyAction>, getState: () => RootState) => {
|
||||
const expandBlocks = () => (dispatch: AppDispatch, getState: () => RootState) => {
|
||||
if (!isLoggedIn(getState)) return null;
|
||||
const nextLinkName = getNextLinkName(getState);
|
||||
|
||||
|
@ -72,7 +72,7 @@ const expandBlocks = () => (dispatch: React.Dispatch<AnyAction>, getState: () =>
|
|||
const next = getLinks(response).refs.find(link => link.rel === nextLinkName);
|
||||
dispatch(importFetchedAccounts(response.data));
|
||||
dispatch(expandBlocksSuccess(response.data, next ? next.uri : null));
|
||||
dispatch(fetchRelationships(response.data.map((item: any) => item.id)) as any);
|
||||
dispatch(fetchRelationships(response.data.map((item: APIEntity) => item.id)));
|
||||
})
|
||||
.catch(error => dispatch(expandBlocksFail(error)));
|
||||
};
|
||||
|
@ -83,7 +83,7 @@ function expandBlocksRequest() {
|
|||
};
|
||||
}
|
||||
|
||||
function expandBlocksSuccess(accounts: any, next: any) {
|
||||
function expandBlocksSuccess(accounts: APIEntity[], next: string | null) {
|
||||
return {
|
||||
type: BLOCKS_EXPAND_SUCCESS,
|
||||
accounts,
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
import api from '../api';
|
||||
|
||||
import type { RootState } from 'soapbox/store';
|
||||
import type { AppDispatch, RootState } from 'soapbox/store';
|
||||
|
||||
const getSubscribersCsv = () =>
|
||||
(dispatch: any, getState: () => RootState) =>
|
||||
(dispatch: AppDispatch, getState: () => RootState) =>
|
||||
api(getState).get('/api/v1/pleroma/admin/email_list/subscribers.csv');
|
||||
|
||||
const getUnsubscribersCsv = () =>
|
||||
(dispatch: any, getState: () => RootState) =>
|
||||
(dispatch: AppDispatch, getState: () => RootState) =>
|
||||
api(getState).get('/api/v1/pleroma/admin/email_list/unsubscribers.csv');
|
||||
|
||||
const getCombinedCsv = () =>
|
||||
(dispatch: any, getState: () => RootState) =>
|
||||
(dispatch: AppDispatch, getState: () => RootState) =>
|
||||
api(getState).get('/api/v1/pleroma/admin/email_list/combined.csv');
|
||||
|
||||
export {
|
||||
|
|
|
@ -569,7 +569,7 @@ const rejectEventParticipationRequestFail = (id: string, accountId: string, erro
|
|||
});
|
||||
|
||||
const fetchEventIcs = (id: string) =>
|
||||
(dispatch: any, getState: () => RootState) =>
|
||||
(dispatch: AppDispatch, getState: () => RootState) =>
|
||||
api(getState).get(`/api/v1/pleroma/events/${id}/ics`);
|
||||
|
||||
const cancelEventCompose = () => ({
|
||||
|
|
|
@ -6,6 +6,7 @@ import toast from 'soapbox/toast';
|
|||
|
||||
import type { AxiosResponse } from 'axios';
|
||||
import type { RootState } from 'soapbox/store';
|
||||
import type { APIEntity } from 'soapbox/types/entities';
|
||||
|
||||
export const EXPORT_FOLLOWS_REQUEST = 'EXPORT_FOLLOWS_REQUEST';
|
||||
export const EXPORT_FOLLOWS_SUCCESS = 'EXPORT_FOLLOWS_SUCCESS';
|
||||
|
@ -59,7 +60,7 @@ const listAccounts = (getState: () => RootState) => async(apiResponse: AxiosResp
|
|||
Array.prototype.push.apply(followings, apiResponse.data);
|
||||
}
|
||||
|
||||
accounts = followings.map((account: any) => normalizeAccount(account).fqn);
|
||||
accounts = followings.map((account: APIEntity) => normalizeAccount(account).fqn);
|
||||
return Array.from(new Set(accounts));
|
||||
};
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ import api from '../api';
|
|||
|
||||
import { ACCOUNTS_IMPORT, importFetchedAccounts } from './importer';
|
||||
|
||||
import type { AxiosError } from 'axios';
|
||||
import type { APIEntity } from 'soapbox/types/entities';
|
||||
|
||||
export const FAMILIAR_FOLLOWERS_FETCH_REQUEST = 'FAMILIAR_FOLLOWERS_FETCH_REQUEST';
|
||||
|
@ -24,7 +25,7 @@ type FamiliarFollowersFetchRequestSuccessAction = {
|
|||
type FamiliarFollowersFetchRequestFailAction = {
|
||||
type: typeof FAMILIAR_FOLLOWERS_FETCH_FAIL
|
||||
id: string
|
||||
error: any
|
||||
error: AxiosError
|
||||
}
|
||||
|
||||
type AccountsImportAction = {
|
||||
|
|
|
@ -314,7 +314,11 @@ const fetchGroupRelationshipsFail = (error: AxiosError) => ({
|
|||
|
||||
const joinGroup = (id: string) =>
|
||||
(dispatch: AppDispatch, getState: () => RootState) => {
|
||||
const locked = (getState().groups.items.get(id) as any).locked || false;
|
||||
const group = getState().groups.items.get(id);
|
||||
|
||||
if (!group) return null;
|
||||
|
||||
const locked = group.locked || false;
|
||||
|
||||
dispatch(joinGroupRequest(id, locked));
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ import toast from 'soapbox/toast';
|
|||
|
||||
import api from '../api';
|
||||
|
||||
import type { AxiosError } from 'axios';
|
||||
import type { RootState } from 'soapbox/store';
|
||||
|
||||
export const IMPORT_FOLLOWS_REQUEST = 'IMPORT_FOLLOWS_REQUEST';
|
||||
|
@ -28,7 +29,7 @@ type ImportDataActions = {
|
|||
| typeof IMPORT_MUTES_REQUEST
|
||||
| typeof IMPORT_MUTES_SUCCESS
|
||||
| typeof IMPORT_MUTES_FAIL
|
||||
error?: any
|
||||
error?: AxiosError
|
||||
config?: string
|
||||
}
|
||||
|
||||
|
|
|
@ -7,23 +7,21 @@ import type { AppDispatch, RootState } from 'soapbox/store';
|
|||
const noOp = (e: any) => {};
|
||||
|
||||
const fetchMedia = (mediaId: string) =>
|
||||
(dispatch: any, getState: () => RootState) => {
|
||||
return api(getState).get(`/api/v1/media/${mediaId}`);
|
||||
};
|
||||
(dispatch: AppDispatch, getState: () => RootState) =>
|
||||
api(getState).get(`/api/v1/media/${mediaId}`);
|
||||
|
||||
const updateMedia = (mediaId: string, params: Record<string, any>) =>
|
||||
(dispatch: any, getState: () => RootState) => {
|
||||
return api(getState).put(`/api/v1/media/${mediaId}`, params);
|
||||
};
|
||||
(dispatch: AppDispatch, getState: () => RootState) =>
|
||||
api(getState).put(`/api/v1/media/${mediaId}`, params);
|
||||
|
||||
const uploadMediaV1 = (data: FormData, onUploadProgress = noOp) =>
|
||||
(dispatch: any, getState: () => RootState) =>
|
||||
(dispatch: AppDispatch, getState: () => RootState) =>
|
||||
api(getState).post('/api/v1/media', data, {
|
||||
onUploadProgress: onUploadProgress,
|
||||
});
|
||||
|
||||
const uploadMediaV2 = (data: FormData, onUploadProgress = noOp) =>
|
||||
(dispatch: any, getState: () => RootState) =>
|
||||
(dispatch: AppDispatch, getState: () => RootState) =>
|
||||
api(getState).post('/api/v2/media', data, {
|
||||
onUploadProgress: onUploadProgress,
|
||||
});
|
||||
|
|
|
@ -21,5 +21,5 @@ export {
|
|||
const changeAlerts = (path: Array<string>, value: any) =>
|
||||
(dispatch: AppDispatch) => {
|
||||
dispatch(setAlerts(path, value));
|
||||
dispatch(saveSettings() as any);
|
||||
dispatch(saveSettings());
|
||||
};
|
||||
|
|
|
@ -54,7 +54,7 @@ const sendSubscriptionToBackend = (subscription: PushSubscription, me: Me) =>
|
|||
}
|
||||
}
|
||||
|
||||
return dispatch(createPushSubscription(params) as any);
|
||||
return dispatch(createPushSubscription(params));
|
||||
};
|
||||
|
||||
// Last one checks for payload support: https://web-push-book.gauntface.com/chapter-06/01-non-standards-browsers/#no-payload
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import type { AnyAction } from 'redux';
|
||||
import type { AppDispatch } from 'soapbox/store';
|
||||
|
||||
const SET_BROWSER_SUPPORT = 'PUSH_NOTIFICATIONS_SET_BROWSER_SUPPORT';
|
||||
const SET_SUBSCRIPTION = 'PUSH_NOTIFICATIONS_SET_SUBSCRIPTION';
|
||||
|
@ -20,7 +20,7 @@ const clearSubscription = () => ({
|
|||
});
|
||||
|
||||
const setAlerts = (path: Array<string>, value: any) =>
|
||||
(dispatch: React.Dispatch<AnyAction>) =>
|
||||
(dispatch: AppDispatch) =>
|
||||
dispatch({
|
||||
type: SET_ALERTS,
|
||||
path,
|
||||
|
|
|
@ -6,7 +6,6 @@ import Icon from 'soapbox/components/icon';
|
|||
import StillImage from 'soapbox/components/still-image';
|
||||
import { MIMETYPE_ICONS } from 'soapbox/components/upload';
|
||||
import { useSettings, useSoapboxConfig } from 'soapbox/hooks';
|
||||
import { Attachment } from 'soapbox/types/entities';
|
||||
import { truncateFilename } from 'soapbox/utils/media';
|
||||
|
||||
import { isIOS } from '../is-mobile';
|
||||
|
@ -14,6 +13,7 @@ import { isPanoramic, isPortrait, isNonConformingRatio, minimumAspectRatio, maxi
|
|||
|
||||
import type { Property } from 'csstype';
|
||||
import type { List as ImmutableList } from 'immutable';
|
||||
import type { Attachment } from 'soapbox/types/entities';
|
||||
|
||||
const ATTACHMENT_LIMIT = 4;
|
||||
const MAX_FILENAME_LENGTH = 45;
|
||||
|
|
|
@ -15,7 +15,6 @@ const Portal: React.FC<IPortal> = ({ children }) => {
|
|||
setIsRendered(true);
|
||||
}, []);
|
||||
|
||||
|
||||
if (!isRendered) {
|
||||
return null;
|
||||
}
|
||||
|
@ -28,4 +27,4 @@ const Portal: React.FC<IPortal> = ({ children }) => {
|
|||
);
|
||||
};
|
||||
|
||||
export default Portal;
|
||||
export default Portal;
|
||||
|
|
|
@ -99,7 +99,6 @@ const findElementPosition = (el: HTMLElement) => {
|
|||
};
|
||||
};
|
||||
|
||||
|
||||
const getPointerPosition = (el: HTMLElement, event: MouseEvent & TouchEvent): Point => {
|
||||
const box = findElementPosition(el);
|
||||
const boxW = el.offsetWidth;
|
||||
|
@ -121,4 +120,4 @@ const getPointerPosition = (el: HTMLElement, event: MouseEvent & TouchEvent): Po
|
|||
};
|
||||
};
|
||||
|
||||
export default Slider;
|
||||
export default Slider;
|
||||
|
|
|
@ -10,7 +10,8 @@ import Icon from 'soapbox/components/icon';
|
|||
import IconButton from 'soapbox/components/icon-button';
|
||||
import Motion from 'soapbox/features/ui/util/optional-motion';
|
||||
import { useAppDispatch } from 'soapbox/hooks';
|
||||
import { Attachment } from 'soapbox/types/entities';
|
||||
|
||||
import type { Attachment } from 'soapbox/types/entities';
|
||||
|
||||
const bookIcon = require('@tabler/icons/book.svg');
|
||||
const fileCodeIcon = require('@tabler/icons/file-code.svg');
|
||||
|
|
|
@ -28,10 +28,11 @@ import { normalizeAttachment } from 'soapbox/normalizers';
|
|||
import { ChatKeys, useChats } from 'soapbox/queries/chats';
|
||||
import { queryClient } from 'soapbox/queries/client';
|
||||
import toast from 'soapbox/toast';
|
||||
import { Account } from 'soapbox/types/entities';
|
||||
import { isDefaultHeader, isLocal, isRemote } from 'soapbox/utils/accounts';
|
||||
import { MASTODON, parseVersion } from 'soapbox/utils/features';
|
||||
|
||||
import type { Account } from 'soapbox/types/entities';
|
||||
|
||||
const messages = defineMessages({
|
||||
edit_profile: { id: 'account.edit_profile', defaultMessage: 'Edit profile' },
|
||||
linkVerifiedOn: { id: 'account.link_verified_on', defaultMessage: 'Ownership of this link was checked on {date}' },
|
||||
|
|
|
@ -5,7 +5,8 @@ import { fetchModerationLog } from 'soapbox/actions/admin';
|
|||
import ScrollableList from 'soapbox/components/scrollable-list';
|
||||
import { Column, Stack, Text } from 'soapbox/components/ui';
|
||||
import { useAppDispatch, useAppSelector } from 'soapbox/hooks';
|
||||
import { AdminLog } from 'soapbox/types/entities';
|
||||
|
||||
import type { AdminLog } from 'soapbox/types/entities';
|
||||
|
||||
const messages = defineMessages({
|
||||
heading: { id: 'column.admin.moderation_log', defaultMessage: 'Moderation Log' },
|
||||
|
|
|
@ -2,17 +2,17 @@ import userEvent from '@testing-library/user-event';
|
|||
import React from 'react';
|
||||
import { VirtuosoMockContext } from 'react-virtuoso';
|
||||
|
||||
|
||||
import { __stub } from 'soapbox/api';
|
||||
import { ChatContext } from 'soapbox/contexts/chat-context';
|
||||
import { queryClient, render, rootState, screen, waitFor } from 'soapbox/jest/test-helpers';
|
||||
import { normalizeChatMessage, normalizeInstance } from 'soapbox/normalizers';
|
||||
import { IAccount } from 'soapbox/queries/accounts';
|
||||
import { ChatMessage } from 'soapbox/types/entities';
|
||||
|
||||
import { __stub } from '../../../../api';
|
||||
import { queryClient, render, rootState, screen, waitFor } from '../../../../jest/test-helpers';
|
||||
import { IChat } from '../../../../queries/chats';
|
||||
import ChatMessageList from '../chat-message-list';
|
||||
|
||||
import type { IAccount } from 'soapbox/queries/accounts';
|
||||
import type { IChat } from 'soapbox/queries/chats';
|
||||
import type { ChatMessage } from 'soapbox/types/entities';
|
||||
|
||||
const chat: IChat = {
|
||||
accepted: true,
|
||||
account: {
|
||||
|
|
|
@ -8,11 +8,12 @@ import { useChatContext } from 'soapbox/contexts/chat-context';
|
|||
import UploadButton from 'soapbox/features/compose/components/upload-button';
|
||||
import { search as emojiSearch } from 'soapbox/features/emoji/emoji-mart-search-light';
|
||||
import { useAppDispatch, useAppSelector, useFeatures } from 'soapbox/hooks';
|
||||
import { Attachment } from 'soapbox/types/entities';
|
||||
import { textAtCursorMatchesToken } from 'soapbox/utils/suggestions';
|
||||
|
||||
import ChatTextarea from './chat-textarea';
|
||||
|
||||
import type { Attachment } from 'soapbox/types/entities';
|
||||
|
||||
const messages = defineMessages({
|
||||
placeholder: { id: 'chat.input.placeholder', defaultMessage: 'Type a message' },
|
||||
send: { id: 'chat.actions.send', defaultMessage: 'Send' },
|
||||
|
|
|
@ -3,7 +3,8 @@ import React from 'react';
|
|||
|
||||
import { Text } from 'soapbox/components/ui';
|
||||
import emojify from 'soapbox/features/emoji/emoji';
|
||||
import { EmojiReaction } from 'soapbox/types/entities';
|
||||
|
||||
import type { EmojiReaction } from 'soapbox/types/entities';
|
||||
|
||||
interface IChatMessageReaction {
|
||||
emojiReaction: EmojiReaction
|
||||
|
@ -42,4 +43,4 @@ const ChatMessageReaction = (props: IChatMessageReaction) => {
|
|||
);
|
||||
};
|
||||
|
||||
export default ChatMessageReaction;
|
||||
export default ChatMessageReaction;
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
import React from 'react';
|
||||
|
||||
import { HStack, Textarea } from 'soapbox/components/ui';
|
||||
import { Attachment } from 'soapbox/types/entities';
|
||||
|
||||
import ChatPendingUpload from './chat-pending-upload';
|
||||
import ChatUpload from './chat-upload';
|
||||
|
||||
import type { Attachment } from 'soapbox/types/entities';
|
||||
|
||||
interface IChatTextarea extends React.ComponentProps<typeof Textarea> {
|
||||
attachments?: Attachment[]
|
||||
onDeleteAttachment?: (i: number) => void
|
||||
|
|
|
@ -8,6 +8,7 @@ import { FormGroup, Stack, Text, Textarea } from 'soapbox/components/ui';
|
|||
import { useAppDispatch, useAppSelector } from 'soapbox/hooks';
|
||||
|
||||
import type { ReducerAccount } from 'soapbox/reducers/accounts';
|
||||
import type { Rule } from 'soapbox/reducers/rules';
|
||||
|
||||
const messages = defineMessages({
|
||||
placeholder: { id: 'report.placeholder', defaultMessage: 'Additional comments' },
|
||||
|
@ -59,7 +60,7 @@ const ReasonStep = (_props: IReasonStep) => {
|
|||
}
|
||||
};
|
||||
|
||||
const filterRuleType = (rule: any) => {
|
||||
const filterRuleType = (rule: Rule) => {
|
||||
const ruleTypeToFilter = isReportingAccount ? 'account' : 'content';
|
||||
|
||||
if (rule.rule_type) {
|
||||
|
|
|
@ -4,7 +4,8 @@ import React from 'react';
|
|||
import PollOption from 'soapbox/components/polls/poll-option';
|
||||
import { Stack } from 'soapbox/components/ui';
|
||||
import { useAppSelector } from 'soapbox/hooks';
|
||||
import { Poll as PollEntity } from 'soapbox/types/entities';
|
||||
|
||||
import type { Poll as PollEntity } from 'soapbox/types/entities';
|
||||
|
||||
interface IPollPreview {
|
||||
pollId: string
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*/
|
||||
import { changeSettingImmediate } from 'soapbox/actions/settings';
|
||||
|
||||
import type { Store } from 'soapbox/store';
|
||||
import type { AppDispatch, Store } from 'soapbox/store';
|
||||
|
||||
/** Add Soapbox globals to the window. */
|
||||
export const createGlobals = (store: Store) => {
|
||||
|
@ -14,7 +14,7 @@ export const createGlobals = (store: Store) => {
|
|||
if (![true, false].includes(bool)) {
|
||||
throw `Invalid option ${bool}. Must be true or false.`;
|
||||
}
|
||||
store.dispatch(changeSettingImmediate(['isDeveloper'], bool) as any);
|
||||
(store.dispatch as AppDispatch)(changeSettingImmediate(['isDeveloper'], bool));
|
||||
return bool;
|
||||
},
|
||||
};
|
||||
|
|
|
@ -14,7 +14,7 @@ const useDimensions = (): UseDimensionsResult => {
|
|||
|
||||
const observer = useMemo(
|
||||
() =>
|
||||
new ResizeObserver((entries: any) => {
|
||||
new ResizeObserver((entries) => {
|
||||
if (entries[0]) {
|
||||
const { width, height } = entries[0].contentRect;
|
||||
setRect({ width, height });
|
||||
|
@ -23,7 +23,7 @@ const useDimensions = (): UseDimensionsResult => {
|
|||
[],
|
||||
);
|
||||
|
||||
useEffect((): any => {
|
||||
useEffect(() => {
|
||||
if (!element) return;
|
||||
observer.observe(element);
|
||||
|
||||
|
|
|
@ -7,12 +7,13 @@ import { createTestStore, mockStore, queryClient, renderHook, rootState, waitFor
|
|||
import { normalizeChatMessage, normalizeRelationship } from 'soapbox/normalizers';
|
||||
import { normalizeEmojiReaction } from 'soapbox/normalizers/emoji-reaction';
|
||||
import { Store } from 'soapbox/store';
|
||||
import { ChatMessage } from 'soapbox/types/entities';
|
||||
import { flattenPages } from 'soapbox/utils/queries';
|
||||
|
||||
import { IAccount } from '../accounts';
|
||||
import { ChatKeys, IChat, isLastMessage, useChat, useChatActions, useChatMessages, useChats } from '../chats';
|
||||
|
||||
import type { ChatMessage } from 'soapbox/types/entities';
|
||||
|
||||
const chat: IChat = {
|
||||
accepted: true,
|
||||
account: {
|
||||
|
|
|
@ -8,7 +8,6 @@ import { useStatContext } from 'soapbox/contexts/stat-context';
|
|||
import { useApi, useAppDispatch, useAppSelector, useFeatures, useOwnAccount } from 'soapbox/hooks';
|
||||
import { normalizeChatMessage } from 'soapbox/normalizers';
|
||||
import toast from 'soapbox/toast';
|
||||
import { ChatMessage } from 'soapbox/types/entities';
|
||||
import { reOrderChatListItems, updateChatMessage } from 'soapbox/utils/chats';
|
||||
import { flattenPages, PaginatedResult, updatePageItem } from 'soapbox/utils/queries';
|
||||
|
||||
|
@ -16,6 +15,7 @@ import { queryClient } from './client';
|
|||
import { useFetchRelationships } from './relationships';
|
||||
|
||||
import type { IAccount } from './accounts';
|
||||
import type { ChatMessage } from 'soapbox/types/entities';
|
||||
|
||||
export const messageExpirationOptions = [604800, 1209600, 2592000, 7776000];
|
||||
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
import { Record as ImmutableRecord, Set as ImmutableSet } from 'immutable';
|
||||
|
||||
import { ChatMessage } from 'soapbox/types/entities';
|
||||
|
||||
import {
|
||||
REPORT_INIT,
|
||||
REPORT_SUBMIT_REQUEST,
|
||||
|
@ -16,6 +14,7 @@ import {
|
|||
} from '../actions/reports';
|
||||
|
||||
import type { AnyAction } from 'redux';
|
||||
import type { ChatMessage } from 'soapbox/types/entities';
|
||||
|
||||
const NewReportRecord = ImmutableRecord({
|
||||
isSubmitting: false,
|
||||
|
|
|
@ -46,7 +46,7 @@ import type { APIEntity } from 'soapbox/types/entities';
|
|||
|
||||
const domParser = new DOMParser();
|
||||
|
||||
type StatusRecord = ReturnType<typeof normalizeStatus>;
|
||||
export type StatusRecord = ReturnType<typeof normalizeStatus>;
|
||||
type APIEntities = Array<APIEntity>;
|
||||
|
||||
type State = ImmutableMap<string, ReducerStatus>;
|
||||
|
|
|
@ -4,11 +4,12 @@ import sumBy from 'lodash/sumBy';
|
|||
import { normalizeChatMessage } from 'soapbox/normalizers';
|
||||
import { ChatKeys } from 'soapbox/queries/chats';
|
||||
import { queryClient } from 'soapbox/queries/client';
|
||||
import { Chat, ChatMessage } from 'soapbox/types/entities';
|
||||
|
||||
import { compareDate } from './comparators';
|
||||
import { appendPageItem, flattenPages, PaginatedResult, sortQueryData, updatePageItem } from './queries';
|
||||
|
||||
import type { Chat, ChatMessage } from 'soapbox/types/entities';
|
||||
|
||||
interface ChatPayload extends Omit<Chat, 'last_message'> {
|
||||
last_message: ChatMessage | null
|
||||
}
|
||||
|
@ -91,4 +92,4 @@ const updateChatMessage = (chatMessage: ChatMessage) => updatePageItem(
|
|||
(o, n) => o.id === n.id,
|
||||
);
|
||||
|
||||
export { updateChatListItem, updateChatMessage, getUnreadChatsCount, reOrderChatListItems };
|
||||
export { updateChatListItem, updateChatMessage, getUnreadChatsCount, reOrderChatListItems };
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
import {
|
||||
Map as ImmutableMap,
|
||||
List as ImmutableList,
|
||||
} from 'immutable';
|
||||
import { Map as ImmutableMap, List as ImmutableList } from 'immutable';
|
||||
|
||||
import type { StatusRecord } from 'soapbox/reducers/statuses';
|
||||
import type { Me } from 'soapbox/types/soapbox';
|
||||
|
||||
// https://emojipedia.org/facebook
|
||||
|
@ -74,7 +72,7 @@ export const reduceEmoji = (emojiReacts: ImmutableList<EmojiReact>, favouritesCo
|
|||
allowedEmoji,
|
||||
));
|
||||
|
||||
export const getReactForStatus = (status: any, allowedEmoji = ALLOWED_EMOJI): string | undefined => {
|
||||
export const getReactForStatus = (status: StatusRecord, allowedEmoji = ALLOWED_EMOJI): string | undefined => {
|
||||
const result = reduceEmoji(
|
||||
status.pleroma.get('emoji_reactions', ImmutableList()),
|
||||
status.favourites_count || 0,
|
||||
|
|
|
@ -26,7 +26,7 @@ const EXCLUDE_TYPES = [
|
|||
type NotificationType = typeof NOTIFICATION_TYPES[number];
|
||||
|
||||
/** Ensure the Notification is a valid, known type. */
|
||||
const validType = (type: string): type is NotificationType => NOTIFICATION_TYPES.includes(type as any);
|
||||
const validType = (type: string): type is NotificationType => NOTIFICATION_TYPES.includes(type as NotificationType);
|
||||
|
||||
export {
|
||||
NOTIFICATION_TYPES,
|
||||
|
|
|
@ -10,7 +10,7 @@ const COUNTRY_CODES = [
|
|||
type CountryCode = typeof COUNTRY_CODES[number];
|
||||
|
||||
/** Check whether a given value is a country code. */
|
||||
const isCountryCode = (value: any): value is CountryCode => COUNTRY_CODES.includes(value);
|
||||
const isCountryCode = (value: string): value is CountryCode => COUNTRY_CODES.includes(value as CountryCode);
|
||||
|
||||
export {
|
||||
COUNTRY_CODES,
|
||||
|
|
|
@ -77,7 +77,7 @@ const removePageItem = <T>(queryKey: QueryKey, itemToRemove: T, isItem: (item: T
|
|||
};
|
||||
|
||||
const paginateQueryData = <T>(array: T[] | undefined) => {
|
||||
return array?.reduce((resultArray: any, item: any, index: any) => {
|
||||
return array?.reduce((resultArray: T[][], item: T, index: number) => {
|
||||
const chunkIndex = Math.floor(index / 20);
|
||||
|
||||
if (!resultArray[chunkIndex]) {
|
||||
|
@ -97,7 +97,7 @@ const sortQueryData = <T>(queryKey: QueryKey, comparator: (a: T, b: T) => number
|
|||
const flattenedQueryData = flattenPages(nextResult);
|
||||
const sortedQueryData = flattenedQueryData?.sort(comparator);
|
||||
const paginatedPages = paginateQueryData(sortedQueryData);
|
||||
const newPages = paginatedPages.map((page: T, idx: number) => ({
|
||||
const newPages = paginatedPages!.map((page: T[], idx: number) => ({
|
||||
...prevResult.pages[idx],
|
||||
result: page,
|
||||
}));
|
||||
|
|
Ładowanie…
Reference in New Issue