frontend-rw #1
3 changed files with 22 additions and 211 deletions
|
@ -5,19 +5,7 @@ import { normalizeAccount } from 'pl-fe/normalizers/account';
|
||||||
import toast from 'pl-fe/toast';
|
import toast from 'pl-fe/toast';
|
||||||
|
|
||||||
import type { Account, PaginatedResponse } from 'pl-api';
|
import type { Account, PaginatedResponse } from 'pl-api';
|
||||||
import type { RootState } from 'pl-fe/store';
|
import type { AppDispatch, RootState } from 'pl-fe/store';
|
||||||
|
|
||||||
const EXPORT_FOLLOWS_REQUEST = 'EXPORT_FOLLOWS_REQUEST' as const;
|
|
||||||
const EXPORT_FOLLOWS_SUCCESS = 'EXPORT_FOLLOWS_SUCCESS' as const;
|
|
||||||
const EXPORT_FOLLOWS_FAIL = 'EXPORT_FOLLOWS_FAIL' as const;
|
|
||||||
|
|
||||||
const EXPORT_BLOCKS_REQUEST = 'EXPORT_BLOCKS_REQUEST' as const;
|
|
||||||
const EXPORT_BLOCKS_SUCCESS = 'EXPORT_BLOCKS_SUCCESS' as const;
|
|
||||||
const EXPORT_BLOCKS_FAIL = 'EXPORT_BLOCKS_FAIL' as const;
|
|
||||||
|
|
||||||
const EXPORT_MUTES_REQUEST = 'EXPORT_MUTES_REQUEST' as const;
|
|
||||||
const EXPORT_MUTES_SUCCESS = 'EXPORT_MUTES_SUCCESS' as const;
|
|
||||||
const EXPORT_MUTES_FAIL = 'EXPORT_MUTES_FAIL' as const;
|
|
||||||
|
|
||||||
const messages = defineMessages({
|
const messages = defineMessages({
|
||||||
blocksSuccess: { id: 'export_data.success.blocks', defaultMessage: 'Blocks exported successfully' },
|
blocksSuccess: { id: 'export_data.success.blocks', defaultMessage: 'Blocks exported successfully' },
|
||||||
|
@ -25,20 +13,6 @@ const messages = defineMessages({
|
||||||
mutesSuccess: { id: 'export_data.success.mutes', defaultMessage: 'Mutes exported successfully' },
|
mutesSuccess: { id: 'export_data.success.mutes', defaultMessage: 'Mutes exported successfully' },
|
||||||
});
|
});
|
||||||
|
|
||||||
type ExportDataAction = {
|
|
||||||
type: typeof EXPORT_FOLLOWS_REQUEST
|
|
||||||
| typeof EXPORT_BLOCKS_REQUEST
|
|
||||||
| typeof EXPORT_MUTES_REQUEST
|
|
||||||
| typeof EXPORT_FOLLOWS_SUCCESS
|
|
||||||
| typeof EXPORT_BLOCKS_SUCCESS
|
|
||||||
| typeof EXPORT_MUTES_SUCCESS;
|
|
||||||
} | {
|
|
||||||
type: typeof EXPORT_FOLLOWS_FAIL
|
|
||||||
| typeof EXPORT_BLOCKS_FAIL
|
|
||||||
| typeof EXPORT_MUTES_FAIL;
|
|
||||||
error?: unknown;
|
|
||||||
}
|
|
||||||
|
|
||||||
const fileExport = (content: string, fileName: string) => {
|
const fileExport = (content: string, fileName: string) => {
|
||||||
const fileToDownload = document.createElement('a');
|
const fileToDownload = document.createElement('a');
|
||||||
|
|
||||||
|
@ -62,8 +36,7 @@ const listAccounts = async (response: PaginatedResponse<Account>) => {
|
||||||
return Array.from(new Set(accounts));
|
return Array.from(new Set(accounts));
|
||||||
};
|
};
|
||||||
|
|
||||||
const exportFollows = () => async (dispatch: React.Dispatch<ExportDataAction>, getState: () => RootState) => {
|
const exportFollows = () => async (_dispatch: AppDispatch, getState: () => RootState) => {
|
||||||
dispatch({ type: EXPORT_FOLLOWS_REQUEST });
|
|
||||||
const me = getState().me;
|
const me = getState().me;
|
||||||
if (!me) return;
|
if (!me) return;
|
||||||
|
|
||||||
|
@ -75,52 +48,31 @@ const exportFollows = () => async (dispatch: React.Dispatch<ExportDataAction>, g
|
||||||
fileExport(followings.join('\n'), 'export_followings.csv');
|
fileExport(followings.join('\n'), 'export_followings.csv');
|
||||||
|
|
||||||
toast.success(messages.followersSuccess);
|
toast.success(messages.followersSuccess);
|
||||||
dispatch({ type: EXPORT_FOLLOWS_SUCCESS });
|
|
||||||
}).catch(error => {
|
|
||||||
dispatch({ type: EXPORT_FOLLOWS_FAIL, error });
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const exportBlocks = () => (dispatch: React.Dispatch<ExportDataAction>, getState: () => RootState) => {
|
const exportBlocks = () => (_dispatch: AppDispatch, getState: () => RootState) => {
|
||||||
dispatch({ type: EXPORT_BLOCKS_REQUEST });
|
|
||||||
return getClient(getState()).filtering.getBlocks({ limit: 40 })
|
return getClient(getState()).filtering.getBlocks({ limit: 40 })
|
||||||
.then(listAccounts)
|
.then(listAccounts)
|
||||||
.then((blocks) => {
|
.then((blocks) => {
|
||||||
fileExport(blocks.join('\n'), 'export_block.csv');
|
fileExport(blocks.join('\n'), 'export_block.csv');
|
||||||
|
|
||||||
toast.success(messages.blocksSuccess);
|
toast.success(messages.blocksSuccess);
|
||||||
dispatch({ type: EXPORT_BLOCKS_SUCCESS });
|
|
||||||
}).catch(error => {
|
|
||||||
dispatch({ type: EXPORT_BLOCKS_FAIL, error });
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const exportMutes = () => (dispatch: React.Dispatch<ExportDataAction>, getState: () => RootState) => {
|
const exportMutes = () => (_dispatch: AppDispatch, getState: () => RootState) => {
|
||||||
dispatch({ type: EXPORT_MUTES_REQUEST });
|
|
||||||
return getClient(getState()).filtering.getMutes({ limit: 40 })
|
return getClient(getState()).filtering.getMutes({ limit: 40 })
|
||||||
.then(listAccounts)
|
.then(listAccounts)
|
||||||
.then((mutes) => {
|
.then((mutes) => {
|
||||||
fileExport(mutes.join('\n'), 'export_mutes.csv');
|
fileExport(mutes.join('\n'), 'export_mutes.csv');
|
||||||
|
|
||||||
toast.success(messages.mutesSuccess);
|
toast.success(messages.mutesSuccess);
|
||||||
dispatch({ type: EXPORT_MUTES_SUCCESS });
|
|
||||||
}).catch(error => {
|
|
||||||
dispatch({ type: EXPORT_MUTES_FAIL, error });
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export {
|
export {
|
||||||
EXPORT_FOLLOWS_REQUEST,
|
|
||||||
EXPORT_FOLLOWS_SUCCESS,
|
|
||||||
EXPORT_FOLLOWS_FAIL,
|
|
||||||
EXPORT_BLOCKS_REQUEST,
|
|
||||||
EXPORT_BLOCKS_SUCCESS,
|
|
||||||
EXPORT_BLOCKS_FAIL,
|
|
||||||
EXPORT_MUTES_REQUEST,
|
|
||||||
EXPORT_MUTES_SUCCESS,
|
|
||||||
EXPORT_MUTES_FAIL,
|
|
||||||
exportFollows,
|
exportFollows,
|
||||||
exportBlocks,
|
exportBlocks,
|
||||||
exportMutes,
|
exportMutes,
|
||||||
type ExportDataAction,
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -8,25 +8,7 @@ import { getClient } from '../api';
|
||||||
import type { Filter, FilterContext } from 'pl-api';
|
import type { Filter, FilterContext } from 'pl-api';
|
||||||
import type { AppDispatch, RootState } from 'pl-fe/store';
|
import type { AppDispatch, RootState } from 'pl-fe/store';
|
||||||
|
|
||||||
const FILTERS_FETCH_REQUEST = 'FILTERS_FETCH_REQUEST' as const;
|
|
||||||
const FILTERS_FETCH_SUCCESS = 'FILTERS_FETCH_SUCCESS' as const;
|
const FILTERS_FETCH_SUCCESS = 'FILTERS_FETCH_SUCCESS' as const;
|
||||||
const FILTERS_FETCH_FAIL = 'FILTERS_FETCH_FAIL' as const;
|
|
||||||
|
|
||||||
const FILTER_FETCH_REQUEST = 'FILTER_FETCH_REQUEST' as const;
|
|
||||||
const FILTER_FETCH_SUCCESS = 'FILTER_FETCH_SUCCESS' as const;
|
|
||||||
const FILTER_FETCH_FAIL = 'FILTER_FETCH_FAIL' as const;
|
|
||||||
|
|
||||||
const FILTERS_CREATE_REQUEST = 'FILTERS_CREATE_REQUEST' as const;
|
|
||||||
const FILTERS_CREATE_SUCCESS = 'FILTERS_CREATE_SUCCESS' as const;
|
|
||||||
const FILTERS_CREATE_FAIL = 'FILTERS_CREATE_FAIL' as const;
|
|
||||||
|
|
||||||
const FILTERS_UPDATE_REQUEST = 'FILTERS_UPDATE_REQUEST' as const;
|
|
||||||
const FILTERS_UPDATE_SUCCESS = 'FILTERS_UPDATE_SUCCESS' as const;
|
|
||||||
const FILTERS_UPDATE_FAIL = 'FILTERS_UPDATE_FAIL' as const;
|
|
||||||
|
|
||||||
const FILTERS_DELETE_REQUEST = 'FILTERS_DELETE_REQUEST' as const;
|
|
||||||
const FILTERS_DELETE_SUCCESS = 'FILTERS_DELETE_SUCCESS' as const;
|
|
||||||
const FILTERS_DELETE_FAIL = 'FILTERS_DELETE_FAIL' as const;
|
|
||||||
|
|
||||||
const messages = defineMessages({
|
const messages = defineMessages({
|
||||||
added: { id: 'filters.added', defaultMessage: 'Filter added.' },
|
added: { id: 'filters.added', defaultMessage: 'Filter added.' },
|
||||||
|
@ -39,130 +21,59 @@ const fetchFilters = () =>
|
||||||
(dispatch: AppDispatch, getState: () => RootState) => {
|
(dispatch: AppDispatch, getState: () => RootState) => {
|
||||||
if (!isLoggedIn(getState)) return;
|
if (!isLoggedIn(getState)) return;
|
||||||
|
|
||||||
dispatch<FiltersAction>({
|
|
||||||
type: FILTERS_FETCH_REQUEST,
|
|
||||||
});
|
|
||||||
|
|
||||||
return getClient(getState).filtering.getFilters()
|
return getClient(getState).filtering.getFilters()
|
||||||
.then((data) => dispatch<FiltersAction>({
|
.then((data) => ({
|
||||||
type: FILTERS_FETCH_SUCCESS,
|
|
||||||
filters: data,
|
filters: data,
|
||||||
}))
|
}))
|
||||||
.catch(error => dispatch<FiltersAction>({
|
.catch(error => ({
|
||||||
type: FILTERS_FETCH_FAIL,
|
|
||||||
error,
|
error,
|
||||||
skipAlert: true,
|
|
||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
|
|
||||||
const fetchFilter = (filterId: string) =>
|
const fetchFilter = (filterId: string) =>
|
||||||
(dispatch: AppDispatch, getState: () => RootState) => {
|
(dispatch: AppDispatch, getState: () => RootState) =>
|
||||||
dispatch<FiltersAction>({ type: FILTER_FETCH_REQUEST });
|
getClient(getState).filtering.getFilter(filterId);
|
||||||
|
|
||||||
return getClient(getState).filtering.getFilter(filterId)
|
|
||||||
.then((data) => {
|
|
||||||
dispatch<FiltersAction>({
|
|
||||||
type: FILTER_FETCH_SUCCESS,
|
|
||||||
filter: data,
|
|
||||||
});
|
|
||||||
|
|
||||||
return data;
|
|
||||||
})
|
|
||||||
.catch(error => {
|
|
||||||
dispatch<FiltersAction>({
|
|
||||||
type: FILTER_FETCH_FAIL,
|
|
||||||
error,
|
|
||||||
skipAlert: true,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
const createFilter = (title: string, expires_in: number | undefined, context: Array<FilterContext>, hide: boolean, keywords_attributes: FilterKeywords) =>
|
const createFilter = (title: string, expires_in: number | undefined, context: Array<FilterContext>, hide: boolean, keywords_attributes: FilterKeywords) =>
|
||||||
(dispatch: AppDispatch, getState: () => RootState) => {
|
(dispatch: AppDispatch, getState: () => RootState) =>
|
||||||
dispatch<FiltersAction>({ type: FILTERS_CREATE_REQUEST });
|
getClient(getState).filtering.createFilter({
|
||||||
|
|
||||||
return getClient(getState).filtering.createFilter({
|
|
||||||
title,
|
title,
|
||||||
context,
|
context,
|
||||||
filter_action: hide ? 'hide' : 'warn',
|
filter_action: hide ? 'hide' : 'warn',
|
||||||
expires_in,
|
expires_in,
|
||||||
keywords_attributes,
|
keywords_attributes,
|
||||||
}).then(response => {
|
}).then(response => {
|
||||||
dispatch<FiltersAction>({ type: FILTERS_CREATE_SUCCESS, filter: response });
|
|
||||||
toast.success(messages.added);
|
toast.success(messages.added);
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
}).catch(error => {
|
|
||||||
dispatch<FiltersAction>({ type: FILTERS_CREATE_FAIL, error });
|
|
||||||
});
|
});
|
||||||
};
|
|
||||||
|
|
||||||
const updateFilter = (filterId: string, title: string, expires_in: number | undefined, context: Array<FilterContext>, hide: boolean, keywords_attributes: FilterKeywords) =>
|
const updateFilter = (filterId: string, title: string, expires_in: number | undefined, context: Array<FilterContext>, hide: boolean, keywords_attributes: FilterKeywords) =>
|
||||||
(dispatch: AppDispatch, getState: () => RootState) => {
|
(dispatch: AppDispatch, getState: () => RootState) =>
|
||||||
dispatch<FiltersAction>({ type: FILTERS_UPDATE_REQUEST });
|
getClient(getState).filtering.updateFilter(filterId, {
|
||||||
|
|
||||||
return getClient(getState).filtering.updateFilter(filterId, {
|
|
||||||
title,
|
title,
|
||||||
context,
|
context,
|
||||||
filter_action: hide ? 'hide' : 'warn',
|
filter_action: hide ? 'hide' : 'warn',
|
||||||
expires_in,
|
expires_in,
|
||||||
keywords_attributes,
|
keywords_attributes,
|
||||||
}).then(response => {
|
}).then(response => {
|
||||||
dispatch<FiltersAction>({ type: FILTERS_UPDATE_SUCCESS, filter: response });
|
|
||||||
toast.success(messages.added);
|
toast.success(messages.added);
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
}).catch(error => {
|
|
||||||
dispatch<FiltersAction>({ type: FILTERS_UPDATE_FAIL, filterId, error });
|
|
||||||
});
|
});
|
||||||
};
|
|
||||||
|
|
||||||
const deleteFilter = (filterId: string) =>
|
const deleteFilter = (filterId: string) =>
|
||||||
(dispatch: AppDispatch, getState: () => RootState) => {
|
(dispatch: AppDispatch, getState: () => RootState) =>
|
||||||
dispatch<FiltersAction>({ type: FILTERS_DELETE_REQUEST });
|
getClient(getState).filtering.deleteFilter(filterId).then(response => {
|
||||||
return getClient(getState).filtering.deleteFilter(filterId).then(response => {
|
|
||||||
dispatch<FiltersAction>({ type: FILTERS_DELETE_SUCCESS, filterId });
|
|
||||||
toast.success(messages.removed);
|
toast.success(messages.removed);
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
}).catch(error => {
|
|
||||||
dispatch<FiltersAction>({ type: FILTERS_DELETE_FAIL, filterId, error });
|
|
||||||
});
|
});
|
||||||
};
|
|
||||||
|
|
||||||
type FiltersAction =
|
type FiltersAction = { type: typeof FILTERS_FETCH_SUCCESS; filters: Array<Filter> };
|
||||||
| { type: typeof FILTERS_FETCH_REQUEST }
|
|
||||||
| { type: typeof FILTERS_FETCH_SUCCESS; filters: Array<Filter> }
|
|
||||||
| { type: typeof FILTERS_FETCH_FAIL; error: unknown; skipAlert: true }
|
|
||||||
| { type: typeof FILTER_FETCH_REQUEST }
|
|
||||||
| { type: typeof FILTER_FETCH_SUCCESS; filter: Filter }
|
|
||||||
| { type: typeof FILTER_FETCH_FAIL; error: unknown; skipAlert: true }
|
|
||||||
| { type: typeof FILTERS_CREATE_REQUEST }
|
|
||||||
| { type: typeof FILTERS_CREATE_SUCCESS; filter: Filter }
|
|
||||||
| { type: typeof FILTERS_CREATE_FAIL; error: unknown }
|
|
||||||
| { type: typeof FILTERS_UPDATE_REQUEST }
|
|
||||||
| { type: typeof FILTERS_UPDATE_SUCCESS; filter: Filter }
|
|
||||||
| { type: typeof FILTERS_UPDATE_FAIL; filterId: string; error: unknown }
|
|
||||||
| { type: typeof FILTERS_DELETE_REQUEST }
|
|
||||||
| { type: typeof FILTERS_DELETE_SUCCESS; filterId: string }
|
|
||||||
| { type: typeof FILTERS_DELETE_FAIL; filterId: string; error: unknown }
|
|
||||||
|
|
||||||
export {
|
export {
|
||||||
FILTERS_FETCH_REQUEST,
|
|
||||||
FILTERS_FETCH_SUCCESS,
|
FILTERS_FETCH_SUCCESS,
|
||||||
FILTERS_FETCH_FAIL,
|
|
||||||
FILTER_FETCH_REQUEST,
|
|
||||||
FILTER_FETCH_SUCCESS,
|
|
||||||
FILTER_FETCH_FAIL,
|
|
||||||
FILTERS_CREATE_REQUEST,
|
|
||||||
FILTERS_CREATE_SUCCESS,
|
|
||||||
FILTERS_CREATE_FAIL,
|
|
||||||
FILTERS_UPDATE_REQUEST,
|
|
||||||
FILTERS_UPDATE_SUCCESS,
|
|
||||||
FILTERS_UPDATE_FAIL,
|
|
||||||
FILTERS_DELETE_REQUEST,
|
|
||||||
FILTERS_DELETE_SUCCESS,
|
|
||||||
FILTERS_DELETE_FAIL,
|
|
||||||
fetchFilters,
|
fetchFilters,
|
||||||
fetchFilter,
|
fetchFilter,
|
||||||
createFilter,
|
createFilter,
|
||||||
|
|
|
@ -4,35 +4,7 @@ import toast from 'pl-fe/toast';
|
||||||
|
|
||||||
import { getClient } from '../api';
|
import { getClient } from '../api';
|
||||||
|
|
||||||
import type { RootState } from 'pl-fe/store';
|
import type { AppDispatch, RootState } from 'pl-fe/store';
|
||||||
|
|
||||||
const IMPORT_FOLLOWS_REQUEST = 'IMPORT_FOLLOWS_REQUEST' as const;
|
|
||||||
const IMPORT_FOLLOWS_SUCCESS = 'IMPORT_FOLLOWS_SUCCESS' as const;
|
|
||||||
const IMPORT_FOLLOWS_FAIL = 'IMPORT_FOLLOWS_FAIL' as const;
|
|
||||||
|
|
||||||
const IMPORT_BLOCKS_REQUEST = 'IMPORT_BLOCKS_REQUEST' as const;
|
|
||||||
const IMPORT_BLOCKS_SUCCESS = 'IMPORT_BLOCKS_SUCCESS' as const;
|
|
||||||
const IMPORT_BLOCKS_FAIL = 'IMPORT_BLOCKS_FAIL' as const;
|
|
||||||
|
|
||||||
const IMPORT_MUTES_REQUEST = 'IMPORT_MUTES_REQUEST' as const;
|
|
||||||
const IMPORT_MUTES_SUCCESS = 'IMPORT_MUTES_SUCCESS' as const;
|
|
||||||
const IMPORT_MUTES_FAIL = 'IMPORT_MUTES_FAIL' as const;
|
|
||||||
|
|
||||||
type ImportDataActions = {
|
|
||||||
type: typeof IMPORT_FOLLOWS_REQUEST
|
|
||||||
| typeof IMPORT_BLOCKS_REQUEST
|
|
||||||
| typeof IMPORT_MUTES_REQUEST;
|
|
||||||
} | {
|
|
||||||
type: typeof IMPORT_FOLLOWS_SUCCESS
|
|
||||||
| typeof IMPORT_BLOCKS_SUCCESS
|
|
||||||
| typeof IMPORT_MUTES_SUCCESS;
|
|
||||||
response?: string;
|
|
||||||
} | {
|
|
||||||
type: | typeof IMPORT_FOLLOWS_FAIL
|
|
||||||
| typeof IMPORT_BLOCKS_FAIL
|
|
||||||
| typeof IMPORT_MUTES_FAIL;
|
|
||||||
error?: unknown;
|
|
||||||
}
|
|
||||||
|
|
||||||
const messages = defineMessages({
|
const messages = defineMessages({
|
||||||
blocksSuccess: { id: 'import_data.success.blocks', defaultMessage: 'Blocks imported successfully' },
|
blocksSuccess: { id: 'import_data.success.blocks', defaultMessage: 'Blocks imported successfully' },
|
||||||
|
@ -41,48 +13,24 @@ const messages = defineMessages({
|
||||||
});
|
});
|
||||||
|
|
||||||
const importFollows = (list: File | string, overwrite?: boolean) =>
|
const importFollows = (list: File | string, overwrite?: boolean) =>
|
||||||
(dispatch: React.Dispatch<ImportDataActions>, getState: () => RootState) => {
|
(dispatch: AppDispatch, getState: () => RootState) =>
|
||||||
dispatch({ type: IMPORT_FOLLOWS_REQUEST });
|
getClient(getState).settings.importFollows(list, overwrite ? 'overwrite' : 'merge').then(response => {
|
||||||
return getClient(getState).settings.importFollows(list, overwrite ? 'overwrite' : 'merge').then(response => {
|
|
||||||
toast.success(messages.followersSuccess);
|
toast.success(messages.followersSuccess);
|
||||||
dispatch({ type: IMPORT_FOLLOWS_SUCCESS, response });
|
|
||||||
}).catch(error => {
|
|
||||||
dispatch({ type: IMPORT_FOLLOWS_FAIL, error });
|
|
||||||
});
|
});
|
||||||
};
|
|
||||||
|
|
||||||
const importBlocks = (list: File | string, overwrite?: boolean) =>
|
const importBlocks = (list: File | string, overwrite?: boolean) =>
|
||||||
(dispatch: React.Dispatch<ImportDataActions>, getState: () => RootState) => {
|
(dispatch: AppDispatch, getState: () => RootState) =>
|
||||||
dispatch({ type: IMPORT_BLOCKS_REQUEST });
|
getClient(getState).settings.importBlocks(list, overwrite ? 'overwrite' : 'merge').then(response => {
|
||||||
return getClient(getState).settings.importBlocks(list, overwrite ? 'overwrite' : 'merge').then(response => {
|
|
||||||
toast.success(messages.blocksSuccess);
|
toast.success(messages.blocksSuccess);
|
||||||
dispatch({ type: IMPORT_BLOCKS_SUCCESS, response });
|
|
||||||
}).catch(error => {
|
|
||||||
dispatch({ type: IMPORT_BLOCKS_FAIL, error });
|
|
||||||
});
|
});
|
||||||
};
|
|
||||||
|
|
||||||
const importMutes = (list: File | string) =>
|
const importMutes = (list: File | string) =>
|
||||||
(dispatch: React.Dispatch<ImportDataActions>, getState: () => RootState) => {
|
(dispatch: AppDispatch, getState: () => RootState) =>
|
||||||
dispatch({ type: IMPORT_MUTES_REQUEST });
|
getClient(getState).settings.importMutes(list).then(response => {
|
||||||
return getClient(getState).settings.importMutes(list).then(response => {
|
|
||||||
toast.success(messages.mutesSuccess);
|
toast.success(messages.mutesSuccess);
|
||||||
dispatch({ type: IMPORT_MUTES_SUCCESS, response });
|
|
||||||
}).catch(error => {
|
|
||||||
dispatch({ type: IMPORT_MUTES_FAIL, error });
|
|
||||||
});
|
});
|
||||||
};
|
|
||||||
|
|
||||||
export {
|
export {
|
||||||
IMPORT_FOLLOWS_REQUEST,
|
|
||||||
IMPORT_FOLLOWS_SUCCESS,
|
|
||||||
IMPORT_FOLLOWS_FAIL,
|
|
||||||
IMPORT_BLOCKS_REQUEST,
|
|
||||||
IMPORT_BLOCKS_SUCCESS,
|
|
||||||
IMPORT_BLOCKS_FAIL,
|
|
||||||
IMPORT_MUTES_REQUEST,
|
|
||||||
IMPORT_MUTES_SUCCESS,
|
|
||||||
IMPORT_MUTES_FAIL,
|
|
||||||
importFollows,
|
importFollows,
|
||||||
importBlocks,
|
importBlocks,
|
||||||
importMutes,
|
importMutes,
|
||||||
|
|
Loading…
Reference in a new issue