Skip to content
This repository has been archived by the owner on Jul 9, 2021. It is now read-only.

Commit

Permalink
Final Commit for v0.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
MrWillCom committed Feb 10, 2021
1 parent 22dab68 commit ac11ac7
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 19 deletions.
14 changes: 14 additions & 0 deletions components/chatDataManager.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// var event = {
// type: "event",
// data: {
// id: "encryptionInitialized"
// }
// }
// var textMsg = {
// type: "msg.text",
// data: {
// text: "Hello"
// }
// }


13 changes: 0 additions & 13 deletions components/chatView.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,6 @@

.chatViewMsgs {}

.chatViewMsgs>p {
margin: 12px;
padding: 0;
}

.chatViewMsgs>p>p {
margin: 0;
padding: 8px;
background-color: var(--color-blue-theme-text);
display: inline-block;
border-radius: 8px;
}

.chatViewInputBar {
background-color: var(--color-blue-theme-text-opacity-8);
position: sticky;
Expand Down
22 changes: 16 additions & 6 deletions components/chatView.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
import styles from './chatView.module.css'
import { msgMgr, msgMgrEvents } from '../messages/manager'

export default function ChatView(props: {
username: string,
signedIn: boolean | object,
}) {
const centerAndGrey = { display: 'grid', placeItems: 'center', color: 'grey', height: '100%' }

const [msgs, setMsgs] = React.useState(msgMgr.get(props.username))
msgMgrEvents.on('add', (username) => {
if (username == props.username) {
setMsgs(msgMgr.get(props.username))
}
})

if (props.username) {
return (
<div className={styles.chatView}>
Expand All @@ -14,15 +22,17 @@ export default function ChatView(props: {
</div>
<div className={styles.chatViewMsgs}>
{(() => {
var items = []
for (let i = 0; i < 64; i++) {
items.push(<p><p>hello by {props.username}, {i + 1}</p></p>)
}
return items
var msgList = []
msgs.forEach(element => {
msgList.push(<p>{JSON.stringify(element)}</p>)
});
return ""
})()}
</div>
<div className={styles.chatViewInputBar}>
<textarea className={styles.chatViewInputBarTextArea}></textarea>
<textarea className={styles.chatViewInputBarTextArea} onKeyDown={(ev) => {

}}></textarea>
</div>
</div>
)
Expand Down
20 changes: 20 additions & 0 deletions messages/manager.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import eventManager from '../socket/eventManager'

var events = new eventManager()

class manager {
messages = {};

add = (username, type, data) => {
if (!this.messages[username]) { this.messages[username] = [] }
this.messages[username].push({ type, data })
events.trigger('add', { username })
};

get = username => this.messages[username];
}

var msgMgr = new manager()

export default msgMgr
export { msgMgr, events as msgMgrEvents }

0 comments on commit ac11ac7

Please sign in to comment.