Updated Toast alerts, progress mvp

• Updated:
- Toast alerts
This commit is contained in:
mgabdev 2020-12-07 23:39:13 -05:00
parent 5422c013e1
commit 05c5dcb581
28 changed files with 205 additions and 109 deletions

View File

@ -148,7 +148,6 @@ const fetchAccountFail = (id, error) => ({
type: ACCOUNT_FETCH_FAIL, type: ACCOUNT_FETCH_FAIL,
id, id,
error, error,
skipAlert: true,
}) })
/** /**
@ -178,12 +177,14 @@ const followAccountRequest = (id, locked) => ({
const followAccountSuccess = (relationship, alreadyFollowing) => ({ const followAccountSuccess = (relationship, alreadyFollowing) => ({
type: ACCOUNT_FOLLOW_SUCCESS, type: ACCOUNT_FOLLOW_SUCCESS,
showToast: true,
relationship, relationship,
alreadyFollowing, alreadyFollowing,
}) })
const followAccountFail = (error, locked) => ({ const followAccountFail = (error, locked) => ({
type: ACCOUNT_FOLLOW_FAIL, type: ACCOUNT_FOLLOW_FAIL,
showToast: true,
error, error,
locked, locked,
}) })
@ -210,12 +211,14 @@ const unfollowAccountRequest = (id) => ({
const unfollowAccountSuccess = (relationship, statuses) => ({ const unfollowAccountSuccess = (relationship, statuses) => ({
type: ACCOUNT_UNFOLLOW_SUCCESS, type: ACCOUNT_UNFOLLOW_SUCCESS,
showToast: true,
relationship, relationship,
statuses, statuses,
}) })
const unfollowAccountFail = (error) => ({ const unfollowAccountFail = (error) => ({
type: ACCOUNT_UNFOLLOW_FAIL, type: ACCOUNT_UNFOLLOW_FAIL,
showToast: true,
error, error,
}) })
@ -243,12 +246,14 @@ const blockAccountRequest = (id) => ({
const blockAccountSuccess = (relationship, statuses) => ({ const blockAccountSuccess = (relationship, statuses) => ({
type: ACCOUNT_BLOCK_SUCCESS, type: ACCOUNT_BLOCK_SUCCESS,
showToast: true,
relationship, relationship,
statuses, statuses,
}) })
const blockAccountFail = (error) => ({ const blockAccountFail = (error) => ({
type: ACCOUNT_BLOCK_FAIL, type: ACCOUNT_BLOCK_FAIL,
showToast: true,
error, error,
}) })
@ -274,11 +279,13 @@ const unblockAccountRequest = (id) => ({
const unblockAccountSuccess = (relationship) => ({ const unblockAccountSuccess = (relationship) => ({
type: ACCOUNT_UNBLOCK_SUCCESS, type: ACCOUNT_UNBLOCK_SUCCESS,
showToast: true,
relationship, relationship,
}) })
const unblockAccountFail = (error) => ({ const unblockAccountFail = (error) => ({
type: ACCOUNT_UNBLOCK_FAIL, type: ACCOUNT_UNBLOCK_FAIL,
showToast: true,
error, error,
}) })
@ -305,12 +312,14 @@ const muteAccountRequest = (id) => ({
const muteAccountSuccess = (relationship, statuses) => ({ const muteAccountSuccess = (relationship, statuses) => ({
type: ACCOUNT_MUTE_SUCCESS, type: ACCOUNT_MUTE_SUCCESS,
showToast: true,
relationship, relationship,
statuses, statuses,
}) })
const muteAccountFail = (error) => ({ const muteAccountFail = (error) => ({
type: ACCOUNT_MUTE_FAIL, type: ACCOUNT_MUTE_FAIL,
showToast: true,
error, error,
}) })
@ -336,11 +345,13 @@ const unmuteAccountRequest = (id) => ({
const unmuteAccountSuccess = (relationship) => ({ const unmuteAccountSuccess = (relationship) => ({
type: ACCOUNT_UNMUTE_SUCCESS, type: ACCOUNT_UNMUTE_SUCCESS,
showToast: true,
relationship, relationship,
}) })
const unmuteAccountFail = (error) => ({ const unmuteAccountFail = (error) => ({
type: ACCOUNT_UNMUTE_FAIL, type: ACCOUNT_UNMUTE_FAIL,
showToast: true,
error, error,
}) })
@ -377,6 +388,7 @@ const fetchFollowersSuccess = (id, accounts, next) => ({
const fetchFollowersFail = (id, error) => ({ const fetchFollowersFail = (id, error) => ({
type: FOLLOWERS_FETCH_FAIL, type: FOLLOWERS_FETCH_FAIL,
showToast: true,
id, id,
error, error,
}) })
@ -419,6 +431,7 @@ const expandFollowersSuccess = (id, accounts, next) => ({
const expandFollowersFail = (id, error) => ({ const expandFollowersFail = (id, error) => ({
type: FOLLOWERS_EXPAND_FAIL, type: FOLLOWERS_EXPAND_FAIL,
showToast: true,
id, id,
error, error,
}) })
@ -456,6 +469,7 @@ const fetchFollowingSuccess = (id, accounts, next) => ({
const fetchFollowingFail = (id, error) => ({ const fetchFollowingFail = (id, error) => ({
type: FOLLOWING_FETCH_FAIL, type: FOLLOWING_FETCH_FAIL,
showToast: true,
id, id,
error, error,
}) })
@ -498,6 +512,7 @@ const expandFollowingSuccess = (id, accounts, next) => ({
const expandFollowingFail = (id, error) => ({ const expandFollowingFail = (id, error) => ({
type: FOLLOWING_EXPAND_FAIL, type: FOLLOWING_EXPAND_FAIL,
showToast: true,
id, id,
error, error,
}) })
@ -575,6 +590,7 @@ const fetchFollowRequestsSuccess = (accounts, next) => ({
const fetchFollowRequestsFail = (error) => ({ const fetchFollowRequestsFail = (error) => ({
type: FOLLOW_REQUESTS_FETCH_FAIL, type: FOLLOW_REQUESTS_FETCH_FAIL,
showToast: true,
error, error,
}) })
@ -610,6 +626,7 @@ const expandFollowRequestsSuccess = (accounts, next) => ({
const expandFollowRequestsFail = (error) => ({ const expandFollowRequestsFail = (error) => ({
type: FOLLOW_REQUESTS_EXPAND_FAIL, type: FOLLOW_REQUESTS_EXPAND_FAIL,
showToast: true,
error, error,
}) })
@ -634,11 +651,13 @@ const authorizeFollowRequestRequest = (id) => ({
const authorizeFollowRequestSuccess = (id) => ({ const authorizeFollowRequestSuccess = (id) => ({
type: FOLLOW_REQUEST_AUTHORIZE_SUCCESS, type: FOLLOW_REQUEST_AUTHORIZE_SUCCESS,
showToast: true,
id, id,
}) })
const authorizeFollowRequestFail = (id, error) => ({ const authorizeFollowRequestFail = (id, error) => ({
type: FOLLOW_REQUEST_AUTHORIZE_FAIL, type: FOLLOW_REQUEST_AUTHORIZE_FAIL,
showToast: true,
id, id,
error, error,
}) })
@ -664,11 +683,13 @@ const rejectFollowRequestRequest = (id) => ({
const rejectFollowRequestSuccess = (id) => ({ const rejectFollowRequestSuccess = (id) => ({
type: FOLLOW_REQUEST_REJECT_SUCCESS, type: FOLLOW_REQUEST_REJECT_SUCCESS,
showToast: true,
id, id,
}) })
const rejectFollowRequestFail = (id, error) => ({ const rejectFollowRequestFail = (id, error) => ({
type: FOLLOW_REQUEST_REJECT_FAIL, type: FOLLOW_REQUEST_REJECT_FAIL,
showToast: true,
id, id,
error, error,
}) })

View File

@ -39,6 +39,7 @@ export const fetchBlocksSuccess = (accounts, next) => ({
export const fetchBlocksFail = (error) => ({ export const fetchBlocksFail = (error) => ({
type: BLOCKS_FETCH_FAIL, type: BLOCKS_FETCH_FAIL,
showToast: true,
error, error,
}) })
@ -75,5 +76,6 @@ export const expandBlocksSuccess = (accounts, next) => ({
export const expandBlocksFail = (error) => ({ export const expandBlocksFail = (error) => ({
type: BLOCKS_EXPAND_FAIL, type: BLOCKS_EXPAND_FAIL,
showToast: true,
error, error,
}) })

View File

@ -43,6 +43,7 @@ const fetchBookmarkedStatusesSuccess = (statuses, next) => ({
const fetchBookmarkedStatusesFail = (error) => ({ const fetchBookmarkedStatusesFail = (error) => ({
type: BOOKMARKED_STATUSES_FETCH_FAIL, type: BOOKMARKED_STATUSES_FETCH_FAIL,
showToast: true,
error, error,
}) })
@ -81,5 +82,6 @@ const expandBookmarkedStatusesSuccess = (statuses, next) => ({
const expandBookmarkedStatusesFail = (error) => ({ const expandBookmarkedStatusesFail = (error) => ({
type: BOOKMARKED_STATUSES_EXPAND_FAIL, type: BOOKMARKED_STATUSES_EXPAND_FAIL,
showToast: true,
error, error,
}) })

View File

@ -106,6 +106,7 @@ export const expandChatMessagesSuccess = (chatConversationId, chatMessages, next
export const expandChatMessagesFail = (chatConversationId, error, isLoadingMore) => ({ export const expandChatMessagesFail = (chatConversationId, error, isLoadingMore) => ({
type: CHAT_CONVERSATION_MESSAGES_EXPAND_FAIL, type: CHAT_CONVERSATION_MESSAGES_EXPAND_FAIL,
showToast: true,
chatConversationId, chatConversationId,
error, error,
skipLoading: !isLoadingMore, skipLoading: !isLoadingMore,

View File

@ -48,6 +48,7 @@ export const sendChatMessageSuccess = (chatMessage) => ({
const sendChatMessageFail = (error) => ({ const sendChatMessageFail = (error) => ({
type: CHAT_MESSAGES_SEND_FAIL, type: CHAT_MESSAGES_SEND_FAIL,
showToast: true,
error, error,
}) })
@ -77,9 +78,11 @@ const deleteChatMessageRequest = (chatMessageId) => ({
const deleteChatMessageSuccess = () => ({ const deleteChatMessageSuccess = () => ({
type: CHAT_MESSAGES_DELETE_SUCCESS, type: CHAT_MESSAGES_DELETE_SUCCESS,
showToast: true,
}) })
const deleteChatMessageFail = (error) => ({ const deleteChatMessageFail = (error) => ({
type: CHAT_MESSAGES_DELETE_FAIL, type: CHAT_MESSAGES_DELETE_FAIL,
showToast: true,
error, error,
}) })

View File

@ -398,11 +398,13 @@ const submitComposeRequest = () => ({
const submitComposeSuccess = (status) => ({ const submitComposeSuccess = (status) => ({
type: COMPOSE_SUBMIT_SUCCESS, type: COMPOSE_SUBMIT_SUCCESS,
showToast: true,
status, status,
}) })
const submitComposeFail = (error) => ({ const submitComposeFail = (error) => ({
type: COMPOSE_SUBMIT_FAIL, type: COMPOSE_SUBMIT_FAIL,
showToast: true,
error, error,
}) })
@ -466,6 +468,7 @@ const uploadComposeSuccess = (media) => ({
const uploadComposeFail = (error) => ({ const uploadComposeFail = (error) => ({
type: COMPOSE_UPLOAD_FAIL, type: COMPOSE_UPLOAD_FAIL,
showToast: true,
error, error,
}) })
@ -496,6 +499,7 @@ const changeUploadComposeSuccess = (media) => ({
const changeUploadComposeFail = (error, decrement = false) => ({ const changeUploadComposeFail = (error, decrement = false) => ({
type: COMPOSE_UPLOAD_CHANGE_FAIL, type: COMPOSE_UPLOAD_CHANGE_FAIL,
error, error,
showToast: true,
decrement: decrement, decrement: decrement,
}) })

View File

@ -43,6 +43,7 @@ const fetchFavoritedStatusesSuccess = (statuses, next) => ({
const fetchFavoritedStatusesFail = (error) => ({ const fetchFavoritedStatusesFail = (error) => ({
type: FAVORITED_STATUSES_FETCH_FAIL, type: FAVORITED_STATUSES_FETCH_FAIL,
showToast: true,
error, error,
}) })
@ -81,5 +82,6 @@ const expandFavoritedStatusesSuccess = (statuses, next) => ({
const expandFavoritedStatusesFail = (error) => ({ const expandFavoritedStatusesFail = (error) => ({
type: FAVORITED_STATUSES_EXPAND_FAIL, type: FAVORITED_STATUSES_EXPAND_FAIL,
showToast: true,
error, error,
}) })

View File

@ -30,8 +30,8 @@ const fetchFiltersSuccess = (filters) => ({
filters, filters,
}) })
const fetchFiltersFail = (err) => ({ const fetchFiltersFail = (error) => ({
type: FILTERS_FETCH_FAIL, type: FILTERS_FETCH_FAIL,
err, error,
skipAlert: true, skipAlert: true,
}) })

View File

@ -26,5 +26,6 @@ const fetchGroupCategoriesSuccess = (categories) => ({
const fetchGroupCategoriesFail = (error) => ({ const fetchGroupCategoriesFail = (error) => ({
type: GROUP_CATEGORIES_FETCH_FAIL, type: GROUP_CATEGORIES_FETCH_FAIL,
showToast: true,
error, error,
}) })

View File

@ -100,11 +100,13 @@ const createGroupRequest = (id) => ({
const createSuccess = (group) => ({ const createSuccess = (group) => ({
type: GROUP_CREATE_SUCCESS, type: GROUP_CREATE_SUCCESS,
showToast: true,
group, group,
}) })
const createFail = (error) => ({ const createFail = (error) => ({
type: GROUP_CREATE_FAIL, type: GROUP_CREATE_FAIL,
showToast: true,
error, error,
}) })
@ -151,11 +153,13 @@ const updateGroupRequest = (id) => ({
const updateGroupSuccess = (group) => ({ const updateGroupSuccess = (group) => ({
type: GROUP_UPDATE_SUCCESS, type: GROUP_UPDATE_SUCCESS,
showToast: true,
group, group,
}) })
const updateGroupFail = (error) => ({ const updateGroupFail = (error) => ({
type: GROUP_UPDATE_FAIL, type: GROUP_UPDATE_FAIL,
showToast: true,
error, error,
}) })

View File

@ -153,6 +153,7 @@ const fetchGroupSuccess = (group) => ({
const fetchGroupFail = (groupId, error) => ({ const fetchGroupFail = (groupId, error) => ({
type: GROUP_FETCH_FAIL, type: GROUP_FETCH_FAIL,
showToast: true,
groupId, groupId,
error, error,
}) })
@ -233,6 +234,7 @@ export const fetchGroupsSuccess = (groups, tab) => ({
const fetchGroupsFail = (error, tab) => ({ const fetchGroupsFail = (error, tab) => ({
type: GROUPS_FETCH_FAIL, type: GROUPS_FETCH_FAIL,
showToast: true,
error, error,
tab, tab,
}) })
@ -273,6 +275,7 @@ const fetchGroupsByCategorySuccess = (groups, category) => ({
const fetchGroupsByCategoryFail = (error, category) => ({ const fetchGroupsByCategoryFail = (error, category) => ({
type: GROUPS_BY_CATEGORY_FETCH_FAIL, type: GROUPS_BY_CATEGORY_FETCH_FAIL,
showToast: true,
error, error,
category, category,
}) })
@ -313,6 +316,7 @@ export const fetchGroupsByTagSuccess = (groups, tag) => ({
export const fetchGroupsByTagFail = (error, tag) => ({ export const fetchGroupsByTagFail = (error, tag) => ({
type: GROUPS_BY_TAG_FETCH_FAIL, type: GROUPS_BY_TAG_FETCH_FAIL,
showToast: true,
error, error,
tag, tag,
}) })
@ -340,11 +344,13 @@ const joinGroupRequest = (groupId) => ({
const joinGroupSuccess = (relationship) => ({ const joinGroupSuccess = (relationship) => ({
type: GROUP_JOIN_SUCCESS, type: GROUP_JOIN_SUCCESS,
showToast: true,
relationship relationship
}) })
const joinGroupFail = (error) => ({ const joinGroupFail = (error) => ({
type: GROUP_JOIN_FAIL, type: GROUP_JOIN_FAIL,
showToast: true,
error, error,
}) })
@ -371,11 +377,13 @@ const leaveGroupRequest = (groupId) => ({
const leaveGroupSuccess = (relationship) => ({ const leaveGroupSuccess = (relationship) => ({
type: GROUP_LEAVE_SUCCESS, type: GROUP_LEAVE_SUCCESS,
showToast: true,
relationship, relationship,
}) })
const leaveGroupFail = (error) => ({ const leaveGroupFail = (error) => ({
type: GROUP_LEAVE_FAIL, type: GROUP_LEAVE_FAIL,
showToast: true,
error, error,
}) })
@ -414,6 +422,7 @@ const fetchMembersSuccess = (groupId, accounts, next) => ({
const fetchMembersFail = (groupId, error) => ({ const fetchMembersFail = (groupId, error) => ({
type: GROUP_MEMBERS_FETCH_FAIL, type: GROUP_MEMBERS_FETCH_FAIL,
showToast: true,
groupId, groupId,
error, error,
}) })
@ -458,6 +467,7 @@ const expandMembersSuccess = (groupId, accounts, next) => ({
const expandMembersFail = (groupId, error) => ({ const expandMembersFail = (groupId, error) => ({
type: GROUP_MEMBERS_EXPAND_FAIL, type: GROUP_MEMBERS_EXPAND_FAIL,
showToast: true,
groupId, groupId,
error, error,
}) })
@ -497,6 +507,7 @@ const fetchRemovedAccountsSuccess = (groupId, accounts, next) => ({
const fetchRemovedAccountsFail = (groupId, error) => ({ const fetchRemovedAccountsFail = (groupId, error) => ({
type: GROUP_REMOVED_ACCOUNTS_FETCH_FAIL, type: GROUP_REMOVED_ACCOUNTS_FETCH_FAIL,
showToast: true,
groupId, groupId,
error, error,
}) })
@ -541,6 +552,7 @@ const expandRemovedAccountsSuccess = (groupId, accounts, next) => ({
const expandRemovedAccountsFail = (groupId, error) => ({ const expandRemovedAccountsFail = (groupId, error) => ({
type: GROUP_REMOVED_ACCOUNTS_EXPAND_FAIL, type: GROUP_REMOVED_ACCOUNTS_EXPAND_FAIL,
showToast: true,
groupId, groupId,
error, error,
}) })
@ -570,12 +582,14 @@ const removeRemovedAccountRequest = (groupId, accountId) => ({
const removeRemovedAccountSuccess = (groupId, accountId) => ({ const removeRemovedAccountSuccess = (groupId, accountId) => ({
type: GROUP_REMOVED_ACCOUNTS_REMOVE_SUCCESS, type: GROUP_REMOVED_ACCOUNTS_REMOVE_SUCCESS,
showToast: true,
groupId, groupId,
accountId, accountId,
}) })
const removeRemovedAccountFail = (groupId, accountId, error) => ({ const removeRemovedAccountFail = (groupId, accountId, error) => ({
type: GROUP_REMOVED_ACCOUNTS_REMOVE_FAIL, type: GROUP_REMOVED_ACCOUNTS_REMOVE_FAIL,
showToast: true,
groupId, groupId,
accountId, accountId,
error, error,
@ -606,12 +620,14 @@ const createRemovedAccountRequest = (groupId, accountId) => ({
const createRemovedAccountSuccess = (groupId, accountId) => ({ const createRemovedAccountSuccess = (groupId, accountId) => ({
type: GROUP_REMOVED_ACCOUNTS_CREATE_SUCCESS, type: GROUP_REMOVED_ACCOUNTS_CREATE_SUCCESS,
showToast: true,
groupId, groupId,
accountId, accountId,
}) })
const createRemovedAccountFail = (groupId, accountId, error) => ({ const createRemovedAccountFail = (groupId, accountId, error) => ({
type: GROUP_REMOVED_ACCOUNTS_CREATE_FAIL, type: GROUP_REMOVED_ACCOUNTS_CREATE_FAIL,
showToast: true,
groupId, groupId,
accountId, accountId,
error, error,
@ -643,12 +659,14 @@ const groupRemoveStatusRequest = (groupId, statusId) => ({
const groupRemoveStatusSuccess = (groupId, statusId) => ({ const groupRemoveStatusSuccess = (groupId, statusId) => ({
type: GROUP_REMOVE_STATUS_SUCCESS, type: GROUP_REMOVE_STATUS_SUCCESS,
showToast: true,
groupId, groupId,
statusId, statusId,
}) })
const groupRemoveStatusFail = (groupId, statusId, error) => ({ const groupRemoveStatusFail = (groupId, statusId, error) => ({
type: GROUP_REMOVE_STATUS_FAIL, type: GROUP_REMOVE_STATUS_FAIL,
showToast: true,
groupId, groupId,
statusId, statusId,
error, error,
@ -680,12 +698,14 @@ const updateRoleRequest = (groupId, accountId) => ({
const updateRoleSuccess = (groupId, accountId) => ({ const updateRoleSuccess = (groupId, accountId) => ({
type: GROUP_UPDATE_ROLE_SUCCESS, type: GROUP_UPDATE_ROLE_SUCCESS,
showToast: true,
groupId, groupId,
accountId, accountId,
}) })
const updateRoleFail = (groupId, accountId, error) => ({ const updateRoleFail = (groupId, accountId, error) => ({
type: GROUP_UPDATE_ROLE_FAIL, type: GROUP_UPDATE_ROLE_FAIL,
showToast: true,
groupId, groupId,
accountId, accountId,
error, error,
@ -760,6 +780,7 @@ const fetchJoinRequestsSuccess = (id, accounts, next) => ({
const fetchJoinRequestsFail = (id, error) => ({ const fetchJoinRequestsFail = (id, error) => ({
type: GROUP_JOIN_REQUESTS_FETCH_FAIL, type: GROUP_JOIN_REQUESTS_FETCH_FAIL,
showToast: true,
id, id,
error, error,
}) })
@ -802,6 +823,7 @@ const expandJoinRequestsSuccess = (id, accounts, next) => ({
const expandJoinRequestsFail = (id, error) => ({ const expandJoinRequestsFail = (id, error) => ({
type: GROUP_JOIN_REQUESTS_EXPAND_FAIL, type: GROUP_JOIN_REQUESTS_EXPAND_FAIL,
showToast: true,
id, id,
error, error,
}) })
@ -821,12 +843,14 @@ export const approveJoinRequest = (accountId, groupId) => (dispatch, getState) =
const approveJoinRequestSuccess = (accountId, groupId) => ({ const approveJoinRequestSuccess = (accountId, groupId) => ({
type: GROUP_JOIN_REQUESTS_APPROVE_SUCCESS, type: GROUP_JOIN_REQUESTS_APPROVE_SUCCESS,
showToast: true,
accountId, accountId,
groupId, groupId,
}) })
const approveJoinRequestFail = (accountId, groupId, error) => ({ const approveJoinRequestFail = (accountId, groupId, error) => ({
type: GROUP_JOIN_REQUESTS_APPROVE_FAIL, type: GROUP_JOIN_REQUESTS_APPROVE_FAIL,
showToast: true,
accountId, accountId,
groupId, groupId,
error, error,
@ -847,12 +871,14 @@ export const rejectJoinRequest = (accountId, groupId) => (dispatch, getState) =>
const rejectJoinRequestSuccess = (accountId, groupId) => ({ const rejectJoinRequestSuccess = (accountId, groupId) => ({
type: GROUP_JOIN_REQUESTS_REJECT_SUCCESS, type: GROUP_JOIN_REQUESTS_REJECT_SUCCESS,
showToast: true,
accountId, accountId,
groupId, groupId,
}) })
const rejectJoinRequestFail = (accountId, groupId, error) => ({ const rejectJoinRequestFail = (accountId, groupId, error) => ({
type: GROUP_JOIN_REQUESTS_REJECT_FAIL, type: GROUP_JOIN_REQUESTS_REJECT_FAIL,
showToast: true,
accountId, accountId,
groupId, groupId,
error, error,
@ -881,12 +907,14 @@ const pinGroupStatusRequest = (groupId) => ({
const pinGroupStatusSuccess = (groupId, statusId) => ({ const pinGroupStatusSuccess = (groupId, statusId) => ({
type: GROUP_PIN_STATUS_SUCCESS, type: GROUP_PIN_STATUS_SUCCESS,
showToast: true,
groupId, groupId,
statusId, statusId,
}) })
const pinGroupStatusFail = (groupId, statusId, error) => ({ const pinGroupStatusFail = (groupId, statusId, error) => ({
type: GROUP_PIN_STATUS_FAIL, type: GROUP_PIN_STATUS_FAIL,
showToast: true,
groupId, groupId,
statusId, statusId,
error, error,
@ -915,12 +943,14 @@ const unpinGroupStatusRequest = (groupId) => ({
const unpinGroupStatusSuccess = (groupId, statusId) => ({ const unpinGroupStatusSuccess = (groupId, statusId) => ({
type: GROUP_UNPIN_STATUS_SUCCESS, type: GROUP_UNPIN_STATUS_SUCCESS,
showToast: true,
groupId, groupId,
statusId, statusId,
}) })
const unpinGroupStatusFail = (groupId, statusId, error) => ({ const unpinGroupStatusFail = (groupId, statusId, error) => ({
type: GROUP_UNPIN_STATUS_FAIL, type: GROUP_UNPIN_STATUS_FAIL,
showToast: true,
groupId, groupId,
statusId, statusId,
error, error,

View File

@ -557,6 +557,7 @@ const expandLikesSuccess = (statusId, accounts, next) => ({
const expandLikesFail = (statusId, error) => ({ const expandLikesFail = (statusId, error) => ({
type: LIKES_EXPAND_FAIL, type: LIKES_EXPAND_FAIL,
showToast: true,
statusId, statusId,
error, error,
}) })

View File

@ -109,6 +109,7 @@ const fetchListsSuccess = (lists) => ({
const fetchListsFail = (error) => ({ const fetchListsFail = (error) => ({
type: LISTS_FETCH_FAIL, type: LISTS_FETCH_FAIL,
showToast: true,
error, error,
}) })
@ -169,11 +170,13 @@ export const createListRequest = () => ({
export const createListSuccess = (list) => ({ export const createListSuccess = (list) => ({
type: LIST_CREATE_SUCCESS, type: LIST_CREATE_SUCCESS,
showToast: true,
list, list,
}) })
export const createListFail = (error) => ({ export const createListFail = (error) => ({
type: LIST_CREATE_FAIL, type: LIST_CREATE_FAIL,
showToast: true,
error, error,
}) })
@ -201,11 +204,13 @@ export const updateListRequest = id => ({
export const updateListSuccess = list => ({ export const updateListSuccess = list => ({
type: LIST_UPDATE_SUCCESS, type: LIST_UPDATE_SUCCESS,
showToast: true,
list, list,
}) })
export const updateListFail = (id, error) => ({ export const updateListFail = (id, error) => ({
type: LIST_UPDATE_FAIL, type: LIST_UPDATE_FAIL,
showToast: true,
id, id,
error, error,
}) })
@ -234,11 +239,13 @@ export const deleteListRequest = (id) => ({
export const deleteListSuccess = (id) => ({ export const deleteListSuccess = (id) => ({
type: LIST_DELETE_SUCCESS, type: LIST_DELETE_SUCCESS,
showToast: true,
id, id,
}) })
export const deleteListFail = (id, error) => ({ export const deleteListFail = (id, error) => ({
type: LIST_DELETE_FAIL, type: LIST_DELETE_FAIL,
showToast: true,
id, id,
error, error,
}) })
@ -271,6 +278,7 @@ export const fetchListAccountsSuccess = (id, accounts, next) => ({
export const fetchListAccountsFail = (id, error) => ({ export const fetchListAccountsFail = (id, error) => ({
type: LIST_ACCOUNTS_FETCH_FAIL, type: LIST_ACCOUNTS_FETCH_FAIL,
showToast: true,
id, id,
error, error,
}) })
@ -346,12 +354,14 @@ const addToListRequest = (listId, accountId) => ({
const addToListSuccess = (listId, accountId) => ({ const addToListSuccess = (listId, accountId) => ({
type: LIST_EDITOR_ADD_SUCCESS, type: LIST_EDITOR_ADD_SUCCESS,
showToast: true,
listId, listId,
accountId, accountId,
}) })
const addToListFail = (listId, accountId, error) => ({ const addToListFail = (listId, accountId, error) => ({
type: LIST_EDITOR_ADD_FAIL, type: LIST_EDITOR_ADD_FAIL,
showToast: true,
listId, listId,
accountId, accountId,
error, error,
@ -385,12 +395,14 @@ const removeFromListRequest = (listId, accountId) => ({
const removeFromListSuccess = (listId, accountId) => ({ const removeFromListSuccess = (listId, accountId) => ({
type: LIST_EDITOR_REMOVE_SUCCESS, type: LIST_EDITOR_REMOVE_SUCCESS,
showToast: true,
listId, listId,
accountId, accountId,
}) })
const removeFromListFail = (listId, accountId, error) => ({ const removeFromListFail = (listId, accountId, error) => ({
type: LIST_EDITOR_REMOVE_FAIL, type: LIST_EDITOR_REMOVE_FAIL,
showToast: true,
listId, listId,
accountId, accountId,
error, error,
@ -439,10 +451,11 @@ const fetchAccountListsSuccess = (id, lists) => ({
lists, lists,
}) })
const fetchAccountListsFail = (id, err) => ({ const fetchAccountListsFail = (id, error) => ({
type: LIST_ADDER_LISTS_FETCH_FAIL, type: LIST_ADDER_LISTS_FETCH_FAIL,
showToast: true,
id, id,
err, error,
}) })
/** /**

View File

@ -43,6 +43,7 @@ const fetchMutesSuccess = (accounts, next) => ({
const fetchMutesFail = (error) => ({ const fetchMutesFail = (error) => ({
type: MUTES_FETCH_FAIL, type: MUTES_FETCH_FAIL,
showToast: true,
error, error,
}) })
@ -79,6 +80,7 @@ const expandMutesSuccess = (accounts, next) => ({
export const expandMutesFail = (error) => ({ export const expandMutesFail = (error) => ({
type: MUTES_EXPAND_FAIL, type: MUTES_EXPAND_FAIL,
showToast: true,
error, error,
}) })

View File

@ -218,6 +218,7 @@ const expandNotificationsSuccess = (notifications, next, isLoadingMore) => ({
const expandNotificationsFail = (error, isLoadingMore) => ({ const expandNotificationsFail = (error, isLoadingMore) => ({
type: NOTIFICATIONS_EXPAND_FAIL, type: NOTIFICATIONS_EXPAND_FAIL,
error, error,
showToast: true,
skipLoading: !isLoadingMore, skipLoading: !isLoadingMore,
}) })

View File

@ -29,11 +29,13 @@ const voteRequest = () => ({
const voteSuccess = (poll) => ({ const voteSuccess = (poll) => ({
type: POLL_VOTE_SUCCESS, type: POLL_VOTE_SUCCESS,
showToast: true,
poll, poll,
}) })
const voteFail = (error) => ({ const voteFail = (error) => ({
type: POLL_VOTE_FAIL, type: POLL_VOTE_FAIL,
showToast: true,
error, error,
}) })

View File

@ -65,11 +65,13 @@ const submitReportRequest = () => ({
const submitReportSuccess = (report) => ({ const submitReportSuccess = (report) => ({
type: REPORT_SUBMIT_SUCCESS, type: REPORT_SUBMIT_SUCCESS,
showToast: true,
report, report,
}) })
const submitReportFail = (error) => ({ const submitReportFail = (error) => ({
type: REPORT_SUBMIT_FAIL, type: REPORT_SUBMIT_FAIL,
showToast: true,
error, error,
}) })

View File

@ -86,6 +86,7 @@ const fetchSearchSuccess = (results) => ({
const fetchSearchFail = (error) => ({ const fetchSearchFail = (error) => ({
type: SEARCH_FETCH_FAIL, type: SEARCH_FETCH_FAIL,
showToast: true,
error, error,
}) })

View File

@ -107,10 +107,12 @@ const removeShortcutsRequest = () => ({
const removeShortcutsSuccess = (shortcutId) => ({ const removeShortcutsSuccess = (shortcutId) => ({
type: SHORTCUTS_REMOVE_SUCCESS, type: SHORTCUTS_REMOVE_SUCCESS,
showToast: true,
shortcutId, shortcutId,
}) })
const removeShortcutsFail = (error) => ({ const removeShortcutsFail = (error) => ({
type: SHORTCUTS_REMOVE_FAIL, type: SHORTCUTS_REMOVE_FAIL,
showToast: true,
error, error,
}) })

View File

@ -11,7 +11,7 @@ export const loadStatusRevisions = (statusId) => (dispatch, getState) => {
dispatch(loadStatusRevisionsRequest()) dispatch(loadStatusRevisionsRequest())
api(getState).get(`/api/v1/statuses/${statusId}/revisions`) api(getState).get(`/api/v1/statuses/${statusId}/revisions`)
.then(res => dispatch(loadStatusRevisionsSuccess(res.data))) .then(res => dispatch(loadStatusRevisionsSuccess(res.data)))
.catch(() => dispatch(loadStatusRevisionsFail())) .catch((error) => dispatch(loadStatusRevisionsFail(error)))
} }
const loadStatusRevisionsRequest = () => ({ const loadStatusRevisionsRequest = () => ({
@ -23,7 +23,8 @@ const loadStatusRevisionsSuccess = (data) => ({
revisions: data, revisions: data,
}) })
const loadStatusRevisionsFail = () => ({ const loadStatusRevisionsFail = (error) => ({
type: STATUS_REVISIONS_LOAD_FAIL, type: STATUS_REVISIONS_LOAD_FAIL,
error: true, showToast: true,
}) error,
})

View File

@ -250,6 +250,7 @@ const fetchCommentsSuccess = (id, descendants) => ({
const fetchCommentsFail = (id, error) => ({ const fetchCommentsFail = (id, error) => ({
type: COMMENTS_FETCH_FAIL, type: COMMENTS_FETCH_FAIL,
showToast: true,
id, id,
error, error,
skipAlert: true, skipAlert: true,

View File

@ -180,6 +180,7 @@ const expandTimelineSuccess = (timeline, statuses, next, partial, isLoadingRecen
const expandTimelineFail = (timeline, error, isLoadingMore) => ({ const expandTimelineFail = (timeline, error, isLoadingMore) => ({
type: TIMELINE_EXPAND_FAIL, type: TIMELINE_EXPAND_FAIL,
showToast: true,
timeline, timeline,
error, error,
skipLoading: !isLoadingMore, skipLoading: !isLoadingMore,

View File

@ -1,8 +1,3 @@
import {
TOAST_TYPE_ERROR,
TOAST_TYPE_SUCCESS,
} from '../constants'
export const TOAST_SHOW = 'TOAST_SHOW' export const TOAST_SHOW = 'TOAST_SHOW'
export const TOAST_DISMISS = 'TOAST_DISMISS' export const TOAST_DISMISS = 'TOAST_DISMISS'
export const TOAST_CLEAR = 'TOAST_CLEAR' 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, 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, type: TOAST_SHOW,
toastType: type, toastType,
message, 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)
}

View File

@ -44,11 +44,13 @@ const saveUserProfileInformationRequest = () => ({
const saveUserProfileInformationSuccess = (userProfileData) => ({ const saveUserProfileInformationSuccess = (userProfileData) => ({
type: SAVE_USER_PROFILE_INFORMATION_FETCH_SUCCESS, type: SAVE_USER_PROFILE_INFORMATION_FETCH_SUCCESS,
showToast: true,
userProfileData, userProfileData,
}) })
const saveUserProfileInformationFail = (error) => ({ const saveUserProfileInformationFail = (error) => ({
type: SAVE_USER_PROFILE_INFORMATION_FETCH_FAIL, type: SAVE_USER_PROFILE_INFORMATION_FETCH_FAIL,
showToast: true,
error, error,
}) })

View File

@ -8,60 +8,63 @@ import Toast from '../components/toast'
class ToastsContainer extends React.PureComponent { class ToastsContainer extends React.PureComponent {
handleOnDismiss = (key) => { handleOnDismiss = (toastKey) => {
this.props.dispatch(dismissToast(key)) this.props.dispatch(dismissToast(toastKey))
} }
render() { render() {
// const { notifications } = this.props 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 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({ const containerClasses = CX({
d: 1, d: 1,
@ -80,17 +83,17 @@ class ToastsContainer extends React.PureComponent {
return ( return (
<div className={containerClasses}> <div className={containerClasses}>
{ {
!hasNotifications && notifications.map((notification) => ( hasNotifications && notifications.map((notification) => (
<Toast <Toast
onDismiss={this.handleOnDismiss} onDismiss={this.handleOnDismiss}
key={notification.key} id={notification.get('key')}
id={notification.key} key={`toast-${notification.get('key')}`}
title={notification.title} title={notification.get('title', '')}
to={notification.to} to={notification.get('to', null)}
image={notification.image} image={notification.get('image', null)}
message={notification.message} message={notification.get('message', null)}
date={notification.date} date={notification.get('date', null)}
isImageAccount={notification.isImageAccount} isImageAccount={notification.get('isImageAccount', null)}
/> />
)) ))
} }
@ -101,11 +104,9 @@ class ToastsContainer extends React.PureComponent {
} }
const mapStateToProps = (state) => { const mapStateToProps = (state) => ({
const notifications = getToasts(state) notifications: state.get('toasts')
if (!notifications) return {} })
return { notifications }
}
ToastsContainer.propTypes = { ToastsContainer.propTypes = {
notifications: PropTypes.array, notifications: PropTypes.array,

View File

@ -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() { export default function errorsMiddleware() {
return ({ dispatch }) => next => action => { return ({ dispatch }) => (next) => (action) => {
// : todo : use skipAlert! if (isObject(action) && action.type && action.showToast) {
if (action.type && !action.skipAlert) { const isFail = new RegExp(`${defaultFailSuffix}$`, 'g')
const isFail = new RegExp(`${defaultFailSuffix}$`, 'g'); const isSuccess = new RegExp(`${defaultSuccessSuffix}$`, 'g')
if (action.type.match(isFail)) { 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)
}; }
}; }

View File

@ -1,3 +1,4 @@
import isObject from 'lodash.isobject'
import { showLoading, hideLoading } from 'react-redux-loading-bar' import { showLoading, hideLoading } from 'react-redux-loading-bar'
const defaultTypeSuffixes = ['PENDING', 'FULFILLED', 'REJECTED'] const defaultTypeSuffixes = ['PENDING', 'FULFILLED', 'REJECTED']
@ -5,8 +6,8 @@ const defaultTypeSuffixes = ['PENDING', 'FULFILLED', 'REJECTED']
export default function loadingBarMiddleware(config = {}) { export default function loadingBarMiddleware(config = {}) {
const promiseTypeSuffixes = config.promiseTypeSuffixes || defaultTypeSuffixes const promiseTypeSuffixes = config.promiseTypeSuffixes || defaultTypeSuffixes
return ({ dispatch }) => next => (action) => { return ({ dispatch }) => (next) => (action) => {
if (action.type && action.type.indexOf('TIMELINE') > -1) { if (isObject(action) && action.type && action.type.indexOf('TIMELINE') > -1) {
const [PENDING, FULFILLED, REJECTED] = promiseTypeSuffixes const [PENDING, FULFILLED, REJECTED] = promiseTypeSuffixes
const isPending = new RegExp(`${PENDING}$`, 'g') const isPending = new RegExp(`${PENDING}$`, 'g')

View File

@ -10,13 +10,13 @@ const initialState = ImmutableList([])
export default function toasts(state = initialState, action) { export default function toasts(state = initialState, action) {
switch(action.type) { switch(action.type) {
case TOAST_SHOW: case TOAST_SHOW:
return state.push(ImmutableMap({ return state.set(state.size, ImmutableMap({
key: state.size > 0 ? state.last().get('key') + 1 : 0, key: state.size > 0 ? state.last().get('key') + 1 : 0,
message: action.message, message: 'action.message',
type: action.toastType, type: action.toastType,
})) }))
case TOAST_DISMISS: 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: case TOAST_CLEAR:
return state.clear() return state.clear()
default: default: