mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 12:56:41 +07:00
renamed messagesSetMessages to messagesSet
This commit is contained in:
parent
737a4396de
commit
a06e54bd78
4 changed files with 13 additions and 13 deletions
|
@ -57,7 +57,7 @@ import { selectModal } from '~/redux/modal/selectors';
|
||||||
import { IModalState } from '~/redux/modal';
|
import { IModalState } from '~/redux/modal';
|
||||||
import { DIALOGS } from '~/redux/modal/constants';
|
import { DIALOGS } from '~/redux/modal/constants';
|
||||||
import { ERRORS } from '~/constants/errors';
|
import { ERRORS } from '~/constants/errors';
|
||||||
import { messagesSetMessages } from '~/redux/messages/actions';
|
import { messagesSet } from '~/redux/messages/actions';
|
||||||
|
|
||||||
export function* reqWrapper(requestAction, props = {}): ReturnType<typeof requestAction> {
|
export function* reqWrapper(requestAction, props = {}): ReturnType<typeof requestAction> {
|
||||||
const access = yield select(selectToken);
|
const access = yield select(selectToken);
|
||||||
|
@ -155,7 +155,7 @@ function* loadProfile({ username }: ReturnType<typeof authLoadProfile>) {
|
||||||
}
|
}
|
||||||
|
|
||||||
yield put(authSetProfile({ is_loading: false, user }));
|
yield put(authSetProfile({ is_loading: false, user }));
|
||||||
yield put(messagesSetMessages({ messages: [] }));
|
yield put(messagesSet({ messages: [] }));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ export const messagesDeleteMessage = (id: IMessage['id']) => ({
|
||||||
id,
|
id,
|
||||||
});
|
});
|
||||||
|
|
||||||
export const messagesSetMessages = (messages: Partial<IMessagesState>) => ({
|
export const messagesSet = (messages: Partial<IMessagesState>) => ({
|
||||||
type: MESSAGES_ACTIONS.SET_MESSAGES,
|
type: MESSAGES_ACTIONS.SET_MESSAGES,
|
||||||
messages,
|
messages,
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import { MESSAGES_ACTIONS } from '~/redux/messages/constants';
|
import { MESSAGES_ACTIONS } from '~/redux/messages/constants';
|
||||||
import { IMessagesState } from '~/redux/messages';
|
import { IMessagesState } from '~/redux/messages';
|
||||||
import { messagesSetMessages } from '~/redux/messages/actions';
|
import { messagesSet } from '~/redux/messages/actions';
|
||||||
|
|
||||||
const setMessages = (
|
const setMessages = (
|
||||||
state: IMessagesState,
|
state: IMessagesState,
|
||||||
{ messages }: ReturnType<typeof messagesSetMessages>
|
{ messages }: ReturnType<typeof messagesSet>
|
||||||
): IMessagesState => ({
|
): IMessagesState => ({
|
||||||
...state,
|
...state,
|
||||||
...messages,
|
...messages,
|
||||||
|
|
|
@ -5,7 +5,7 @@ import { apiAuthGetUserMessages, apiAuthSendMessage } from '~/redux/auth/api';
|
||||||
import { ERRORS } from '~/constants/errors';
|
import { ERRORS } from '~/constants/errors';
|
||||||
import { IMessageNotification } from '~/redux/types';
|
import { IMessageNotification } from '~/redux/types';
|
||||||
import { reqWrapper } from '~/redux/auth/sagas';
|
import { reqWrapper } from '~/redux/auth/sagas';
|
||||||
import { messagesGetMessages, messagesSendMessage, messagesSetMessages, } from '~/redux/messages/actions';
|
import { messagesGetMessages, messagesSendMessage, messagesSet } from '~/redux/messages/actions';
|
||||||
import { MESSAGES_ACTIONS } from '~/redux/messages/constants';
|
import { MESSAGES_ACTIONS } from '~/redux/messages/constants';
|
||||||
import { selectMessages } from '~/redux/messages/selectors';
|
import { selectMessages } from '~/redux/messages/selectors';
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ function* getMessages({ username }: ReturnType<typeof messagesGetMessages>) {
|
||||||
const { messages }: ReturnType<typeof selectMessages> = yield select(selectMessages);
|
const { messages }: ReturnType<typeof selectMessages> = yield select(selectMessages);
|
||||||
|
|
||||||
yield put(
|
yield put(
|
||||||
messagesSetMessages({
|
messagesSet({
|
||||||
is_loading_messages: true,
|
is_loading_messages: true,
|
||||||
messages:
|
messages:
|
||||||
messages &&
|
messages &&
|
||||||
|
@ -28,14 +28,14 @@ function* getMessages({ username }: ReturnType<typeof messagesGetMessages>) {
|
||||||
|
|
||||||
if (error || !data.messages) {
|
if (error || !data.messages) {
|
||||||
return yield put(
|
return yield put(
|
||||||
messagesSetMessages({
|
messagesSet({
|
||||||
is_loading_messages: false,
|
is_loading_messages: false,
|
||||||
messages_error: ERRORS.EMPTY_RESPONSE,
|
messages_error: ERRORS.EMPTY_RESPONSE,
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
yield put(messagesSetMessages({ is_loading_messages: false, messages: data.messages }));
|
yield put(messagesSet({ is_loading_messages: false, messages: data.messages }));
|
||||||
|
|
||||||
const { notifications } = yield select(selectAuthUpdates);
|
const { notifications } = yield select(selectAuthUpdates);
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ function* sendMessage({ message, onSuccess }: ReturnType<typeof messagesSendMess
|
||||||
|
|
||||||
if (!username) return;
|
if (!username) return;
|
||||||
|
|
||||||
yield put(messagesSetMessages({ is_sending_messages: true, messages_error: null }));
|
yield put(messagesSet({ is_sending_messages: true, messages_error: null }));
|
||||||
|
|
||||||
const { error, data } = yield call(reqWrapper, apiAuthSendMessage, {
|
const { error, data } = yield call(reqWrapper, apiAuthSendMessage, {
|
||||||
username,
|
username,
|
||||||
|
@ -67,7 +67,7 @@ function* sendMessage({ message, onSuccess }: ReturnType<typeof messagesSendMess
|
||||||
|
|
||||||
if (error || !data.message) {
|
if (error || !data.message) {
|
||||||
return yield put(
|
return yield put(
|
||||||
messagesSetMessages({
|
messagesSet({
|
||||||
is_sending_messages: false,
|
is_sending_messages: false,
|
||||||
messages_error: error || ERRORS.EMPTY_RESPONSE,
|
messages_error: error || ERRORS.EMPTY_RESPONSE,
|
||||||
})
|
})
|
||||||
|
@ -77,13 +77,13 @@ function* sendMessage({ message, onSuccess }: ReturnType<typeof messagesSendMess
|
||||||
const { user }: ReturnType<typeof selectAuthProfile> = yield select(selectAuthProfile);
|
const { user }: ReturnType<typeof selectAuthProfile> = yield select(selectAuthProfile);
|
||||||
|
|
||||||
if (user.username !== username) {
|
if (user.username !== username) {
|
||||||
return yield put(messagesSetMessages({ is_sending_messages: false }));
|
return yield put(messagesSet({ is_sending_messages: false }));
|
||||||
}
|
}
|
||||||
|
|
||||||
const { messages }: ReturnType<typeof selectMessages> = yield select(selectMessages);
|
const { messages }: ReturnType<typeof selectMessages> = yield select(selectMessages);
|
||||||
|
|
||||||
yield put(
|
yield put(
|
||||||
messagesSetMessages({
|
messagesSet({
|
||||||
is_sending_messages: false,
|
is_sending_messages: false,
|
||||||
messages: [data.message, ...messages],
|
messages: [data.message, ...messages],
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue