Progress
This commit is contained in:
1
app/javascript/gabsocial/actions/albums.js
Normal file
1
app/javascript/gabsocial/actions/albums.js
Normal file
@@ -0,0 +1 @@
|
||||
//
|
||||
@@ -10,6 +10,20 @@ export const BOOKMARKED_STATUSES_EXPAND_REQUEST = 'BOOKMARKED_STATUSES_EXPAND_RE
|
||||
export const BOOKMARKED_STATUSES_EXPAND_SUCCESS = 'BOOKMARKED_STATUSES_EXPAND_SUCCESS'
|
||||
export const BOOKMARKED_STATUSES_EXPAND_FAIL = 'BOOKMARKED_STATUSES_EXPAND_FAIL'
|
||||
|
||||
//
|
||||
|
||||
export const BOOKMARK_COLLECTIONS_FETCH_REQUEST = 'BOOKMARK_COLLECTIONS_FETCH_REQUEST'
|
||||
export const BOOKMARK_COLLECTIONS_FETCH_SUCCESS = 'BOOKMARK_COLLECTIONS_FETCH_SUCCESS'
|
||||
export const BOOKMARK_COLLECTIONS_FETCH_FAIL = 'BOOKMARK_COLLECTIONS_FETCH_FAIL'
|
||||
|
||||
export const BOOKMARK_COLLECTIONS_CREATE_REQUEST = 'BOOKMARK_COLLECTIONS_CREATE_REQUEST'
|
||||
export const BOOKMARK_COLLECTIONS_CREATE_SUCCESS = 'BOOKMARK_COLLECTIONS_CREATE_SUCCESS'
|
||||
export const BOOKMARK_COLLECTIONS_CREATE_FAIL = 'BOOKMARK_COLLECTIONS_CREATE_FAIL'
|
||||
|
||||
export const BOOKMARK_COLLECTIONS_REMOVE_REQUEST = 'BOOKMARK_COLLECTIONS_REMOVE_REQUEST'
|
||||
export const BOOKMARK_COLLECTIONS_REMOVE_SUCCESS = 'BOOKMARK_COLLECTIONS_REMOVE_SUCCESS'
|
||||
export const BOOKMARK_COLLECTIONS_REMOVE_FAIL = 'BOOKMARK_COLLECTIONS_REMOVE_FAIL'
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@@ -22,11 +36,11 @@ export const fetchBookmarkedStatuses = () => (dispatch, getState) => {
|
||||
|
||||
dispatch(fetchBookmarkedStatusesRequest())
|
||||
|
||||
api(getState).get('/api/v1/bookmarks').then(response => {
|
||||
api(getState).get('/api/v1/bookmarks').then((response) => {
|
||||
const next = getLinks(response).refs.find(link => link.rel === 'next')
|
||||
dispatch(importFetchedStatuses(response.data))
|
||||
dispatch(fetchBookmarkedStatusesSuccess(response.data, next ? next.uri : null))
|
||||
}).catch(error => {
|
||||
}).catch((error) => {
|
||||
dispatch(fetchBookmarkedStatusesFail(error))
|
||||
})
|
||||
}
|
||||
@@ -61,11 +75,11 @@ export const expandBookmarkedStatuses = () => (dispatch, getState) => {
|
||||
|
||||
dispatch(expandBookmarkedStatusesRequest())
|
||||
|
||||
api(getState).get(url).then(response => {
|
||||
api(getState).get(url).then((response) => {
|
||||
const next = getLinks(response).refs.find(link => link.rel === 'next')
|
||||
dispatch(importFetchedStatuses(response.data))
|
||||
dispatch(expandBookmarkedStatusesSuccess(response.data, next ? next.uri : null))
|
||||
}).catch(error => {
|
||||
}).catch((error) => {
|
||||
dispatch(expandBookmarkedStatusesFail(error))
|
||||
})
|
||||
}
|
||||
@@ -85,3 +99,95 @@ const expandBookmarkedStatusesFail = (error) => ({
|
||||
showToast: true,
|
||||
error,
|
||||
})
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
export const fetchBookmarkCollections = () => (dispatch, getState) => {
|
||||
if (!me) return
|
||||
|
||||
if (getState().getIn(['bookmark_collections', 'isLoading'])) return
|
||||
|
||||
dispatch(fetchBookmarkCollectionsRequest())
|
||||
|
||||
api(getState).get('/api/v1/bookmark_collections').then((response) => {
|
||||
dispatch(fetchBookmarkCollectionsSuccess(response.data))
|
||||
}).catch((error) => {
|
||||
dispatch(fetchBookmarkCollectionsFail(error))
|
||||
})
|
||||
}
|
||||
|
||||
const fetchBookmarkCollectionsRequest = () => ({
|
||||
type: BOOKMARK_COLLECTIONS_FETCH_REQUEST,
|
||||
})
|
||||
|
||||
const fetchBookmarkCollectionsSuccess = (bookmarkCollections) => ({
|
||||
type: BOOKMARK_COLLECTIONS_FETCH_SUCCESS,
|
||||
bookmarkCollections,
|
||||
})
|
||||
|
||||
const fetchBookmarkCollectionsFail = (error) => ({
|
||||
type: BOOKMARK_COLLECTIONS_FETCH_FAIL,
|
||||
showToast: true,
|
||||
error,
|
||||
})
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
export const createBookmarkCollection = (title) => (dispatch, getState) => {
|
||||
if (!me || !title) return
|
||||
|
||||
dispatch(createBookmarkCollectionRequest())
|
||||
|
||||
api(getState).post('/api/v1/bookmark_collections', { title }).then((response) => {
|
||||
dispatch(createBookmarkCollectionSuccess(response.data))
|
||||
}).catch((error) => {
|
||||
dispatch(createBookmarkCollectionFail(error))
|
||||
})
|
||||
}
|
||||
|
||||
const createBookmarkCollectionRequest = () => ({
|
||||
type: BOOKMARK_COLLECTIONS_CREATE_REQUEST,
|
||||
})
|
||||
|
||||
const createBookmarkCollectionSuccess = (bookmarkCollection) => ({
|
||||
type: BOOKMARK_COLLECTIONS_CREATE_SUCCESS,
|
||||
bookmarkCollection,
|
||||
})
|
||||
|
||||
const createBookmarkCollectionFail = (error) => ({
|
||||
type: BOOKMARK_COLLECTIONS_CREATE_FAIL,
|
||||
showToast: true,
|
||||
error,
|
||||
})
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
export const removeBookmarkCollection = (bookmarkCollectionId) => (dispatch, getState) => {
|
||||
if (!me || !bookmarkCollectionId) return
|
||||
|
||||
dispatch(removeBookmarkCollectionRequest(bookmarkCollectionId))
|
||||
|
||||
api(getState).delete(`/api/v1/bookmark_collection/${bookmarkCollectionId}`).then((response) => {
|
||||
dispatch(removeBookmarkCollectionSuccess(response.data))
|
||||
}).catch((error) => {
|
||||
dispatch(removeBookmarkCollectionFail(error))
|
||||
})
|
||||
}
|
||||
|
||||
const removeBookmarkCollectionRequest = (bookmarkCollectionId) => ({
|
||||
type: BOOKMARK_COLLECTIONS_CREATE_REQUEST,
|
||||
bookmarkCollectionId,
|
||||
})
|
||||
|
||||
const removeBookmarkCollectionSuccess = () => ({
|
||||
type: BOOKMARK_COLLECTIONS_CREATE_SUCCESS,
|
||||
})
|
||||
|
||||
const removeBookmarkCollectionFail = (error) => ({
|
||||
type: BOOKMARK_COLLECTIONS_CREATE_FAIL,
|
||||
showToast: true,
|
||||
error,
|
||||
})
|
||||
@@ -46,6 +46,7 @@ export const IS_CHAT_MESSENGER_MUTED_SUCCESS = 'IS_CHAT_MESSENGER_MUTED_SUCCESS'
|
||||
*
|
||||
*/
|
||||
export const blockChatMessenger = (accountId) => (dispatch, getState) => {
|
||||
console.log("blockChatMessenger:", accountId)
|
||||
if (!me || !accountId) return
|
||||
|
||||
dispatch(blockChatMessengerRequest(accountId))
|
||||
|
||||
@@ -44,10 +44,10 @@ export const clearChatMessageConversation = (chatConversationId) => (dispatch) =
|
||||
/**
|
||||
*
|
||||
*/
|
||||
export const scrollBottomChatMessageConversation = (chatConversationId, top) => ({
|
||||
export const scrollBottomChatMessageConversation = (chatConversationId, bottom) => ({
|
||||
type: CHAT_CONVERSATION_MESSAGES_SCROLL_BOTTOM,
|
||||
chatConversationId,
|
||||
top,
|
||||
bottom,
|
||||
})
|
||||
|
||||
/**
|
||||
@@ -56,7 +56,7 @@ export const scrollBottomChatMessageConversation = (chatConversationId, top) =>
|
||||
export const expandChatMessages = (chatConversationId, params = {}, done = noop) => (dispatch, getState) => {
|
||||
if (!me || !chatConversationId) return
|
||||
|
||||
const chatConversation = getState().getIn(['chat_messages', chatConversationId], ImmutableMap())
|
||||
const chatConversation = getState().getIn(['chat_conversations', chatConversationId], ImmutableMap())
|
||||
const isLoadingMore = !!params.maxId
|
||||
|
||||
if (!!chatConversation && (chatConversation.get('isLoading') || chatConversation.get('isError'))) {
|
||||
|
||||
@@ -45,6 +45,22 @@ export const CHAT_CONVERSATION_DELETE_REQUEST = 'CHAT_CONVERSATION_DELETE_REQUES
|
||||
export const CHAT_CONVERSATION_DELETE_SUCCESS = 'CHAT_CONVERSATION_DELETE_SUCCESS'
|
||||
export const CHAT_CONVERSATION_DELETE_FAIL = 'CHAT_CONVERSATION_DELETE_FAIL'
|
||||
|
||||
//
|
||||
|
||||
export const CHAT_CONVERSATION_MARK_READ_FETCH = 'CHAT_CONVERSATION_MARK_READ_FETCH'
|
||||
export const CHAT_CONVERSATION_MARK_READ_SUCCESS = 'CHAT_CONVERSATION_MARK_READ_SUCCESS'
|
||||
export const CHAT_CONVERSATION_MARK_READ_FAIL = 'CHAT_CONVERSATION_MARK_READ_FAIL'
|
||||
|
||||
export const CHAT_CONVERSATION_HIDE_FETCH = 'CHAT_CONVERSATION_HIDE_FETCH'
|
||||
export const CHAT_CONVERSATION_HIDE_SUCCESS = 'CHAT_CONVERSATION_HIDE_SUCCESS'
|
||||
export const CHAT_CONVERSATION_HIDE_FAIL = 'CHAT_CONVERSATION_HIDE_FAIL'
|
||||
|
||||
//
|
||||
|
||||
export const SET_CHAT_CONVERSATION_EXPIRATION_REQUEST = 'SET_CHAT_CONVERSATION_EXPIRATION_REQUEST'
|
||||
export const SET_CHAT_CONVERSATION_EXPIRATION_SUCCESS = 'SET_CHAT_CONVERSATION_EXPIRATION_SUCCESS'
|
||||
export const SET_CHAT_CONVERSATION_EXPIRATION_FAIL = 'SET_CHAT_CONVERSATION_EXPIRATION_FAIL'
|
||||
|
||||
/**
|
||||
* @description Fetch paginated active chat conversations, import accounts and set chat converations
|
||||
*/
|
||||
@@ -309,4 +325,93 @@ export const approveChatConversationRequestSuccess = (chatConversation) => ({
|
||||
|
||||
export const approveChatConversationRequestFail = () => ({
|
||||
type: CHAT_CONVERSATION_REQUEST_APPROVE_FAIL,
|
||||
})
|
||||
})
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
export const hideChatConversation = (chatConversationId) => (dispatch, getState) => {
|
||||
if (!me|| !chatConversationId) return
|
||||
|
||||
dispatch(hideChatConversationFetch(chatConversationId))
|
||||
|
||||
api(getState).post(`/api/v1/chat_conversation/${chatConversationId}/mark_chat_conversation_hidden`).then((response) => {
|
||||
dispatch(approveChatConversationRequestSuccess(chatConversationId))
|
||||
}).catch((error) => dispatch(approveChatConversationRequestFail(error)))
|
||||
}
|
||||
|
||||
export const hideChatConversationFetch = (chatConversationId) => ({
|
||||
type: CHAT_CONVERSATION_HIDE_SUCCESS,
|
||||
chatConversationId,
|
||||
})
|
||||
|
||||
export const hideChatConversationSuccess = (chatConversationId) => ({
|
||||
type: CHAT_CONVERSATION_HIDE_SUCCESS,
|
||||
chatConversationId,
|
||||
})
|
||||
|
||||
export const hideChatConversationFail = () => ({
|
||||
type: CHAT_CONVERSATION_HIDE_FAIL,
|
||||
})
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
export const readChatConversation = (chatConversationId) => (dispatch, getState) => {
|
||||
if (!me|| !chatConversationId) return
|
||||
|
||||
const chatConversation = getState().getIn(['chat_conversations', chatConversationId])
|
||||
if (!chatConversation) return
|
||||
if (chatConversation.get('unread_count') < 1) return
|
||||
|
||||
dispatch(readChatConversationFetch(chatConversation))
|
||||
|
||||
api(getState).post(`/api/v1/chat_conversation/${chatConversationId}/mark_chat_conversation_read`).then((response) => {
|
||||
dispatch(readChatConversationSuccess(response.data))
|
||||
}).catch((error) => dispatch(readChatConversationFail(error)))
|
||||
}
|
||||
|
||||
export const readChatConversationFetch = (chatConversation) => ({
|
||||
type: CHAT_CONVERSATION_MARK_READ_FETCH,
|
||||
chatConversation,
|
||||
})
|
||||
|
||||
export const readChatConversationSuccess = (chatConversation) => ({
|
||||
type: CHAT_CONVERSATION_MARK_READ_SUCCESS,
|
||||
chatConversation,
|
||||
})
|
||||
|
||||
export const readChatConversationFail = () => ({
|
||||
type: CHAT_CONVERSATION_MARK_READ_FAIL,
|
||||
})
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
export const setChatConversationExpiration = (chatConversationId, expiration) => (dispatch, getState) => {
|
||||
if (!me|| !chatConversationId || !expiration) return
|
||||
|
||||
dispatch(setChatConversationExpirationFetch(chatConversation))
|
||||
|
||||
api(getState).post(`/api/v1/chat_conversation/${chatConversationId}/set_expiration_policy`, {
|
||||
expiration,
|
||||
}).then((response) => {
|
||||
dispatch(setChatConversationExpirationSuccess(response.data))
|
||||
}).catch((error) => dispatch(setChatConversationExpirationFail(error)))
|
||||
}
|
||||
|
||||
export const setChatConversationExpirationFetch = (chatConversation) => ({
|
||||
type: SET_CHAT_CONVERSATION_EXPIRATION_REQUEST,
|
||||
chatConversation,
|
||||
})
|
||||
|
||||
export const setChatConversationExpirationSuccess = (chatConversation) => ({
|
||||
type: SET_CHAT_CONVERSATION_EXPIRATION_REQUEST,
|
||||
chatConversation,
|
||||
})
|
||||
|
||||
export const setChatConversationExpirationFail = (error) => ({
|
||||
type: SET_CHAT_CONVERSATION_EXPIRATION_REQUEST,
|
||||
error,
|
||||
})
|
||||
|
||||
|
||||
@@ -56,6 +56,22 @@ const sendChatMessageFail = (error) => ({
|
||||
error,
|
||||
})
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
export const manageIncomingChatMessage = (chatMessage) => (dispatch, getState) => {
|
||||
if (!chatMessage) return
|
||||
|
||||
console.log("chatMessage:", chatMessage)
|
||||
dispatch(sendChatMessageSuccess(chatMessage))
|
||||
|
||||
const isOnline = getState().getIn(['chat_conversation_messages', chatMessage.chat_conversation_id, 'online'])
|
||||
console.log("isOnline: ", isOnline)
|
||||
|
||||
// : todo :
|
||||
// Check if is online for conversation, if not increase total/convo unread count
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@@ -99,24 +115,25 @@ export const purgeChatMessages = (chatConversationId) => (dispatch, getState) =>
|
||||
|
||||
dispatch(deleteChatMessagesRequest(chatConversationId))
|
||||
|
||||
api(getState).delete(`/api/v1/chat_conversations/${chatConversationId}/messages/destroy_all`).then((response) => {
|
||||
api(getState).delete(`/api/v1/chat_conversations/messages/${chatConversationId}/destroy_all`).then((response) => {
|
||||
dispatch(deleteChatMessagesSuccess(response.data))
|
||||
}).catch((error) => {
|
||||
dispatch(deleteChatMessagesFail(error))
|
||||
})
|
||||
}
|
||||
|
||||
const deleteChatMessagesRequest = () => ({
|
||||
const purgeChatMessagesRequest = (chatConversationId) => ({
|
||||
type: CHAT_MESSAGES_PURGE_REQUEST,
|
||||
chatConversationId,
|
||||
})
|
||||
|
||||
const deleteChatMessagesSuccess = (chatConversationId) => ({
|
||||
const purgeChatMessagesSuccess = (chatConversationId) => ({
|
||||
type: CHAT_MESSAGES_PURGE_SUCCESS,
|
||||
chatConversationId,
|
||||
showToast: true,
|
||||
})
|
||||
|
||||
const deleteChatMessagesFail = (error) => ({
|
||||
const purgeChatMessagesFail = (error) => ({
|
||||
type: CHAT_MESSAGES_PURGE_FAIL,
|
||||
showToast: true,
|
||||
error,
|
||||
|
||||
@@ -20,12 +20,12 @@ import { defineMessages } from 'react-intl'
|
||||
import { openModal, closeModal } from './modal'
|
||||
import {
|
||||
MODAL_COMPOSE,
|
||||
STATUS_EXPIRATION_OPTION_5_MINUTES,
|
||||
STATUS_EXPIRATION_OPTION_60_MINUTES,
|
||||
STATUS_EXPIRATION_OPTION_6_HOURS,
|
||||
STATUS_EXPIRATION_OPTION_24_HOURS,
|
||||
STATUS_EXPIRATION_OPTION_3_DAYS,
|
||||
STATUS_EXPIRATION_OPTION_7_DAYS,
|
||||
EXPIRATION_OPTION_5_MINUTES,
|
||||
EXPIRATION_OPTION_60_MINUTES,
|
||||
EXPIRATION_OPTION_6_HOURS,
|
||||
EXPIRATION_OPTION_24_HOURS,
|
||||
EXPIRATION_OPTION_3_DAYS,
|
||||
EXPIRATION_OPTION_7_DAYS,
|
||||
} from '../constants'
|
||||
import { me } from '../initial_state'
|
||||
import { makeGetStatus } from '../selectors'
|
||||
@@ -347,17 +347,17 @@ export const submitCompose = (groupId, replyToId = null, router, isStandalone, a
|
||||
let expires_at = getState().getIn(['compose', 'expires_at'], null)
|
||||
|
||||
if (expires_at) {
|
||||
if (expires_at === STATUS_EXPIRATION_OPTION_5_MINUTES) {
|
||||
if (expires_at === EXPIRATION_OPTION_5_MINUTES) {
|
||||
expires_at = moment.utc().add('5', 'minute').toDate()
|
||||
} else if (expires_at === STATUS_EXPIRATION_OPTION_60_MINUTES) {
|
||||
} else if (expires_at === EXPIRATION_OPTION_60_MINUTES) {
|
||||
expires_at = moment.utc().add('60', 'minute').toDate()
|
||||
} else if (expires_at === STATUS_EXPIRATION_OPTION_6_HOURS) {
|
||||
} else if (expires_at === EXPIRATION_OPTION_6_HOURS) {
|
||||
expires_at = moment.utc().add('6', 'hour').toDate()
|
||||
} else if (expires_at === STATUS_EXPIRATION_OPTION_24_HOURS) {
|
||||
} else if (expires_at === EXPIRATION_OPTION_24_HOURS) {
|
||||
expires_at = moment.utc().add('24', 'hour').toDate()
|
||||
} else if (expires_at === STATUS_EXPIRATION_OPTION_3_DAYS) {
|
||||
} else if (expires_at === EXPIRATION_OPTION_3_DAYS) {
|
||||
expires_at = moment.utc().add('3', 'day').toDate()
|
||||
} else if (expires_at === STATUS_EXPIRATION_OPTION_7_DAYS) {
|
||||
} else if (expires_at === EXPIRATION_OPTION_7_DAYS) {
|
||||
expires_at = moment.utc().add('7', 'day').toDate()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
updateTimelineQueue,
|
||||
} from './timelines'
|
||||
import { updateNotificationsQueue } from './notifications'
|
||||
import { sendChatMessageSuccess } from './chat_messages'
|
||||
import { manageIncomingChatMessage } from './chat_messages'
|
||||
import { fetchFilters } from './filters'
|
||||
import { getLocale } from '../locales'
|
||||
import { handleComposeSubmit } from './compose'
|
||||
@@ -84,7 +84,7 @@ export const connectChatMessagesStream = (accountId) => {
|
||||
onReceive (data) {
|
||||
if (!data['event'] || !data['payload']) return
|
||||
if (data.event === 'notification') {
|
||||
dispatch(sendChatMessageSuccess(JSON.parse(data.payload)))
|
||||
dispatch(manageIncomingChatMessage(JSON.parse(data.payload)))
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user