diff --git a/app/javascript/gabsocial/actions/accounts.js b/app/javascript/gabsocial/actions/accounts.js index e8b53e96..7677afd9 100644 --- a/app/javascript/gabsocial/actions/accounts.js +++ b/app/javascript/gabsocial/actions/accounts.js @@ -148,7 +148,6 @@ const fetchAccountFail = (id, error) => ({ type: ACCOUNT_FETCH_FAIL, id, error, - skipAlert: true, }) /** @@ -178,12 +177,14 @@ const followAccountRequest = (id, locked) => ({ const followAccountSuccess = (relationship, alreadyFollowing) => ({ type: ACCOUNT_FOLLOW_SUCCESS, + showToast: true, relationship, alreadyFollowing, }) const followAccountFail = (error, locked) => ({ type: ACCOUNT_FOLLOW_FAIL, + showToast: true, error, locked, }) @@ -210,12 +211,14 @@ const unfollowAccountRequest = (id) => ({ const unfollowAccountSuccess = (relationship, statuses) => ({ type: ACCOUNT_UNFOLLOW_SUCCESS, + showToast: true, relationship, statuses, }) const unfollowAccountFail = (error) => ({ type: ACCOUNT_UNFOLLOW_FAIL, + showToast: true, error, }) @@ -243,12 +246,14 @@ const blockAccountRequest = (id) => ({ const blockAccountSuccess = (relationship, statuses) => ({ type: ACCOUNT_BLOCK_SUCCESS, + showToast: true, relationship, statuses, }) const blockAccountFail = (error) => ({ type: ACCOUNT_BLOCK_FAIL, + showToast: true, error, }) @@ -274,11 +279,13 @@ const unblockAccountRequest = (id) => ({ const unblockAccountSuccess = (relationship) => ({ type: ACCOUNT_UNBLOCK_SUCCESS, + showToast: true, relationship, }) const unblockAccountFail = (error) => ({ type: ACCOUNT_UNBLOCK_FAIL, + showToast: true, error, }) @@ -305,12 +312,14 @@ const muteAccountRequest = (id) => ({ const muteAccountSuccess = (relationship, statuses) => ({ type: ACCOUNT_MUTE_SUCCESS, + showToast: true, relationship, statuses, }) const muteAccountFail = (error) => ({ type: ACCOUNT_MUTE_FAIL, + showToast: true, error, }) @@ -336,11 +345,13 @@ const unmuteAccountRequest = (id) => ({ const unmuteAccountSuccess = (relationship) => ({ type: ACCOUNT_UNMUTE_SUCCESS, + showToast: true, relationship, }) const unmuteAccountFail = (error) => ({ type: ACCOUNT_UNMUTE_FAIL, + showToast: true, error, }) @@ -377,6 +388,7 @@ const fetchFollowersSuccess = (id, accounts, next) => ({ const fetchFollowersFail = (id, error) => ({ type: FOLLOWERS_FETCH_FAIL, + showToast: true, id, error, }) @@ -419,6 +431,7 @@ const expandFollowersSuccess = (id, accounts, next) => ({ const expandFollowersFail = (id, error) => ({ type: FOLLOWERS_EXPAND_FAIL, + showToast: true, id, error, }) @@ -456,6 +469,7 @@ const fetchFollowingSuccess = (id, accounts, next) => ({ const fetchFollowingFail = (id, error) => ({ type: FOLLOWING_FETCH_FAIL, + showToast: true, id, error, }) @@ -498,6 +512,7 @@ const expandFollowingSuccess = (id, accounts, next) => ({ const expandFollowingFail = (id, error) => ({ type: FOLLOWING_EXPAND_FAIL, + showToast: true, id, error, }) @@ -575,6 +590,7 @@ const fetchFollowRequestsSuccess = (accounts, next) => ({ const fetchFollowRequestsFail = (error) => ({ type: FOLLOW_REQUESTS_FETCH_FAIL, + showToast: true, error, }) @@ -610,6 +626,7 @@ const expandFollowRequestsSuccess = (accounts, next) => ({ const expandFollowRequestsFail = (error) => ({ type: FOLLOW_REQUESTS_EXPAND_FAIL, + showToast: true, error, }) @@ -634,11 +651,13 @@ const authorizeFollowRequestRequest = (id) => ({ const authorizeFollowRequestSuccess = (id) => ({ type: FOLLOW_REQUEST_AUTHORIZE_SUCCESS, + showToast: true, id, }) const authorizeFollowRequestFail = (id, error) => ({ type: FOLLOW_REQUEST_AUTHORIZE_FAIL, + showToast: true, id, error, }) @@ -664,11 +683,13 @@ const rejectFollowRequestRequest = (id) => ({ const rejectFollowRequestSuccess = (id) => ({ type: FOLLOW_REQUEST_REJECT_SUCCESS, + showToast: true, id, }) const rejectFollowRequestFail = (id, error) => ({ type: FOLLOW_REQUEST_REJECT_FAIL, + showToast: true, id, error, }) diff --git a/app/javascript/gabsocial/actions/blocks.js b/app/javascript/gabsocial/actions/blocks.js index 279f505f..8febff1c 100644 --- a/app/javascript/gabsocial/actions/blocks.js +++ b/app/javascript/gabsocial/actions/blocks.js @@ -39,6 +39,7 @@ export const fetchBlocksSuccess = (accounts, next) => ({ export const fetchBlocksFail = (error) => ({ type: BLOCKS_FETCH_FAIL, + showToast: true, error, }) @@ -75,5 +76,6 @@ export const expandBlocksSuccess = (accounts, next) => ({ export const expandBlocksFail = (error) => ({ type: BLOCKS_EXPAND_FAIL, + showToast: true, error, }) diff --git a/app/javascript/gabsocial/actions/bookmarks.js b/app/javascript/gabsocial/actions/bookmarks.js index 3af513a9..26007292 100644 --- a/app/javascript/gabsocial/actions/bookmarks.js +++ b/app/javascript/gabsocial/actions/bookmarks.js @@ -43,6 +43,7 @@ const fetchBookmarkedStatusesSuccess = (statuses, next) => ({ const fetchBookmarkedStatusesFail = (error) => ({ type: BOOKMARKED_STATUSES_FETCH_FAIL, + showToast: true, error, }) @@ -81,5 +82,6 @@ const expandBookmarkedStatusesSuccess = (statuses, next) => ({ const expandBookmarkedStatusesFail = (error) => ({ type: BOOKMARKED_STATUSES_EXPAND_FAIL, + showToast: true, error, }) diff --git a/app/javascript/gabsocial/actions/chat_conversation_messages.js b/app/javascript/gabsocial/actions/chat_conversation_messages.js index 47895dc1..d59892f3 100644 --- a/app/javascript/gabsocial/actions/chat_conversation_messages.js +++ b/app/javascript/gabsocial/actions/chat_conversation_messages.js @@ -106,6 +106,7 @@ export const expandChatMessagesSuccess = (chatConversationId, chatMessages, next export const expandChatMessagesFail = (chatConversationId, error, isLoadingMore) => ({ type: CHAT_CONVERSATION_MESSAGES_EXPAND_FAIL, + showToast: true, chatConversationId, error, skipLoading: !isLoadingMore, diff --git a/app/javascript/gabsocial/actions/chat_messages.js b/app/javascript/gabsocial/actions/chat_messages.js index 038e2710..aacec68f 100644 --- a/app/javascript/gabsocial/actions/chat_messages.js +++ b/app/javascript/gabsocial/actions/chat_messages.js @@ -48,6 +48,7 @@ export const sendChatMessageSuccess = (chatMessage) => ({ const sendChatMessageFail = (error) => ({ type: CHAT_MESSAGES_SEND_FAIL, + showToast: true, error, }) @@ -77,9 +78,11 @@ const deleteChatMessageRequest = (chatMessageId) => ({ const deleteChatMessageSuccess = () => ({ type: CHAT_MESSAGES_DELETE_SUCCESS, + showToast: true, }) const deleteChatMessageFail = (error) => ({ type: CHAT_MESSAGES_DELETE_FAIL, + showToast: true, error, }) \ No newline at end of file diff --git a/app/javascript/gabsocial/actions/compose.js b/app/javascript/gabsocial/actions/compose.js index 91eb47bb..f3be35d8 100644 --- a/app/javascript/gabsocial/actions/compose.js +++ b/app/javascript/gabsocial/actions/compose.js @@ -398,11 +398,13 @@ const submitComposeRequest = () => ({ const submitComposeSuccess = (status) => ({ type: COMPOSE_SUBMIT_SUCCESS, + showToast: true, status, }) const submitComposeFail = (error) => ({ type: COMPOSE_SUBMIT_FAIL, + showToast: true, error, }) @@ -466,6 +468,7 @@ const uploadComposeSuccess = (media) => ({ const uploadComposeFail = (error) => ({ type: COMPOSE_UPLOAD_FAIL, + showToast: true, error, }) @@ -496,6 +499,7 @@ const changeUploadComposeSuccess = (media) => ({ const changeUploadComposeFail = (error, decrement = false) => ({ type: COMPOSE_UPLOAD_CHANGE_FAIL, error, + showToast: true, decrement: decrement, }) diff --git a/app/javascript/gabsocial/actions/favorites.js b/app/javascript/gabsocial/actions/favorites.js index 271967aa..ae6fb210 100644 --- a/app/javascript/gabsocial/actions/favorites.js +++ b/app/javascript/gabsocial/actions/favorites.js @@ -43,6 +43,7 @@ const fetchFavoritedStatusesSuccess = (statuses, next) => ({ const fetchFavoritedStatusesFail = (error) => ({ type: FAVORITED_STATUSES_FETCH_FAIL, + showToast: true, error, }) @@ -81,5 +82,6 @@ const expandFavoritedStatusesSuccess = (statuses, next) => ({ const expandFavoritedStatusesFail = (error) => ({ type: FAVORITED_STATUSES_EXPAND_FAIL, + showToast: true, error, -}) +}) \ No newline at end of file diff --git a/app/javascript/gabsocial/actions/filters.js b/app/javascript/gabsocial/actions/filters.js index bb831b3d..3bf42ccb 100644 --- a/app/javascript/gabsocial/actions/filters.js +++ b/app/javascript/gabsocial/actions/filters.js @@ -30,8 +30,8 @@ const fetchFiltersSuccess = (filters) => ({ filters, }) -const fetchFiltersFail = (err) => ({ +const fetchFiltersFail = (error) => ({ type: FILTERS_FETCH_FAIL, - err, + error, skipAlert: true, }) \ No newline at end of file diff --git a/app/javascript/gabsocial/actions/group_categories.js b/app/javascript/gabsocial/actions/group_categories.js index 0861e4d7..d91f70d3 100644 --- a/app/javascript/gabsocial/actions/group_categories.js +++ b/app/javascript/gabsocial/actions/group_categories.js @@ -26,5 +26,6 @@ const fetchGroupCategoriesSuccess = (categories) => ({ const fetchGroupCategoriesFail = (error) => ({ type: GROUP_CATEGORIES_FETCH_FAIL, + showToast: true, error, }) \ No newline at end of file diff --git a/app/javascript/gabsocial/actions/group_editor.js b/app/javascript/gabsocial/actions/group_editor.js index cf4c80bd..d2306a69 100644 --- a/app/javascript/gabsocial/actions/group_editor.js +++ b/app/javascript/gabsocial/actions/group_editor.js @@ -100,11 +100,13 @@ const createGroupRequest = (id) => ({ const createSuccess = (group) => ({ type: GROUP_CREATE_SUCCESS, + showToast: true, group, }) const createFail = (error) => ({ type: GROUP_CREATE_FAIL, + showToast: true, error, }) @@ -151,11 +153,13 @@ const updateGroupRequest = (id) => ({ const updateGroupSuccess = (group) => ({ type: GROUP_UPDATE_SUCCESS, + showToast: true, group, }) const updateGroupFail = (error) => ({ type: GROUP_UPDATE_FAIL, + showToast: true, error, }) diff --git a/app/javascript/gabsocial/actions/groups.js b/app/javascript/gabsocial/actions/groups.js index b247daa8..bc1b0ace 100644 --- a/app/javascript/gabsocial/actions/groups.js +++ b/app/javascript/gabsocial/actions/groups.js @@ -153,6 +153,7 @@ const fetchGroupSuccess = (group) => ({ const fetchGroupFail = (groupId, error) => ({ type: GROUP_FETCH_FAIL, + showToast: true, groupId, error, }) @@ -233,6 +234,7 @@ export const fetchGroupsSuccess = (groups, tab) => ({ const fetchGroupsFail = (error, tab) => ({ type: GROUPS_FETCH_FAIL, + showToast: true, error, tab, }) @@ -273,6 +275,7 @@ const fetchGroupsByCategorySuccess = (groups, category) => ({ const fetchGroupsByCategoryFail = (error, category) => ({ type: GROUPS_BY_CATEGORY_FETCH_FAIL, + showToast: true, error, category, }) @@ -313,6 +316,7 @@ export const fetchGroupsByTagSuccess = (groups, tag) => ({ export const fetchGroupsByTagFail = (error, tag) => ({ type: GROUPS_BY_TAG_FETCH_FAIL, + showToast: true, error, tag, }) @@ -340,11 +344,13 @@ const joinGroupRequest = (groupId) => ({ const joinGroupSuccess = (relationship) => ({ type: GROUP_JOIN_SUCCESS, + showToast: true, relationship }) const joinGroupFail = (error) => ({ type: GROUP_JOIN_FAIL, + showToast: true, error, }) @@ -371,11 +377,13 @@ const leaveGroupRequest = (groupId) => ({ const leaveGroupSuccess = (relationship) => ({ type: GROUP_LEAVE_SUCCESS, + showToast: true, relationship, }) const leaveGroupFail = (error) => ({ type: GROUP_LEAVE_FAIL, + showToast: true, error, }) @@ -414,6 +422,7 @@ const fetchMembersSuccess = (groupId, accounts, next) => ({ const fetchMembersFail = (groupId, error) => ({ type: GROUP_MEMBERS_FETCH_FAIL, + showToast: true, groupId, error, }) @@ -458,6 +467,7 @@ const expandMembersSuccess = (groupId, accounts, next) => ({ const expandMembersFail = (groupId, error) => ({ type: GROUP_MEMBERS_EXPAND_FAIL, + showToast: true, groupId, error, }) @@ -497,6 +507,7 @@ const fetchRemovedAccountsSuccess = (groupId, accounts, next) => ({ const fetchRemovedAccountsFail = (groupId, error) => ({ type: GROUP_REMOVED_ACCOUNTS_FETCH_FAIL, + showToast: true, groupId, error, }) @@ -541,6 +552,7 @@ const expandRemovedAccountsSuccess = (groupId, accounts, next) => ({ const expandRemovedAccountsFail = (groupId, error) => ({ type: GROUP_REMOVED_ACCOUNTS_EXPAND_FAIL, + showToast: true, groupId, error, }) @@ -570,12 +582,14 @@ const removeRemovedAccountRequest = (groupId, accountId) => ({ const removeRemovedAccountSuccess = (groupId, accountId) => ({ type: GROUP_REMOVED_ACCOUNTS_REMOVE_SUCCESS, + showToast: true, groupId, accountId, }) const removeRemovedAccountFail = (groupId, accountId, error) => ({ type: GROUP_REMOVED_ACCOUNTS_REMOVE_FAIL, + showToast: true, groupId, accountId, error, @@ -606,12 +620,14 @@ const createRemovedAccountRequest = (groupId, accountId) => ({ const createRemovedAccountSuccess = (groupId, accountId) => ({ type: GROUP_REMOVED_ACCOUNTS_CREATE_SUCCESS, + showToast: true, groupId, accountId, }) const createRemovedAccountFail = (groupId, accountId, error) => ({ type: GROUP_REMOVED_ACCOUNTS_CREATE_FAIL, + showToast: true, groupId, accountId, error, @@ -643,12 +659,14 @@ const groupRemoveStatusRequest = (groupId, statusId) => ({ const groupRemoveStatusSuccess = (groupId, statusId) => ({ type: GROUP_REMOVE_STATUS_SUCCESS, + showToast: true, groupId, statusId, }) const groupRemoveStatusFail = (groupId, statusId, error) => ({ type: GROUP_REMOVE_STATUS_FAIL, + showToast: true, groupId, statusId, error, @@ -680,12 +698,14 @@ const updateRoleRequest = (groupId, accountId) => ({ const updateRoleSuccess = (groupId, accountId) => ({ type: GROUP_UPDATE_ROLE_SUCCESS, + showToast: true, groupId, accountId, }) const updateRoleFail = (groupId, accountId, error) => ({ type: GROUP_UPDATE_ROLE_FAIL, + showToast: true, groupId, accountId, error, @@ -760,6 +780,7 @@ const fetchJoinRequestsSuccess = (id, accounts, next) => ({ const fetchJoinRequestsFail = (id, error) => ({ type: GROUP_JOIN_REQUESTS_FETCH_FAIL, + showToast: true, id, error, }) @@ -802,6 +823,7 @@ const expandJoinRequestsSuccess = (id, accounts, next) => ({ const expandJoinRequestsFail = (id, error) => ({ type: GROUP_JOIN_REQUESTS_EXPAND_FAIL, + showToast: true, id, error, }) @@ -821,12 +843,14 @@ export const approveJoinRequest = (accountId, groupId) => (dispatch, getState) = const approveJoinRequestSuccess = (accountId, groupId) => ({ type: GROUP_JOIN_REQUESTS_APPROVE_SUCCESS, + showToast: true, accountId, groupId, }) const approveJoinRequestFail = (accountId, groupId, error) => ({ type: GROUP_JOIN_REQUESTS_APPROVE_FAIL, + showToast: true, accountId, groupId, error, @@ -847,12 +871,14 @@ export const rejectJoinRequest = (accountId, groupId) => (dispatch, getState) => const rejectJoinRequestSuccess = (accountId, groupId) => ({ type: GROUP_JOIN_REQUESTS_REJECT_SUCCESS, + showToast: true, accountId, groupId, }) const rejectJoinRequestFail = (accountId, groupId, error) => ({ type: GROUP_JOIN_REQUESTS_REJECT_FAIL, + showToast: true, accountId, groupId, error, @@ -881,12 +907,14 @@ const pinGroupStatusRequest = (groupId) => ({ const pinGroupStatusSuccess = (groupId, statusId) => ({ type: GROUP_PIN_STATUS_SUCCESS, + showToast: true, groupId, statusId, }) const pinGroupStatusFail = (groupId, statusId, error) => ({ type: GROUP_PIN_STATUS_FAIL, + showToast: true, groupId, statusId, error, @@ -915,12 +943,14 @@ const unpinGroupStatusRequest = (groupId) => ({ const unpinGroupStatusSuccess = (groupId, statusId) => ({ type: GROUP_UNPIN_STATUS_SUCCESS, + showToast: true, groupId, statusId, }) const unpinGroupStatusFail = (groupId, statusId, error) => ({ type: GROUP_UNPIN_STATUS_FAIL, + showToast: true, groupId, statusId, error, diff --git a/app/javascript/gabsocial/actions/interactions.js b/app/javascript/gabsocial/actions/interactions.js index 2dd2d01a..f57e01a4 100644 --- a/app/javascript/gabsocial/actions/interactions.js +++ b/app/javascript/gabsocial/actions/interactions.js @@ -557,6 +557,7 @@ const expandLikesSuccess = (statusId, accounts, next) => ({ const expandLikesFail = (statusId, error) => ({ type: LIKES_EXPAND_FAIL, + showToast: true, statusId, error, }) diff --git a/app/javascript/gabsocial/actions/lists.js b/app/javascript/gabsocial/actions/lists.js index 03c85ced..24befc56 100644 --- a/app/javascript/gabsocial/actions/lists.js +++ b/app/javascript/gabsocial/actions/lists.js @@ -109,6 +109,7 @@ const fetchListsSuccess = (lists) => ({ const fetchListsFail = (error) => ({ type: LISTS_FETCH_FAIL, + showToast: true, error, }) @@ -169,11 +170,13 @@ export const createListRequest = () => ({ export const createListSuccess = (list) => ({ type: LIST_CREATE_SUCCESS, + showToast: true, list, }) export const createListFail = (error) => ({ type: LIST_CREATE_FAIL, + showToast: true, error, }) @@ -201,11 +204,13 @@ export const updateListRequest = id => ({ export const updateListSuccess = list => ({ type: LIST_UPDATE_SUCCESS, + showToast: true, list, }) export const updateListFail = (id, error) => ({ type: LIST_UPDATE_FAIL, + showToast: true, id, error, }) @@ -234,11 +239,13 @@ export const deleteListRequest = (id) => ({ export const deleteListSuccess = (id) => ({ type: LIST_DELETE_SUCCESS, + showToast: true, id, }) export const deleteListFail = (id, error) => ({ type: LIST_DELETE_FAIL, + showToast: true, id, error, }) @@ -271,6 +278,7 @@ export const fetchListAccountsSuccess = (id, accounts, next) => ({ export const fetchListAccountsFail = (id, error) => ({ type: LIST_ACCOUNTS_FETCH_FAIL, + showToast: true, id, error, }) @@ -346,12 +354,14 @@ const addToListRequest = (listId, accountId) => ({ const addToListSuccess = (listId, accountId) => ({ type: LIST_EDITOR_ADD_SUCCESS, + showToast: true, listId, accountId, }) const addToListFail = (listId, accountId, error) => ({ type: LIST_EDITOR_ADD_FAIL, + showToast: true, listId, accountId, error, @@ -385,12 +395,14 @@ const removeFromListRequest = (listId, accountId) => ({ const removeFromListSuccess = (listId, accountId) => ({ type: LIST_EDITOR_REMOVE_SUCCESS, + showToast: true, listId, accountId, }) const removeFromListFail = (listId, accountId, error) => ({ type: LIST_EDITOR_REMOVE_FAIL, + showToast: true, listId, accountId, error, @@ -439,10 +451,11 @@ const fetchAccountListsSuccess = (id, lists) => ({ lists, }) -const fetchAccountListsFail = (id, err) => ({ +const fetchAccountListsFail = (id, error) => ({ type: LIST_ADDER_LISTS_FETCH_FAIL, + showToast: true, id, - err, + error, }) /** diff --git a/app/javascript/gabsocial/actions/mutes.js b/app/javascript/gabsocial/actions/mutes.js index 8e1d3c1f..3f189c94 100644 --- a/app/javascript/gabsocial/actions/mutes.js +++ b/app/javascript/gabsocial/actions/mutes.js @@ -43,6 +43,7 @@ const fetchMutesSuccess = (accounts, next) => ({ const fetchMutesFail = (error) => ({ type: MUTES_FETCH_FAIL, + showToast: true, error, }) @@ -79,6 +80,7 @@ const expandMutesSuccess = (accounts, next) => ({ export const expandMutesFail = (error) => ({ type: MUTES_EXPAND_FAIL, + showToast: true, error, }) diff --git a/app/javascript/gabsocial/actions/notifications.js b/app/javascript/gabsocial/actions/notifications.js index 5a3d737f..71e1e291 100644 --- a/app/javascript/gabsocial/actions/notifications.js +++ b/app/javascript/gabsocial/actions/notifications.js @@ -218,6 +218,7 @@ const expandNotificationsSuccess = (notifications, next, isLoadingMore) => ({ const expandNotificationsFail = (error, isLoadingMore) => ({ type: NOTIFICATIONS_EXPAND_FAIL, error, + showToast: true, skipLoading: !isLoadingMore, }) diff --git a/app/javascript/gabsocial/actions/polls.js b/app/javascript/gabsocial/actions/polls.js index 29ba4f7d..1d9d2cfc 100644 --- a/app/javascript/gabsocial/actions/polls.js +++ b/app/javascript/gabsocial/actions/polls.js @@ -29,11 +29,13 @@ const voteRequest = () => ({ const voteSuccess = (poll) => ({ type: POLL_VOTE_SUCCESS, + showToast: true, poll, }) const voteFail = (error) => ({ type: POLL_VOTE_FAIL, + showToast: true, error, }) diff --git a/app/javascript/gabsocial/actions/reports.js b/app/javascript/gabsocial/actions/reports.js index 094b3cf2..5b3839ac 100644 --- a/app/javascript/gabsocial/actions/reports.js +++ b/app/javascript/gabsocial/actions/reports.js @@ -65,11 +65,13 @@ const submitReportRequest = () => ({ const submitReportSuccess = (report) => ({ type: REPORT_SUBMIT_SUCCESS, + showToast: true, report, }) const submitReportFail = (error) => ({ type: REPORT_SUBMIT_FAIL, + showToast: true, error, }) diff --git a/app/javascript/gabsocial/actions/search.js b/app/javascript/gabsocial/actions/search.js index 81d021cc..37d48f77 100644 --- a/app/javascript/gabsocial/actions/search.js +++ b/app/javascript/gabsocial/actions/search.js @@ -86,6 +86,7 @@ const fetchSearchSuccess = (results) => ({ const fetchSearchFail = (error) => ({ type: SEARCH_FETCH_FAIL, + showToast: true, error, }) diff --git a/app/javascript/gabsocial/actions/shortcuts.js b/app/javascript/gabsocial/actions/shortcuts.js index 6b1169d3..4bb93b06 100644 --- a/app/javascript/gabsocial/actions/shortcuts.js +++ b/app/javascript/gabsocial/actions/shortcuts.js @@ -107,10 +107,12 @@ const removeShortcutsRequest = () => ({ const removeShortcutsSuccess = (shortcutId) => ({ type: SHORTCUTS_REMOVE_SUCCESS, + showToast: true, shortcutId, }) const removeShortcutsFail = (error) => ({ type: SHORTCUTS_REMOVE_FAIL, + showToast: true, error, }) diff --git a/app/javascript/gabsocial/actions/status_revisions.js b/app/javascript/gabsocial/actions/status_revisions.js index 081fe0ba..7aeba2e8 100644 --- a/app/javascript/gabsocial/actions/status_revisions.js +++ b/app/javascript/gabsocial/actions/status_revisions.js @@ -11,7 +11,7 @@ export const loadStatusRevisions = (statusId) => (dispatch, getState) => { dispatch(loadStatusRevisionsRequest()) api(getState).get(`/api/v1/statuses/${statusId}/revisions`) .then(res => dispatch(loadStatusRevisionsSuccess(res.data))) - .catch(() => dispatch(loadStatusRevisionsFail())) + .catch((error) => dispatch(loadStatusRevisionsFail(error))) } const loadStatusRevisionsRequest = () => ({ @@ -23,7 +23,8 @@ const loadStatusRevisionsSuccess = (data) => ({ revisions: data, }) -const loadStatusRevisionsFail = () => ({ +const loadStatusRevisionsFail = (error) => ({ type: STATUS_REVISIONS_LOAD_FAIL, - error: true, -}) \ No newline at end of file + showToast: true, + error, +}) diff --git a/app/javascript/gabsocial/actions/statuses.js b/app/javascript/gabsocial/actions/statuses.js index 008b29df..57613a6d 100644 --- a/app/javascript/gabsocial/actions/statuses.js +++ b/app/javascript/gabsocial/actions/statuses.js @@ -250,6 +250,7 @@ const fetchCommentsSuccess = (id, descendants) => ({ const fetchCommentsFail = (id, error) => ({ type: COMMENTS_FETCH_FAIL, + showToast: true, id, error, skipAlert: true, diff --git a/app/javascript/gabsocial/actions/timelines.js b/app/javascript/gabsocial/actions/timelines.js index af65ae18..2429c6d6 100644 --- a/app/javascript/gabsocial/actions/timelines.js +++ b/app/javascript/gabsocial/actions/timelines.js @@ -180,6 +180,7 @@ const expandTimelineSuccess = (timeline, statuses, next, partial, isLoadingRecen const expandTimelineFail = (timeline, error, isLoadingMore) => ({ type: TIMELINE_EXPAND_FAIL, + showToast: true, timeline, error, skipLoading: !isLoadingMore, diff --git a/app/javascript/gabsocial/actions/toasts.js b/app/javascript/gabsocial/actions/toasts.js index 3910f75d..9aa8409d 100644 --- a/app/javascript/gabsocial/actions/toasts.js +++ b/app/javascript/gabsocial/actions/toasts.js @@ -1,8 +1,3 @@ -import { - TOAST_TYPE_ERROR, - TOAST_TYPE_SUCCESS, -} from '../constants' - export const TOAST_SHOW = 'TOAST_SHOW' export const TOAST_DISMISS = 'TOAST_DISMISS' export const TOAST_CLEAR = 'TOAST_CLEAR' @@ -10,9 +5,9 @@ export const TOAST_CLEAR = 'TOAST_CLEAR' /** * */ -export const dismissToast = (alert) => ({ +export const dismissToast = (toastKey) => ({ type: TOAST_DISMISS, - alert, + toastKey, }) /** @@ -25,17 +20,8 @@ export const clearToast = () => ({ /** * */ -export const showToast = (type, message) => ({ +export const showToast = (toastType, toastData) => ({ type: TOAST_SHOW, - toastType: type, - message, + toastType, + toastData, }) - -export const showToastError = (message) => { - return showToast(TOAST_TYPE_ERROR, message) -} - -export const showToastSucess = (message) => { - console.log("showToastSucess:", message) - return showToast(TOAST_TYPE_SUCCESS, message) -} \ No newline at end of file diff --git a/app/javascript/gabsocial/actions/user.js b/app/javascript/gabsocial/actions/user.js index 67c858b9..3d206227 100644 --- a/app/javascript/gabsocial/actions/user.js +++ b/app/javascript/gabsocial/actions/user.js @@ -44,11 +44,13 @@ const saveUserProfileInformationRequest = () => ({ const saveUserProfileInformationSuccess = (userProfileData) => ({ type: SAVE_USER_PROFILE_INFORMATION_FETCH_SUCCESS, + showToast: true, userProfileData, }) const saveUserProfileInformationFail = (error) => ({ type: SAVE_USER_PROFILE_INFORMATION_FETCH_FAIL, + showToast: true, error, }) diff --git a/app/javascript/gabsocial/containers/toasts_container.js b/app/javascript/gabsocial/containers/toasts_container.js index 528da5b2..25daa331 100644 --- a/app/javascript/gabsocial/containers/toasts_container.js +++ b/app/javascript/gabsocial/containers/toasts_container.js @@ -8,60 +8,63 @@ import Toast from '../components/toast' class ToastsContainer extends React.PureComponent { - handleOnDismiss = (key) => { - this.props.dispatch(dismissToast(key)) + handleOnDismiss = (toastKey) => { + this.props.dispatch(dismissToast(toastKey)) } render() { - // const { notifications } = this.props - const notifications = [ - { - key: '1', - title: 'Error', - to: 'to', - image: 'https://gab.com/media/user/58077e8a49705.jpg', - message: 'Unable to follow @andrew', - date: new Date(), - isImageAccount: true, - }, - { - key: '2', - title: 'Success', - to: 'to', - image: 'https://gab.com/media/user/58077e8a49705.jpg', - message: 'Your gab was posted. Click here to view', - date: new Date(), - isImageAccount: false, - }, - { - key: '3', - title: '', - to: 'to', - image: 'https://gab.com/media/user/58077e8a49705.jpg', - message: 'Unable to follow @andrew', - date: new Date(), - isImageAccount: true, - }, - { - key: '4', - title: '', - to: 'to', - image: 'https://gab.com/media/user/58077e8a49705.jpg', - message: 'Your gab was posted. Click here to view', - date: new Date(), - isImageAccount: false, - }, - { - key: '5', - title: '', - to: 'to', - message: 'Your gab was deleted', - date: new Date(), - isImageAccount: false, - }, - ] + const { notifications } = this.props - const hasNotifications = Array.isArray(notifications) && notifications.length > 0 + console.log("notifications:", notifications) + + // const notifications = [ + // { + // key: '1', + // title: 'Error', + // to: 'to', + // image: 'https://gab.com/media/user/58077e8a49705.jpg', + // message: 'Unable to follow @andrew', + // date: new Date(), + // isImageAccount: true, + // }, + // { + // key: '2', + // title: 'Success', + // to: 'to', + // image: 'https://gab.com/media/user/58077e8a49705.jpg', + // message: 'Your gab was posted. Click here to view', + // date: new Date(), + // isImageAccount: false, + // }, + // { + // key: '3', + // title: '', + // to: 'to', + // image: 'https://gab.com/media/user/58077e8a49705.jpg', + // message: 'Unable to follow @andrew', + // date: new Date(), + // isImageAccount: true, + // }, + // { + // key: '4', + // title: '', + // to: 'to', + // image: 'https://gab.com/media/user/58077e8a49705.jpg', + // message: 'Your gab was posted. Click here to view', + // date: new Date(), + // isImageAccount: false, + // }, + // { + // key: '5', + // title: '', + // to: 'to', + // message: 'Your gab was deleted', + // date: new Date(), + // isImageAccount: false, + // }, + // ] + + const hasNotifications = !!notifications && notifications.size > 0 const containerClasses = CX({ d: 1, @@ -80,17 +83,17 @@ class ToastsContainer extends React.PureComponent { return (
{ - !hasNotifications && notifications.map((notification) => ( + hasNotifications && notifications.map((notification) => ( )) } @@ -101,11 +104,9 @@ class ToastsContainer extends React.PureComponent { } -const mapStateToProps = (state) => { - const notifications = getToasts(state) - if (!notifications) return {} - return { notifications } -} +const mapStateToProps = (state) => ({ + notifications: state.get('toasts') +}) ToastsContainer.propTypes = { notifications: PropTypes.array, diff --git a/app/javascript/gabsocial/middleware/errors.js b/app/javascript/gabsocial/middleware/errors.js index ee8ca73c..7470852c 100644 --- a/app/javascript/gabsocial/middleware/errors.js +++ b/app/javascript/gabsocial/middleware/errors.js @@ -1,18 +1,27 @@ -// import { showAlertForError } from '../actions/alerts'; +import isObject from 'lodash.isobject' +import { showToast } from '../actions/toasts' +import { + TOAST_TYPE_ERROR, + TOAST_TYPE_SUCCESS, +} from '../constants' -const defaultFailSuffix = 'FAIL'; +const defaultSuccessSuffix = 'SUCCESS' +const defaultFailSuffix = 'FAIL' export default function errorsMiddleware() { - return ({ dispatch }) => next => action => { - // : todo : use skipAlert! - if (action.type && !action.skipAlert) { - const isFail = new RegExp(`${defaultFailSuffix}$`, 'g'); + return ({ dispatch }) => (next) => (action) => { + if (isObject(action) && action.type && action.showToast) { + const isFail = new RegExp(`${defaultFailSuffix}$`, 'g') + const isSuccess = new RegExp(`${defaultSuccessSuffix}$`, 'g') + if (action.type.match(isFail)) { - // dispatch(showAlertForError(action.error)); - } + dispatch(showToast(TOAST_TYPE_ERROR, action)) + } else if (action.type.match(isSuccess)) { + dispatch(showToast(TOAST_TYPE_SUCCESS, action)) + } } - return next(action); - }; -}; + return next(action) + } +} diff --git a/app/javascript/gabsocial/middleware/loading_bar.js b/app/javascript/gabsocial/middleware/loading_bar.js index 1c20897a..5f0e19a4 100644 --- a/app/javascript/gabsocial/middleware/loading_bar.js +++ b/app/javascript/gabsocial/middleware/loading_bar.js @@ -1,3 +1,4 @@ +import isObject from 'lodash.isobject' import { showLoading, hideLoading } from 'react-redux-loading-bar' const defaultTypeSuffixes = ['PENDING', 'FULFILLED', 'REJECTED'] @@ -5,8 +6,8 @@ const defaultTypeSuffixes = ['PENDING', 'FULFILLED', 'REJECTED'] export default function loadingBarMiddleware(config = {}) { const promiseTypeSuffixes = config.promiseTypeSuffixes || defaultTypeSuffixes - return ({ dispatch }) => next => (action) => { - if (action.type && action.type.indexOf('TIMELINE') > -1) { + return ({ dispatch }) => (next) => (action) => { + if (isObject(action) && action.type && action.type.indexOf('TIMELINE') > -1) { const [PENDING, FULFILLED, REJECTED] = promiseTypeSuffixes const isPending = new RegExp(`${PENDING}$`, 'g') diff --git a/app/javascript/gabsocial/reducers/toasts.js b/app/javascript/gabsocial/reducers/toasts.js index 3d9c9560..8e5479dc 100644 --- a/app/javascript/gabsocial/reducers/toasts.js +++ b/app/javascript/gabsocial/reducers/toasts.js @@ -10,13 +10,13 @@ const initialState = ImmutableList([]) export default function toasts(state = initialState, action) { switch(action.type) { case TOAST_SHOW: - return state.push(ImmutableMap({ + return state.set(state.size, ImmutableMap({ key: state.size > 0 ? state.last().get('key') + 1 : 0, - message: action.message, + message: 'action.message', type: action.toastType, })) case TOAST_DISMISS: - return state.filterNot(item => item.get('key') === action.toast.key) + return state.filterNot(item => item.get('key') === action.toastKey) case TOAST_CLEAR: return state.clear() default: