diff --git a/packages/concordia-app/public/locales/en/translation.json b/packages/concordia-app/public/locales/en/translation.json index ab15e35..341d528 100644 --- a/packages/concordia-app/public/locales/en/translation.json +++ b/packages/concordia-app/public/locales/en/translation.json @@ -29,8 +29,8 @@ "topbar.button.create.topic": "Create topic", "topbar.button.profile": "Profile", "topbar.button.register": "Sign Up", - "topic.create.form.message.field.label": "First post message", - "topic.create.form.message.field.placeholder": "Message", + "topic.create.form.content.field.label": "First post content", + "topic.create.form.content.field.placeholder": "Message", "topic.create.form.post.button": "Post", "topic.create.form.subject.field.label": "Topic subject", "topic.create.form.subject.field.placeholder": "Subject", diff --git a/packages/concordia-app/src/components/PostList/PostListRow/index.jsx b/packages/concordia-app/src/components/PostList/PostListRow/index.jsx index 5f754c1..374d55a 100644 --- a/packages/concordia-app/src/components/PostList/PostListRow/index.jsx +++ b/packages/concordia-app/src/components/PostList/PostListRow/index.jsx @@ -14,7 +14,8 @@ import { breeze } from '../../../redux/store'; import './styles.css'; import { POSTS_DATABASE, USER_DATABASE } from '../../../constants/OrbitDatabases'; import determineKVAddress from '../../../utils/orbitUtils'; -import { PROFILE_PICTURE } from '../../../constants/UserDatabaseKeys'; +import { USER_PROFILE_PICTURE } from '../../../constants/UserDatabaseKeys'; +import { POST_CONTENT, POST_SUBJECT } from '../../../constants/PostsDatabaseKeys'; const { orbit } = breeze; @@ -65,8 +66,8 @@ const PostListRow = (props) => { .find((post) => post.id === postId); if (postFound) { - setPostSubject(postFound.subject); - setPostMessage(postFound.message); + setPostSubject(postFound[POST_SUBJECT]); + setPostMessage(postFound[POST_CONTENT]); } }, [postId, posts]); @@ -90,11 +91,11 @@ const PostListRow = (props) => { return useMemo(() => ( - {postAuthorMeta !== null && postAuthorMeta[PROFILE_PICTURE] + {postAuthorMeta !== null && postAuthorMeta[USER_PROFILE_PICTURE] ? ( ) : ( diff --git a/packages/concordia-app/src/components/TopicList/TopicListRow/index.jsx b/packages/concordia-app/src/components/TopicList/TopicListRow/index.jsx index 786e770..4e6196d 100644 --- a/packages/concordia-app/src/components/TopicList/TopicListRow/index.jsx +++ b/packages/concordia-app/src/components/TopicList/TopicListRow/index.jsx @@ -14,7 +14,8 @@ import { breeze } from '../../../redux/store'; import './styles.css'; import { TOPICS_DATABASE, USER_DATABASE } from '../../../constants/OrbitDatabases'; import determineKVAddress from '../../../utils/orbitUtils'; -import { PROFILE_PICTURE } from '../../../constants/UserDatabaseKeys'; +import { USER_PROFILE_PICTURE } from '../../../constants/UserDatabaseKeys'; +import { TOPIC_SUBJECT } from '../../../constants/TopicsDatabaseKeys'; const { orbit } = breeze; @@ -66,7 +67,7 @@ const TopicListRow = (props) => { .find((topic) => topic.id === topicId); if (topicFound) { - setTopicSubject(topicFound.subject); + setTopicSubject(topicFound[TOPIC_SUBJECT]); } }, [topicId, topics]); @@ -94,12 +95,12 @@ const TopicListRow = (props) => { return ( - {topicAuthorMeta !== null && topicAuthorMeta[PROFILE_PICTURE] + {topicAuthorMeta !== null && topicAuthorMeta[USER_PROFILE_PICTURE] ? ( ) : ( diff --git a/packages/concordia-app/src/constants/PostsDatabaseKeys.js b/packages/concordia-app/src/constants/PostsDatabaseKeys.js new file mode 100644 index 0000000..8a6a148 --- /dev/null +++ b/packages/concordia-app/src/constants/PostsDatabaseKeys.js @@ -0,0 +1,9 @@ +export const POST_SUBJECT = 'subject'; +export const POST_CONTENT = 'content'; + +const postsDatabaseKeys = [ + POST_SUBJECT, + POST_CONTENT, +]; + +export default postsDatabaseKeys; diff --git a/packages/concordia-app/src/constants/TopicsDatabaseKeys.js b/packages/concordia-app/src/constants/TopicsDatabaseKeys.js new file mode 100644 index 0000000..a79a95a --- /dev/null +++ b/packages/concordia-app/src/constants/TopicsDatabaseKeys.js @@ -0,0 +1,7 @@ +export const TOPIC_SUBJECT = 'subject'; + +const topicsDatabaseKeys = [ + TOPIC_SUBJECT, +]; + +export default topicsDatabaseKeys; diff --git a/packages/concordia-app/src/constants/UserDatabaseKeys.js b/packages/concordia-app/src/constants/UserDatabaseKeys.js index db2b2d6..de5aea4 100644 --- a/packages/concordia-app/src/constants/UserDatabaseKeys.js +++ b/packages/concordia-app/src/constants/UserDatabaseKeys.js @@ -1,9 +1,9 @@ -export const PROFILE_PICTURE = 'profile_picture'; -export const LOCATION = 'location'; +export const USER_PROFILE_PICTURE = 'profile_picture'; +export const USER_LOCATION = 'location'; const userDatabaseKeys = [ - PROFILE_PICTURE, - LOCATION, + USER_PROFILE_PICTURE, + USER_LOCATION, ]; export default userDatabaseKeys; diff --git a/packages/concordia-app/src/redux/sagas/peerDbReplicationSaga.js b/packages/concordia-app/src/redux/sagas/peerDbReplicationSaga.js index 61f702c..cd54388 100644 --- a/packages/concordia-app/src/redux/sagas/peerDbReplicationSaga.js +++ b/packages/concordia-app/src/redux/sagas/peerDbReplicationSaga.js @@ -11,6 +11,8 @@ import determineKVAddress from '../../utils/orbitUtils'; import { FETCH_USER_DATABASE, UPDATE_ORBIT_DATA } from '../actions/peerDbReplicationActions'; import { POSTS_DATABASE, TOPICS_DATABASE, USER_DATABASE } from '../../constants/OrbitDatabases'; import userDatabaseKeys from '../../constants/UserDatabaseKeys'; +import { TOPIC_SUBJECT } from '../../constants/TopicsDatabaseKeys'; +import { POST_CONTENT, POST_SUBJECT } from '../../constants/PostsDatabaseKeys'; function* fetchUserDb({ orbit, userAddress, dbName }) { const peerDbAddress = yield call(determineKVAddress, { @@ -70,7 +72,7 @@ function* updateReduxState({ database }) { .entries(database.all) .map(([key, value]) => ({ id: parseInt(key, 10), - subject: value.subject, + [TOPIC_SUBJECT]: value[TOPIC_SUBJECT], })), ], posts: [...posts], @@ -92,8 +94,8 @@ function* updateReduxState({ database }) { ...oldPostsUnchanged, ...Object.entries(database.all).map(([key, value]) => ({ id: parseInt(key, 10), - subject: value.subject, - message: value.message, + [POST_SUBJECT]: value[POST_SUBJECT], + [POST_CONTENT]: value[POST_CONTENT], })), ], }); diff --git a/packages/concordia-app/src/views/Register/PersonalInformationStep/index.jsx b/packages/concordia-app/src/views/Register/PersonalInformationStep/index.jsx index fb72557..2f9b155 100644 --- a/packages/concordia-app/src/views/Register/PersonalInformationStep/index.jsx +++ b/packages/concordia-app/src/views/Register/PersonalInformationStep/index.jsx @@ -11,7 +11,7 @@ import checkUrlValid from '../../../utils/urlUtils'; import { breeze } from '../../../redux/store'; import './styles.css'; import { USER_DATABASE } from '../../../constants/OrbitDatabases'; -import { LOCATION, PROFILE_PICTURE } from '../../../constants/UserDatabaseKeys'; +import { USER_LOCATION, USER_PROFILE_PICTURE } from '../../../constants/UserDatabaseKeys'; const { orbit: { stores } } = breeze; @@ -72,14 +72,14 @@ const PersonalInformationStep = (props) => { if (profilePictureInput.length > 0) { keyValuesToStore.push({ - key: PROFILE_PICTURE, + key: USER_PROFILE_PICTURE, value: profilePictureInput, }); } if (locationInput.length > 0) { keyValuesToStore.push({ - key: LOCATION, + key: USER_LOCATION, value: locationInput, }); } diff --git a/packages/concordia-app/src/views/Topic/TopicCreate/index.jsx b/packages/concordia-app/src/views/Topic/TopicCreate/index.jsx index 32410f0..f3f0ea7 100644 --- a/packages/concordia-app/src/views/Topic/TopicCreate/index.jsx +++ b/packages/concordia-app/src/views/Topic/TopicCreate/index.jsx @@ -11,6 +11,8 @@ 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'; +import { TOPIC_SUBJECT } from '../../../constants/TopicsDatabaseKeys'; +import { POST_CONTENT, POST_SUBJECT } from '../../../constants/PostsDatabaseKeys'; const { contracts: { Forum: { methods: { createTopic } } } } = drizzle; const { orbit: { stores } } = breeze; @@ -69,11 +71,11 @@ const TopicCreate = (props) => { const postsDb = Object.values(stores).find((store) => store.dbname === POSTS_DATABASE); topicsDb - .put(topicId, { subject: subjectInput }, { pin: true }) + .put(topicId, { [TOPIC_SUBJECT]: subjectInput }, { pin: true }) .then(() => postsDb .put(postId, { - subject: subjectInput, - content: messageInput, + [POST_SUBJECT]: subjectInput, + [POST_CONTENT]: messageInput, }, { pin: true })) .then(() => { history.push(`/topics/${topicId}`); @@ -119,7 +121,7 @@ const TopicCreate = (props) => {