From 24810f83c0e07cb0d1902bd628a1547546141e16 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Fri, 17 Apr 2020 16:12:33 -0500 Subject: [PATCH] fetchMastoPreferences() action for pulling /api/v1/preferences --- app/gabsocial/actions/preferences.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 app/gabsocial/actions/preferences.js diff --git a/app/gabsocial/actions/preferences.js b/app/gabsocial/actions/preferences.js new file mode 100644 index 000000000..1395ce1da --- /dev/null +++ b/app/gabsocial/actions/preferences.js @@ -0,0 +1,23 @@ +import api from '../api'; + +export const MASTO_PREFS_FETCH_SUCCESS = 'MASTO_PREFS_FETCH_SUCCESS'; + +export const FE_NAME = 'soapbox_fe'; + +export function fetchMastoPreferences() { + return (dispatch, getState) => { + api(getState).get('/api/v1/preferences').then(response => { + dispatch(mastoFetchPrefsSuccess(response.data)); + }).catch(e => { + console.error(e); + console.error('Could not fetch Mastodon preferences.'); + }); + }; +} + +export function mastoFetchPrefsSuccess(prefs) { + return { + type: MASTO_PREFS_FETCH_SUCCESS, + prefs, + }; +}