diff --git a/app/soapbox/actions/accounts.js b/app/soapbox/actions/accounts.js index 55e5926e4..725fb8130 100644 --- a/app/soapbox/actions/accounts.js +++ b/app/soapbox/actions/accounts.js @@ -6,6 +6,7 @@ import { importFetchedAccounts, importErrorWhileFetchingAccountByUsername, } from './importer'; +import { isLoggedIn } from 'soapbox/utils/accounts'; export const ACCOUNT_FETCH_REQUEST = 'ACCOUNT_FETCH_REQUEST'; export const ACCOUNT_FETCH_SUCCESS = 'ACCOUNT_FETCH_SUCCESS'; @@ -162,7 +163,7 @@ export function fetchAccountFail(id, error) { export function followAccount(id, reblogs = true) { return (dispatch, getState) => { - if (!getState().get('me')) return; + if (!isLoggedIn(getState)) return; const alreadyFollowing = getState().getIn(['relationships', id, 'following']); const locked = getState().getIn(['accounts', id, 'locked'], false); @@ -179,7 +180,7 @@ export function followAccount(id, reblogs = true) { export function unfollowAccount(id) { return (dispatch, getState) => { - if (!getState().get('me')) return; + if (!isLoggedIn(getState)) return; dispatch(unfollowAccountRequest(id)); @@ -245,7 +246,7 @@ export function unfollowAccountFail(error) { export function blockAccount(id) { return (dispatch, getState) => { - if (!getState().get('me')) return; + if (!isLoggedIn(getState)) return; dispatch(blockAccountRequest(id)); @@ -260,7 +261,7 @@ export function blockAccount(id) { export function unblockAccount(id) { return (dispatch, getState) => { - if (!getState().get('me')) return; + if (!isLoggedIn(getState)) return; dispatch(unblockAccountRequest(id)); @@ -318,7 +319,7 @@ export function unblockAccountFail(error) { export function muteAccount(id, notifications) { return (dispatch, getState) => { - if (!getState().get('me')) return; + if (!isLoggedIn(getState)) return; dispatch(muteAccountRequest(id)); @@ -333,7 +334,7 @@ export function muteAccount(id, notifications) { export function unmuteAccount(id) { return (dispatch, getState) => { - if (!getState().get('me')) return; + if (!isLoggedIn(getState)) return; dispatch(unmuteAccountRequest(id)); @@ -391,7 +392,7 @@ export function unmuteAccountFail(error) { export function fetchFollowers(id) { return (dispatch, getState) => { - if (!getState().get('me')) return; + if (!isLoggedIn(getState)) return; dispatch(fetchFollowersRequest(id)); @@ -433,7 +434,7 @@ export function fetchFollowersFail(id, error) { export function expandFollowers(id) { return (dispatch, getState) => { - if (!getState().get('me')) return; + if (!isLoggedIn(getState)) return; const url = getState().getIn(['user_lists', 'followers', id, 'next']); @@ -481,7 +482,7 @@ export function expandFollowersFail(id, error) { export function fetchFollowing(id) { return (dispatch, getState) => { - if (!getState().get('me')) return; + if (!isLoggedIn(getState)) return; dispatch(fetchFollowingRequest(id)); @@ -523,7 +524,7 @@ export function fetchFollowingFail(id, error) { export function expandFollowing(id) { return (dispatch, getState) => { - if (!getState().get('me')) return; + if (!isLoggedIn(getState)) return; const url = getState().getIn(['user_lists', 'following', id, 'next']); @@ -571,7 +572,7 @@ export function expandFollowingFail(id, error) { export function fetchRelationships(accountIds) { return (dispatch, getState) => { - if (!getState().get('me')) return; + if (!isLoggedIn(getState)) return; const loadedRelationships = getState().get('relationships'); const newAccountIds = accountIds.filter(id => loadedRelationships.get(id, null) === null); @@ -616,7 +617,7 @@ export function fetchRelationshipsFail(error) { export function fetchFollowRequests() { return (dispatch, getState) => { - if (!getState().get('me')) return; + if (!isLoggedIn(getState)) return; dispatch(fetchFollowRequestsRequest()); @@ -651,7 +652,7 @@ export function fetchFollowRequestsFail(error) { export function expandFollowRequests() { return (dispatch, getState) => { - if (!getState().get('me')) return; + if (!isLoggedIn(getState)) return; const url = getState().getIn(['user_lists', 'follow_requests', 'next']); @@ -692,7 +693,7 @@ export function expandFollowRequestsFail(error) { export function authorizeFollowRequest(id) { return (dispatch, getState) => { - if (!getState().get('me')) return; + if (!isLoggedIn(getState)) return; dispatch(authorizeFollowRequestRequest(id)); @@ -728,7 +729,7 @@ export function authorizeFollowRequestFail(id, error) { export function rejectFollowRequest(id) { return (dispatch, getState) => { - if (!getState().get('me')) return; + if (!isLoggedIn(getState)) return; dispatch(rejectFollowRequestRequest(id)); @@ -763,7 +764,7 @@ export function rejectFollowRequestFail(id, error) { export function pinAccount(id) { return (dispatch, getState) => { - if (!getState().get('me')) return; + if (!isLoggedIn(getState)) return; dispatch(pinAccountRequest(id)); @@ -777,7 +778,7 @@ export function pinAccount(id) { export function unpinAccount(id) { return (dispatch, getState) => { - if (!getState().get('me')) return; + if (!isLoggedIn(getState)) return; dispatch(unpinAccountRequest(id)); diff --git a/app/soapbox/actions/blocks.js b/app/soapbox/actions/blocks.js index d891999bb..66d13d4ec 100644 --- a/app/soapbox/actions/blocks.js +++ b/app/soapbox/actions/blocks.js @@ -1,6 +1,7 @@ import api, { getLinks } from '../api'; import { fetchRelationships } from './accounts'; import { importFetchedAccounts } from './importer'; +import { isLoggedIn } from 'soapbox/utils/accounts'; export const BLOCKS_FETCH_REQUEST = 'BLOCKS_FETCH_REQUEST'; export const BLOCKS_FETCH_SUCCESS = 'BLOCKS_FETCH_SUCCESS'; @@ -12,7 +13,7 @@ export const BLOCKS_EXPAND_FAIL = 'BLOCKS_EXPAND_FAIL'; export function fetchBlocks() { return (dispatch, getState) => { - if (!getState().get('me')) return; + if (!isLoggedIn(getState)) return; dispatch(fetchBlocksRequest()); @@ -48,7 +49,7 @@ export function fetchBlocksFail(error) { export function expandBlocks() { return (dispatch, getState) => { - if (!getState().get('me')) return; + if (!isLoggedIn(getState)) return; const url = getState().getIn(['user_lists', 'blocks', 'next']); diff --git a/app/soapbox/actions/compose.js b/app/soapbox/actions/compose.js index 782dee74a..f7af6de51 100644 --- a/app/soapbox/actions/compose.js +++ b/app/soapbox/actions/compose.js @@ -13,6 +13,7 @@ import { openModal, closeModal } from './modal'; import { getSettings } from './settings'; import { getFeatures } from 'soapbox/utils/features'; import { uploadMedia } from './media'; +import { isLoggedIn } from 'soapbox/utils/accounts'; let cancelFetchComposeSuggestionsAccounts; @@ -157,7 +158,7 @@ export function handleComposeSubmit(dispatch, getState, response, status) { export function submitCompose(routerHistory, group) { return function(dispatch, getState) { - if (!getState().get('me')) return; + if (!isLoggedIn(getState)) return; const status = getState().getIn(['compose', 'text'], ''); const media = getState().getIn(['compose', 'media_attachments']); @@ -216,7 +217,7 @@ export function submitComposeFail(error) { export function uploadCompose(files) { return function(dispatch, getState) { - if (!getState().get('me')) return; + if (!isLoggedIn(getState)) return; const uploadLimit = getFeatures(getState().get('instance')).attachmentLimit; const media = getState().getIn(['compose', 'media_attachments']); @@ -254,7 +255,7 @@ export function uploadCompose(files) { export function changeUploadCompose(id, params) { return (dispatch, getState) => { - if (!getState().get('me')) return; + if (!isLoggedIn(getState)) return; dispatch(changeUploadComposeRequest()); diff --git a/app/soapbox/actions/conversations.js b/app/soapbox/actions/conversations.js index fc1305156..c43fe3efb 100644 --- a/app/soapbox/actions/conversations.js +++ b/app/soapbox/actions/conversations.js @@ -4,6 +4,7 @@ import { importFetchedStatuses, importFetchedStatus, } from './importer'; +import { isLoggedIn } from 'soapbox/utils/accounts'; export const CONVERSATIONS_MOUNT = 'CONVERSATIONS_MOUNT'; export const CONVERSATIONS_UNMOUNT = 'CONVERSATIONS_UNMOUNT'; @@ -24,7 +25,7 @@ export const unmountConversations = () => ({ }); export const markConversationRead = conversationId => (dispatch, getState) => { - if (!getState().get('me')) return; + if (!isLoggedIn(getState)) return; dispatch({ type: CONVERSATIONS_READ, @@ -35,7 +36,7 @@ export const markConversationRead = conversationId => (dispatch, getState) => { }; export const expandConversations = ({ maxId } = {}) => (dispatch, getState) => { - if (!getState().get('me')) return; + if (!isLoggedIn(getState)) return; dispatch(expandConversationsRequest()); diff --git a/app/soapbox/actions/domain_blocks.js b/app/soapbox/actions/domain_blocks.js index a5ebb0c99..c8da042f0 100644 --- a/app/soapbox/actions/domain_blocks.js +++ b/app/soapbox/actions/domain_blocks.js @@ -1,4 +1,5 @@ import api, { getLinks } from '../api'; +import { isLoggedIn } from 'soapbox/utils/accounts'; export const DOMAIN_BLOCK_REQUEST = 'DOMAIN_BLOCK_REQUEST'; export const DOMAIN_BLOCK_SUCCESS = 'DOMAIN_BLOCK_SUCCESS'; @@ -18,7 +19,7 @@ export const DOMAIN_BLOCKS_EXPAND_FAIL = 'DOMAIN_BLOCKS_EXPAND_FAIL'; export function blockDomain(domain) { return (dispatch, getState) => { - if (!getState().get('me')) return; + if (!isLoggedIn(getState)) return; dispatch(blockDomainRequest(domain)); @@ -57,7 +58,7 @@ export function blockDomainFail(domain, error) { export function unblockDomain(domain) { return (dispatch, getState) => { - if (!getState().get('me')) return; + if (!isLoggedIn(getState)) return; dispatch(unblockDomainRequest(domain)); @@ -102,7 +103,7 @@ export function unblockDomainFail(domain, error) { export function fetchDomainBlocks() { return (dispatch, getState) => { - if (!getState().get('me')) return; + if (!isLoggedIn(getState)) return; dispatch(fetchDomainBlocksRequest()); @@ -138,7 +139,7 @@ export function fetchDomainBlocksFail(error) { export function expandDomainBlocks() { return (dispatch, getState) => { - if (!getState().get('me')) return; + if (!isLoggedIn(getState)) return; const url = getState().getIn(['domain_lists', 'blocks', 'next']); diff --git a/app/soapbox/actions/favourites.js b/app/soapbox/actions/favourites.js index d5b774f12..d5c362ebf 100644 --- a/app/soapbox/actions/favourites.js +++ b/app/soapbox/actions/favourites.js @@ -1,5 +1,6 @@ import api, { getLinks } from '../api'; import { importFetchedStatuses } from './importer'; +import { isLoggedIn } from 'soapbox/utils/accounts'; export const FAVOURITED_STATUSES_FETCH_REQUEST = 'FAVOURITED_STATUSES_FETCH_REQUEST'; export const FAVOURITED_STATUSES_FETCH_SUCCESS = 'FAVOURITED_STATUSES_FETCH_SUCCESS'; @@ -11,7 +12,7 @@ export const FAVOURITED_STATUSES_EXPAND_FAIL = 'FAVOURITED_STATUSES_EXPAND_FA export function fetchFavouritedStatuses() { return (dispatch, getState) => { - if (!getState().get('me')) return; + if (!isLoggedIn(getState)) return; if (getState().getIn(['status_lists', 'favourites', 'isLoading'])) { return; @@ -55,7 +56,7 @@ export function fetchFavouritedStatusesFail(error) { export function expandFavouritedStatuses() { return (dispatch, getState) => { - if (!getState().get('me')) return; + if (!isLoggedIn(getState)) return; const url = getState().getIn(['status_lists', 'favourites', 'next'], null); diff --git a/app/soapbox/actions/filters.js b/app/soapbox/actions/filters.js index e3ad557f5..9823509e6 100644 --- a/app/soapbox/actions/filters.js +++ b/app/soapbox/actions/filters.js @@ -1,5 +1,6 @@ import api from '../api'; import snackbar from 'soapbox/actions/snackbar'; +import { isLoggedIn } from 'soapbox/utils/accounts'; export const FILTERS_FETCH_REQUEST = 'FILTERS_FETCH_REQUEST'; export const FILTERS_FETCH_SUCCESS = 'FILTERS_FETCH_SUCCESS'; @@ -14,7 +15,7 @@ export const FILTERS_DELETE_SUCCESS = 'FILTERS_DELETE_SUCCESS'; export const FILTERS_DELETE_FAIL = 'FILTERS_DELETE_FAIL'; export const fetchFilters = () => (dispatch, getState) => { - if (!getState().get('me')) return; + if (!isLoggedIn(getState)) return; dispatch({ type: FILTERS_FETCH_REQUEST, diff --git a/app/soapbox/actions/group_editor.js b/app/soapbox/actions/group_editor.js index 4b9245081..b165e0236 100644 --- a/app/soapbox/actions/group_editor.js +++ b/app/soapbox/actions/group_editor.js @@ -1,4 +1,5 @@ import api from '../api'; +import { isLoggedIn } from 'soapbox/utils/accounts'; export const GROUP_CREATE_REQUEST = 'GROUP_CREATE_REQUEST'; export const GROUP_CREATE_SUCCESS = 'GROUP_CREATE_SUCCESS'; @@ -27,7 +28,7 @@ export const submit = (routerHistory) => (dispatch, getState) => { export const create = (title, description, coverImage, routerHistory) => (dispatch, getState) => { - if (!getState().get('me')) return; + if (!isLoggedIn(getState)) return; dispatch(createRequest()); @@ -62,7 +63,7 @@ export const createFail = error => ({ }); export const update = (groupId, title, description, coverImage, routerHistory) => (dispatch, getState) => { - if (!getState().get('me')) return; + if (!isLoggedIn(getState)) return; dispatch(updateRequest()); diff --git a/app/soapbox/actions/groups.js b/app/soapbox/actions/groups.js index 959b1b0b2..14a487370 100644 --- a/app/soapbox/actions/groups.js +++ b/app/soapbox/actions/groups.js @@ -1,6 +1,7 @@ import api, { getLinks } from '../api'; import { importFetchedAccounts } from './importer'; import { fetchRelationships } from './accounts'; +import { isLoggedIn } from 'soapbox/utils/accounts'; export const GROUP_FETCH_REQUEST = 'GROUP_FETCH_REQUEST'; export const GROUP_FETCH_SUCCESS = 'GROUP_FETCH_SUCCESS'; @@ -51,7 +52,7 @@ export const GROUP_REMOVE_STATUS_SUCCESS = 'GROUP_REMOVE_STATUS_SUCCESS'; export const GROUP_REMOVE_STATUS_FAIL = 'GROUP_REMOVE_STATUS_FAIL'; export const fetchGroup = id => (dispatch, getState) => { - if (!getState().get('me')) return; + if (!isLoggedIn(getState)) return; dispatch(fetchGroupRelationships([id])); @@ -84,7 +85,7 @@ export const fetchGroupFail = (id, error) => ({ export function fetchGroupRelationships(groupIds) { return (dispatch, getState) => { - if (!getState().get('me')) return; + if (!isLoggedIn(getState)) return; const loadedRelationships = getState().get('group_relationships'); const newGroupIds = groupIds.filter(id => loadedRelationships.get(id, null) === null); @@ -128,7 +129,7 @@ export function fetchGroupRelationshipsFail(error) { }; export const fetchGroups = (tab) => (dispatch, getState) => { - if (!getState().get('me')) return; + if (!isLoggedIn(getState)) return; dispatch(fetchGroupsRequest()); @@ -157,7 +158,7 @@ export const fetchGroupsFail = error => ({ export function joinGroup(id) { return (dispatch, getState) => { - if (!getState().get('me')) return; + if (!isLoggedIn(getState)) return; dispatch(joinGroupRequest(id)); @@ -171,7 +172,7 @@ export function joinGroup(id) { export function leaveGroup(id) { return (dispatch, getState) => { - if (!getState().get('me')) return; + if (!isLoggedIn(getState)) return; dispatch(leaveGroupRequest(id)); @@ -227,7 +228,7 @@ export function leaveGroupFail(error) { export function fetchMembers(id) { return (dispatch, getState) => { - if (!getState().get('me')) return; + if (!isLoggedIn(getState)) return; dispatch(fetchMembersRequest(id)); @@ -269,7 +270,7 @@ export function fetchMembersFail(id, error) { export function expandMembers(id) { return (dispatch, getState) => { - if (!getState().get('me')) return; + if (!isLoggedIn(getState)) return; const url = getState().getIn(['user_lists', 'groups', id, 'next']); @@ -317,7 +318,7 @@ export function expandMembersFail(id, error) { export function fetchRemovedAccounts(id) { return (dispatch, getState) => { - if (!getState().get('me')) return; + if (!isLoggedIn(getState)) return; dispatch(fetchRemovedAccountsRequest(id)); @@ -359,7 +360,7 @@ export function fetchRemovedAccountsFail(id, error) { export function expandRemovedAccounts(id) { return (dispatch, getState) => { - if (!getState().get('me')) return; + if (!isLoggedIn(getState)) return; const url = getState().getIn(['user_lists', 'groups_removed_accounts', id, 'next']); @@ -407,7 +408,7 @@ export function expandRemovedAccountsFail(id, error) { export function removeRemovedAccount(groupId, id) { return (dispatch, getState) => { - if (!getState().get('me')) return; + if (!isLoggedIn(getState)) return; dispatch(removeRemovedAccountRequest(groupId, id)); @@ -446,7 +447,7 @@ export function removeRemovedAccountFail(groupId, id, error) { export function createRemovedAccount(groupId, id) { return (dispatch, getState) => { - if (!getState().get('me')) return; + if (!isLoggedIn(getState)) return; dispatch(createRemovedAccountRequest(groupId, id)); @@ -485,7 +486,7 @@ export function createRemovedAccountFail(groupId, id, error) { export function groupRemoveStatus(groupId, id) { return (dispatch, getState) => { - if (!getState().get('me')) return; + if (!isLoggedIn(getState)) return; dispatch(groupRemoveStatusRequest(groupId, id)); diff --git a/app/soapbox/actions/interactions.js b/app/soapbox/actions/interactions.js index b07feac1b..bd6f3218d 100644 --- a/app/soapbox/actions/interactions.js +++ b/app/soapbox/actions/interactions.js @@ -1,6 +1,7 @@ import api from '../api'; import { importFetchedAccounts, importFetchedStatus } from './importer'; import snackbar from 'soapbox/actions/snackbar'; +import { isLoggedIn } from 'soapbox/utils/accounts'; export const REBLOG_REQUEST = 'REBLOG_REQUEST'; export const REBLOG_SUCCESS = 'REBLOG_SUCCESS'; @@ -44,7 +45,7 @@ export const UNBOOKMARK_FAIL = 'UNBOOKMARKED_FAIL'; export function reblog(status) { return function(dispatch, getState) { - if (!getState().get('me')) return; + if (!isLoggedIn(getState)) return; dispatch(reblogRequest(status)); @@ -61,7 +62,7 @@ export function reblog(status) { export function unreblog(status) { return (dispatch, getState) => { - if (!getState().get('me')) return; + if (!isLoggedIn(getState)) return; dispatch(unreblogRequest(status)); @@ -126,7 +127,7 @@ export function unreblogFail(status, error) { export function favourite(status) { return function(dispatch, getState) { - if (!getState().get('me')) return; + if (!isLoggedIn(getState)) return; dispatch(favouriteRequest(status)); @@ -141,7 +142,7 @@ export function favourite(status) { export function unfavourite(status) { return (dispatch, getState) => { - if (!getState().get('me')) return; + if (!isLoggedIn(getState)) return; dispatch(unfavouriteRequest(status)); @@ -280,7 +281,7 @@ export function unbookmarkFail(status, error) { export function fetchReblogs(id) { return (dispatch, getState) => { - if (!getState().get('me')) return; + if (!isLoggedIn(getState)) return; dispatch(fetchReblogsRequest(id)); @@ -317,7 +318,7 @@ export function fetchReblogsFail(id, error) { export function fetchFavourites(id) { return (dispatch, getState) => { - if (!getState().get('me')) return; + if (!isLoggedIn(getState)) return; dispatch(fetchFavouritesRequest(id)); @@ -354,7 +355,7 @@ export function fetchFavouritesFail(id, error) { export function pin(status) { return (dispatch, getState) => { - if (!getState().get('me')) return; + if (!isLoggedIn(getState)) return; dispatch(pinRequest(status)); @@ -394,7 +395,7 @@ export function pinFail(status, error) { export function unpin(status) { return (dispatch, getState) => { - if (!getState().get('me')) return; + if (!isLoggedIn(getState)) return; dispatch(unpinRequest(status)); diff --git a/app/soapbox/actions/lists.js b/app/soapbox/actions/lists.js index d93ddc43c..13a28ddf0 100644 --- a/app/soapbox/actions/lists.js +++ b/app/soapbox/actions/lists.js @@ -1,6 +1,7 @@ import api from '../api'; import { importFetchedAccounts } from './importer'; import { showAlertForError } from './alerts'; +import { isLoggedIn } from 'soapbox/utils/accounts'; export const LIST_FETCH_REQUEST = 'LIST_FETCH_REQUEST'; export const LIST_FETCH_SUCCESS = 'LIST_FETCH_SUCCESS'; @@ -50,7 +51,7 @@ export const LIST_ADDER_LISTS_FETCH_SUCCESS = 'LIST_ADDER_LISTS_FETCH_SUCCESS'; export const LIST_ADDER_LISTS_FETCH_FAIL = 'LIST_ADDER_LISTS_FETCH_FAIL'; export const fetchList = id => (dispatch, getState) => { - if (!getState().get('me')) return; + if (!isLoggedIn(getState)) return; if (getState().getIn(['lists', id])) { return; @@ -80,7 +81,7 @@ export const fetchListFail = (id, error) => ({ }); export const fetchLists = () => (dispatch, getState) => { - if (!getState().get('me')) return; + if (!isLoggedIn(getState)) return; dispatch(fetchListsRequest()); @@ -129,7 +130,7 @@ export const changeListEditorTitle = value => ({ }); export const createList = (title, shouldReset) => (dispatch, getState) => { - if (!getState().get('me')) return; + if (!isLoggedIn(getState)) return; dispatch(createListRequest()); @@ -157,7 +158,7 @@ export const createListFail = error => ({ }); export const updateList = (id, title, shouldReset) => (dispatch, getState) => { - if (!getState().get('me')) return; + if (!isLoggedIn(getState)) return; dispatch(updateListRequest(id)); @@ -191,7 +192,7 @@ export const resetListEditor = () => ({ }); export const deleteList = id => (dispatch, getState) => { - if (!getState().get('me')) return; + if (!isLoggedIn(getState)) return; dispatch(deleteListRequest(id)); @@ -217,7 +218,7 @@ export const deleteListFail = (id, error) => ({ }); export const fetchListAccounts = listId => (dispatch, getState) => { - if (!getState().get('me')) return; + if (!isLoggedIn(getState)) return; dispatch(fetchListAccountsRequest(listId)); @@ -246,7 +247,7 @@ export const fetchListAccountsFail = (id, error) => ({ }); export const fetchListSuggestions = q => (dispatch, getState) => { - if (!getState().get('me')) return; + if (!isLoggedIn(getState)) return; const params = { q, @@ -281,7 +282,7 @@ export const addToListEditor = accountId => (dispatch, getState) => { }; export const addToList = (listId, accountId) => (dispatch, getState) => { - if (!getState().get('me')) return; + if (!isLoggedIn(getState)) return; dispatch(addToListRequest(listId, accountId)); @@ -314,7 +315,7 @@ export const removeFromListEditor = accountId => (dispatch, getState) => { }; export const removeFromList = (listId, accountId) => (dispatch, getState) => { - if (!getState().get('me')) return; + if (!isLoggedIn(getState)) return; dispatch(removeFromListRequest(listId, accountId)); @@ -356,7 +357,7 @@ export const setupListAdder = accountId => (dispatch, getState) => { }; export const fetchAccountLists = accountId => (dispatch, getState) => { - if (!getState().get('me')) return; + if (!isLoggedIn(getState)) return; dispatch(fetchAccountListsRequest(accountId)); diff --git a/app/soapbox/actions/mutes.js b/app/soapbox/actions/mutes.js index 00d791197..1d081584a 100644 --- a/app/soapbox/actions/mutes.js +++ b/app/soapbox/actions/mutes.js @@ -2,6 +2,7 @@ import api, { getLinks } from '../api'; import { fetchRelationships } from './accounts'; import { importFetchedAccounts } from './importer'; import { openModal } from './modal'; +import { isLoggedIn } from 'soapbox/utils/accounts'; export const MUTES_FETCH_REQUEST = 'MUTES_FETCH_REQUEST'; export const MUTES_FETCH_SUCCESS = 'MUTES_FETCH_SUCCESS'; @@ -16,7 +17,7 @@ export const MUTES_TOGGLE_HIDE_NOTIFICATIONS = 'MUTES_TOGGLE_HIDE_NOTIFICATIONS' export function fetchMutes() { return (dispatch, getState) => { - if (!getState().get('me')) return; + if (!isLoggedIn(getState)) return; dispatch(fetchMutesRequest()); @@ -52,7 +53,7 @@ export function fetchMutesFail(error) { export function expandMutes() { return (dispatch, getState) => { - if (!getState().get('me')) return; + if (!isLoggedIn(getState)) return; const url = getState().getIn(['user_lists', 'mutes', 'next']); diff --git a/app/soapbox/actions/notifications.js b/app/soapbox/actions/notifications.js index 63d4adab3..7b30fc332 100644 --- a/app/soapbox/actions/notifications.js +++ b/app/soapbox/actions/notifications.js @@ -17,6 +17,7 @@ import { } from 'immutable'; import { unescapeHTML } from '../utils/html'; import { getFilters, regexFromFilters } from '../selectors'; +import { isLoggedIn } from 'soapbox/utils/accounts'; export const NOTIFICATIONS_UPDATE = 'NOTIFICATIONS_UPDATE'; export const NOTIFICATIONS_UPDATE_NOOP = 'NOTIFICATIONS_UPDATE_NOOP'; @@ -156,7 +157,7 @@ const noOp = () => {}; export function expandNotifications({ maxId } = {}, done = noOp) { return (dispatch, getState) => { - if (!getState().get('me')) return; + if (!isLoggedIn(getState)) return; const activeFilter = getSettings(getState()).getIn(['notifications', 'quickFilter', 'active']); const notifications = getState().get('notifications'); @@ -222,7 +223,7 @@ export function expandNotificationsFail(error, isLoadingMore) { export function clearNotifications() { return (dispatch, getState) => { - if (!getState().get('me')) return; + if (!isLoggedIn(getState)) return; dispatch({ type: NOTIFICATIONS_CLEAR, diff --git a/app/soapbox/actions/statuses.js b/app/soapbox/actions/statuses.js index bdf31da8f..7712e1bd9 100644 --- a/app/soapbox/actions/statuses.js +++ b/app/soapbox/actions/statuses.js @@ -4,6 +4,7 @@ import { evictStatus } from '../storage/modifier'; import { deleteFromTimelines } from './timelines'; import { importFetchedStatus, importFetchedStatuses, importAccount, importStatus } from './importer'; import { openModal } from './modal'; +import { isLoggedIn } from 'soapbox/utils/accounts'; export const STATUS_FETCH_REQUEST = 'STATUS_FETCH_REQUEST'; export const STATUS_FETCH_SUCCESS = 'STATUS_FETCH_SUCCESS'; @@ -141,7 +142,7 @@ export function redraft(status, raw_text) { export function deleteStatus(id, routerHistory, withRedraft = false) { return (dispatch, getState) => { - if (!getState().get('me')) return; + if (!isLoggedIn(getState)) return; let status = getState().getIn(['statuses', id]); @@ -233,7 +234,7 @@ export function fetchContextFail(id, error) { export function muteStatus(id) { return (dispatch, getState) => { - if (!getState().get('me')) return; + if (!isLoggedIn(getState)) return; dispatch(muteStatusRequest(id)); @@ -269,7 +270,7 @@ export function muteStatusFail(id, error) { export function unmuteStatus(id) { return (dispatch, getState) => { - if (!getState().get('me')) return; + if (!isLoggedIn(getState)) return; dispatch(unmuteStatusRequest(id)); diff --git a/app/soapbox/actions/suggestions.js b/app/soapbox/actions/suggestions.js index d84bb758f..bf6edffb4 100644 --- a/app/soapbox/actions/suggestions.js +++ b/app/soapbox/actions/suggestions.js @@ -1,5 +1,6 @@ import api from '../api'; import { importFetchedAccounts } from './importer'; +import { isLoggedIn } from 'soapbox/utils/accounts'; export const SUGGESTIONS_FETCH_REQUEST = 'SUGGESTIONS_FETCH_REQUEST'; export const SUGGESTIONS_FETCH_SUCCESS = 'SUGGESTIONS_FETCH_SUCCESS'; @@ -43,7 +44,7 @@ export function fetchSuggestionsFail(error) { }; export const dismissSuggestion = accountId => (dispatch, getState) => { - if (!getState().get('me')) return; + if (!isLoggedIn(getState)) return; dispatch({ type: SUGGESTIONS_DISMISS, diff --git a/app/soapbox/utils/accounts.js b/app/soapbox/utils/accounts.js index 7e25f868c..6dd60feae 100644 --- a/app/soapbox/utils/accounts.js +++ b/app/soapbox/utils/accounts.js @@ -49,3 +49,5 @@ export const isLocal = account => { export const isVerified = account => ( account.getIn(['pleroma', 'tags'], ImmutableList()).includes('verified') ); + +export const isLoggedIn = getState => typeof getState().get('me') === 'string';