mirror of https://gitlab.com/ecentrics/concordia
Apostolos Fanakis
4 years ago
19 changed files with 98 additions and 23 deletions
@ -1 +1 @@ |
|||
export const FORUM = 'Forum'; |
|||
export const FORUM_CONTRACT = 'Forum'; |
|||
|
@ -0,0 +1,13 @@ |
|||
export const USER_SIGNED_UP_EVENT = 'UserSignedUp'; |
|||
export const USERNAME_UPDATED_EVENT = 'UsernameUpdated'; |
|||
export const TOPIC_CREATED_EVENT = 'TopicCreated'; |
|||
export const POST_CREATED_EVENT = 'PostCreated'; |
|||
|
|||
const forumContractEvents = [ |
|||
USER_SIGNED_UP_EVENT, |
|||
USERNAME_UPDATED_EVENT, |
|||
TOPIC_CREATED_EVENT, |
|||
POST_CREATED_EVENT, |
|||
]; |
|||
|
|||
export default forumContractEvents; |
@ -0,0 +1,20 @@ |
|||
import { |
|||
POST_CREATED_EVENT, |
|||
TOPIC_CREATED_EVENT, |
|||
USER_SIGNED_UP_EVENT, |
|||
USERNAME_UPDATED_EVENT, |
|||
} from '../../constants/ForumContractEvents'; |
|||
|
|||
export const FORUM_EVENT_USER_SIGNED_UP = 'FORUM_EVENT_USER_SIGNED_UP'; |
|||
export const FORUM_EVENT_USERNAME_UPDATED = 'FORUM_EVENT_USERNAME_UPDATED'; |
|||
export const FORUM_EVENT_TOPIC_CREATED = 'FORUM_EVENT_TOPIC_CREATED'; |
|||
export const FORUM_EVENT_POST_CREATED = 'FORUM_EVENT_POST_CREATED'; |
|||
|
|||
const eventActionMap = { |
|||
[USER_SIGNED_UP_EVENT]: FORUM_EVENT_USER_SIGNED_UP, |
|||
[USERNAME_UPDATED_EVENT]: FORUM_EVENT_USERNAME_UPDATED, |
|||
[TOPIC_CREATED_EVENT]: FORUM_EVENT_TOPIC_CREATED, |
|||
[POST_CREATED_EVENT]: FORUM_EVENT_POST_CREATED, |
|||
}; |
|||
|
|||
export default eventActionMap; |
@ -0,0 +1,13 @@ |
|||
import { put, takeEvery } from 'redux-saga/effects'; |
|||
import { CONTRACT_EVENT_FIRED } from '@ezerous/drizzle/src/contracts/constants'; |
|||
import eventActionMap from '../actions/contractEventActions'; |
|||
|
|||
function* eventBreakDown({ event }) { |
|||
yield put({ type: eventActionMap[event.event], event: { ...event } }); |
|||
} |
|||
|
|||
function* eventSaga() { |
|||
yield takeEvery(CONTRACT_EVENT_FIRED, eventBreakDown); |
|||
} |
|||
|
|||
export default eventSaga; |
Loading…
Reference in new issue