Browse Source

Replace hardcoded string with constants

develop
Apostolos Fanakis 4 years ago
parent
commit
d8fe90a120
  1. 5
      packages/concordia-app/src/components/PostList/PostListRow/index.jsx
  2. 3
      packages/concordia-app/src/components/TopicList/TopicListRow/index.jsx
  3. 5
      packages/concordia-app/src/redux/sagas/peerDbReplicationSaga.js
  4. 6
      packages/concordia-app/src/views/Register/index.jsx
  5. 10
      packages/concordia-app/src/views/Topic/TopicCreate/index.jsx
  6. 3
      packages/concordia-app/src/views/Topic/TopicView/index.jsx

5
packages/concordia-app/src/components/PostList/PostListRow/index.jsx

@ -2,7 +2,7 @@ import React, {
memo, useEffect, useMemo, useState,
} from 'react';
import {
Dimmer, Grid, List, Loader, Placeholder,
Dimmer, Grid, List, Placeholder,
} from 'semantic-ui-react';
import PropTypes from 'prop-types';
import { useTranslation } from 'react-i18next';
@ -12,6 +12,7 @@ import { useDispatch, useSelector } from 'react-redux';
import { FETCH_USER_DATABASE } from '../../../redux/actions/peerDbReplicationActions';
import { breeze } from '../../../redux/store';
import './styles.css';
import { POSTS_DATABASE } from '../../../constants/OrbitDatabases';
const { orbit } = breeze;
@ -42,7 +43,7 @@ const PostListRow = (props) => {
dispatch({
type: FETCH_USER_DATABASE,
orbit,
dbName: 'posts',
dbName: POSTS_DATABASE,
userAddress: postAuthorAddress,
});
}

3
packages/concordia-app/src/components/TopicList/TopicListRow/index.jsx

@ -12,6 +12,7 @@ import { useDispatch, useSelector } from 'react-redux';
import { FETCH_USER_DATABASE } from '../../../redux/actions/peerDbReplicationActions';
import { breeze } from '../../../redux/store';
import './styles.css';
import { TOPICS_DATABASE } from '../../../constants/OrbitDatabases';
const { orbit } = breeze;
@ -43,7 +44,7 @@ const TopicListRow = (props) => {
dispatch({
type: FETCH_USER_DATABASE,
orbit,
dbName: 'topics',
dbName: TOPICS_DATABASE,
userAddress: topicAuthorAddress,
});
}

5
packages/concordia-app/src/redux/sagas/peerDbReplicationSaga.js

@ -9,6 +9,7 @@ import {
} from '@ezerous/breeze/src/orbit/orbitActions';
import determineKVAddress from '../../utils/orbitUtils';
import { FETCH_USER_DATABASE, UPDATE_ORBIT_DATA } from '../actions/peerDbReplicationActions';
import { POSTS_DATABASE, TOPICS_DATABASE } from '../../constants/OrbitDatabases';
function* fetchUserDb({ orbit, userAddress, dbName }) {
const peerDbAddress = yield call(determineKVAddress, {
@ -24,7 +25,7 @@ function* updateReduxState({ database }) {
posts: state.orbitData.posts,
}));
if (database.dbname === 'topics') {
if (database.dbname === TOPICS_DATABASE) {
const oldTopicsUnchanged = topics
.filter((topic) => !Object
.keys(database.all)
@ -46,7 +47,7 @@ function* updateReduxState({ database }) {
});
}
if (database.dbname === 'posts') {
if (database.dbname === POSTS_DATABASE) {
const oldPostsUnchanged = posts
.filter((post) => !Object
.keys(database.all)

6
packages/concordia-app/src/views/Register/index.jsx

@ -19,11 +19,11 @@ const Register = () => {
const goToHomePage = useCallback(() => history.push('/'), [history]);
const pushNextStep = useCallback(() => {
if (currentStep === 'signup') {
setCurrentStep('profile-information');
if (currentStep === REGISTER_STEP_SIGNUP) {
setCurrentStep(REGISTER_STEP_PROFILE_INFORMATION);
}
if (currentStep === 'profile-information') {
if (currentStep === REGISTER_STEP_PROFILE_INFORMATION) {
goToHomePage();
}
}, [currentStep, goToHomePage]);

10
packages/concordia-app/src/views/Topic/TopicCreate/index.jsx

@ -9,6 +9,8 @@ import { useHistory } from 'react-router';
import { useSelector } from 'react-redux';
import './styles.css';
import { drizzle, breeze } from '../../../redux/store';
import { TRANSACTION_ERROR, TRANSACTION_SUCCESS } from '../../../constants/TransactionStatus';
import { POSTS_DATABASE, TOPICS_DATABASE } from '../../../constants/OrbitDatabases';
const { contracts: { Forum: { methods: { createTopic } } } } = drizzle;
const { orbit: { stores } } = breeze;
@ -47,9 +49,9 @@ const TopicCreate = (props) => {
useEffect(() => {
if (posting && transactionStack && transactionStack[createTopicCacheSendStackId]
&& transactions[transactionStack[createTopicCacheSendStackId]]) {
if (transactions[transactionStack[createTopicCacheSendStackId]].status === 'error') {
if (transactions[transactionStack[createTopicCacheSendStackId]].status === TRANSACTION_ERROR) {
setPosting(false);
} else if (transactions[transactionStack[createTopicCacheSendStackId]].status === 'success') {
} else if (transactions[transactionStack[createTopicCacheSendStackId]].status === TRANSACTION_SUCCESS) {
const {
receipt: {
events: {
@ -63,8 +65,8 @@ const TopicCreate = (props) => {
},
} = transactions[transactionStack[createTopicCacheSendStackId]];
const topicsDb = Object.values(stores).find((store) => store.dbname === 'topics');
const postsDb = Object.values(stores).find((store) => store.dbname === 'posts');
const topicsDb = Object.values(stores).find((store) => store.dbname === TOPICS_DATABASE);
const postsDb = Object.values(stores).find((store) => store.dbname === POSTS_DATABASE);
topicsDb
.put(topicId, { subject: subjectInput }, { pin: true })

3
packages/concordia-app/src/views/Topic/TopicView/index.jsx

@ -9,6 +9,7 @@ import { breeze, drizzle } from '../../../redux/store';
import { FETCH_USER_DATABASE } from '../../../redux/actions/peerDbReplicationActions';
import './styles.css';
import PostList from '../../../components/PostList';
import { TOPICS_DATABASE } from '../../../constants/OrbitDatabases';
const { contracts: { Forum: { methods: { getTopic: { cacheCall: getTopicChainData } } } } } = drizzle;
const { orbit } = breeze;
@ -59,7 +60,7 @@ const TopicView = (props) => {
dispatch({
type: FETCH_USER_DATABASE,
orbit,
dbName: 'topics',
dbName: TOPICS_DATABASE,
userAddress: getTopicResults[getTopicCallHash].value[0],
});
}

Loading…
Cancel
Save