edfghjkl;
parent
830e689840
commit
7d3c72eb81
|
|
@ -1,26 +1,8 @@
|
||||||
import React from 'react';
|
import React, { createContext } from 'react';
|
||||||
import ReactDOM from 'react-dom';
|
import ReactDOM from 'react-dom';
|
||||||
import Channels from './pages/Channels';
|
import App from './pages/App';
|
||||||
import Chat from './pages/Chat';
|
|
||||||
|
|
||||||
ReactDOM.render(
|
ReactDOM.render(
|
||||||
(
|
<App></App>,
|
||||||
<div style={{
|
|
||||||
display: 'grid',
|
|
||||||
gridTemplateColumns: '200px 1fr',
|
|
||||||
gridTemplateRows: '1fr',
|
|
||||||
height: '100%',
|
|
||||||
}}>
|
|
||||||
<div style={{
|
|
||||||
background: 'rgba(25, 26, 33)',
|
|
||||||
borderRight: '1px solid #bd93f9',
|
|
||||||
}}>
|
|
||||||
<Channels></Channels>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<Chat></Chat>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
),
|
|
||||||
document.getElementById('app'),
|
document.getElementById('app'),
|
||||||
);
|
);
|
||||||
|
|
@ -0,0 +1,39 @@
|
||||||
|
import { createContext, useState } from 'react';
|
||||||
|
import Channels from './Channels';
|
||||||
|
import Chat from './Chat';
|
||||||
|
|
||||||
|
|
||||||
|
export const channelContext = createContext<{
|
||||||
|
channel: string | null,
|
||||||
|
setChannel: (uid: string) => void
|
||||||
|
}>({
|
||||||
|
channel: null,
|
||||||
|
setChannel: () => {},
|
||||||
|
});
|
||||||
|
|
||||||
|
export default function App() {
|
||||||
|
const [channel, setChannel] = useState<string>(null);
|
||||||
|
|
||||||
|
const channelContextValue = { channel, setChannel };
|
||||||
|
|
||||||
|
return (
|
||||||
|
<channelContext.Provider value={channelContextValue}>
|
||||||
|
<div style={{
|
||||||
|
display: 'grid',
|
||||||
|
gridTemplateColumns: '200px 1fr',
|
||||||
|
gridTemplateRows: '1fr',
|
||||||
|
height: '100%',
|
||||||
|
}}>
|
||||||
|
<div style={{
|
||||||
|
background: 'rgba(25, 26, 33)',
|
||||||
|
borderRight: '1px solid #bd93f9',
|
||||||
|
}}>
|
||||||
|
<Channels></Channels>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<Chat></Chat>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</channelContext.Provider>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
@ -19,7 +19,7 @@ export function expose(router: Function, port: number) {
|
||||||
try {
|
try {
|
||||||
console.log('[IN]', action, data);
|
console.log('[IN]', action, data);
|
||||||
const _return = await (router(action, data) as unknown as Promise<any>);
|
const _return = await (router(action, data) as unknown as Promise<any>);
|
||||||
console.log(_return);
|
// console.log(_return);
|
||||||
if(_return) {
|
if(_return) {
|
||||||
try {
|
try {
|
||||||
switch(_return.type) {
|
switch(_return.type) {
|
||||||
|
|
|
||||||
|
|
@ -13,10 +13,10 @@ export default router({
|
||||||
async add(channel: any) {
|
async add(channel: any) {
|
||||||
const name = channel.name;
|
const name = channel.name;
|
||||||
const uid = v4();
|
const uid = v4();
|
||||||
console.log(channel);
|
// console.log(channel);
|
||||||
const res = await query(add, name, uid);
|
const res = await query(add, name, uid);
|
||||||
if(res === null) return;
|
if(res === null) return;
|
||||||
console.log(res);
|
// console.log(res);
|
||||||
return broadcast({
|
return broadcast({
|
||||||
uid,
|
uid,
|
||||||
name,
|
name,
|
||||||
|
|
|
||||||
Reference in New Issue