edfghjkl;
parent
830e689840
commit
7d3c72eb81
|
|
@ -1,26 +1,8 @@
|
|||
import React from 'react';
|
||||
import React, { createContext } from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
import Channels from './pages/Channels';
|
||||
import Chat from './pages/Chat';
|
||||
import App from './pages/App';
|
||||
|
||||
ReactDOM.render(
|
||||
(
|
||||
<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>
|
||||
),
|
||||
<App></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 {
|
||||
console.log('[IN]', action, data);
|
||||
const _return = await (router(action, data) as unknown as Promise<any>);
|
||||
console.log(_return);
|
||||
// console.log(_return);
|
||||
if(_return) {
|
||||
try {
|
||||
switch(_return.type) {
|
||||
|
|
|
|||
|
|
@ -13,10 +13,10 @@ export default router({
|
|||
async add(channel: any) {
|
||||
const name = channel.name;
|
||||
const uid = v4();
|
||||
console.log(channel);
|
||||
// console.log(channel);
|
||||
const res = await query(add, name, uid);
|
||||
if(res === null) return;
|
||||
console.log(res);
|
||||
// console.log(res);
|
||||
return broadcast({
|
||||
uid,
|
||||
name,
|
||||
|
|
|
|||
Reference in New Issue