]> Untitled Git - lemmy.git/blob - ui/src/components/create-post.tsx
Adding login and Register
[lemmy.git] / ui / src / components / create-post.tsx
1 import { Component, linkEvent } from 'inferno';
2
3 import { LoginForm, PostForm, UserOperation } from '../interfaces';
4 import { WebSocketService, UserService } from '../services';
5 import { msgOp } from '../utils';
6
7 interface State {
8   postForm: PostForm;
9 }
10
11 let emptyState: State = {
12   postForm: {
13     name: null,
14     url: null,
15     attributed_to: null
16   }
17 }
18
19 export class CreatePost extends Component<any, State> {
20
21   constructor(props, context) {
22     super(props, context);
23
24     this.state = emptyState;
25
26     WebSocketService.Instance.subject.subscribe(
27       (msg) => this.parseMessage(msg),
28       (err) => console.error(err),
29       () => console.log('complete')
30     );
31   }
32
33
34   render() {
35     return (
36       <div class="container">
37         <div class="row">
38           <div class="col-12 col-lg-6 mb-4">
39             create post
40             {/* {this.postForm()} */}
41           </div>
42         </div>
43       </div>
44     )
45   }
46
47   parseMessage(msg: any) {
48     console.log(msg);
49     let op: UserOperation = msgOp(msg);
50     if (msg.error) {
51       alert(msg.error);
52       return;
53     } else {
54     }
55   }
56
57 }