2021-08-11 16:23:42 -07:00
|
|
|
import { getSettings, changeSetting } from 'soapbox/actions/settings';
|
|
|
|
|
2021-08-11 17:38:25 -07:00
|
|
|
const getPinnedHosts = state => {
|
2021-08-11 16:23:42 -07:00
|
|
|
const settings = getSettings(state);
|
|
|
|
return settings.getIn(['remote_timeline', 'pinnedHosts']);
|
|
|
|
};
|
|
|
|
|
|
|
|
export function pinHost(host) {
|
|
|
|
return (dispatch, getState) => {
|
|
|
|
const state = getState();
|
2021-08-11 17:38:25 -07:00
|
|
|
const pinnedHosts = getPinnedHosts(state);
|
2021-08-11 16:23:42 -07:00
|
|
|
|
|
|
|
return dispatch(changeSetting(['remote_timeline', 'pinnedHosts'], pinnedHosts.add(host)));
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export function unpinHost(host) {
|
|
|
|
return (dispatch, getState) => {
|
|
|
|
const state = getState();
|
2021-08-11 17:38:25 -07:00
|
|
|
const pinnedHosts = getPinnedHosts(state);
|
2021-08-11 16:23:42 -07:00
|
|
|
|
|
|
|
return dispatch(changeSetting(['remote_timeline', 'pinnedHosts'], pinnedHosts.delete(host)));
|
|
|
|
};
|
|
|
|
}
|