pleroma/app/soapbox/actions/remote_timeline.ts
marcin mikołajczak cfacc23f5c Actions: TypeScript
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
2022-06-15 22:11:36 +02:00

29 lines
882 B
TypeScript

import { getSettings, changeSetting } from 'soapbox/actions/settings';
import type { AppDispatch, RootState } from 'soapbox/store';
const getPinnedHosts = (state: RootState) => {
const settings = getSettings(state);
return settings.getIn(['remote_timeline', 'pinnedHosts']);
};
const pinHost = (host: string) =>
(dispatch: AppDispatch, getState: () => RootState) => {
const state = getState();
const pinnedHosts = getPinnedHosts(state);
return dispatch(changeSetting(['remote_timeline', 'pinnedHosts'], pinnedHosts.push(host)));
};
const unpinHost = (host) =>
(dispatch: AppDispatch, getState: () => RootState) => {
const state = getState();
const pinnedHosts = getPinnedHosts(state);
return dispatch(changeSetting(['remote_timeline', 'pinnedHosts'], pinnedHosts.filter((value) => value !== host)));
};
export {
pinHost,
unpinHost,
};