refactoring
This commit is contained in:
parent
72c72a2ec1
commit
e5dff62e1b
4 changed files with 21 additions and 12 deletions
|
@ -12,11 +12,11 @@ const ChannelEntry = (props: ChannelEntryProps) => {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div>{channel.name}</div>
|
{channel.name}
|
||||||
{joined.length > 0 && (
|
{joined.length > 0 && (
|
||||||
<ul>
|
<ul>
|
||||||
{joined.map(e => (
|
{joined.map(e => (
|
||||||
<li>{e.nickname}</li>
|
<li key={e.databaseId}>{e.nickname}</li>
|
||||||
))}
|
))}
|
||||||
</ul>
|
</ul>
|
||||||
)}
|
)}
|
||||||
|
|
|
@ -2,24 +2,26 @@ import React, { Component } from 'react';
|
||||||
import ApiService from '../../services/ApiService';
|
import ApiService from '../../services/ApiService';
|
||||||
import ChannelList from './ChannelList';
|
import ChannelList from './ChannelList';
|
||||||
|
|
||||||
class Channels extends Component<any, any> {
|
class Channels extends Component<{}, ChannelState> {
|
||||||
constructor(props: any) {
|
constructor(props: any) {
|
||||||
super(props);
|
super(props);
|
||||||
this.state = {
|
this.state = {
|
||||||
loaded: false,
|
loaded: false,
|
||||||
channels: [],
|
channels: [],
|
||||||
users: [],
|
clients: [],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
ApiService.fetchAllChannels().then(data => {
|
ApiService.fetchAllChannels()
|
||||||
|
.then(data => {
|
||||||
this.setState({
|
this.setState({
|
||||||
channels: data.channelJson,
|
channels: data.channelJson,
|
||||||
clients: data.clientJson,
|
clients: data.clientJson,
|
||||||
loaded: true,
|
loaded: true,
|
||||||
});
|
});
|
||||||
});
|
})
|
||||||
|
.catch(e => console.error(e));
|
||||||
}
|
}
|
||||||
render() {
|
render() {
|
||||||
const { loaded, channels, clients } = this.state;
|
const { loaded, channels, clients } = this.state;
|
||||||
|
|
6
src/interfaces.d.ts → src/types.d.ts
vendored
6
src/interfaces.d.ts → src/types.d.ts
vendored
|
@ -15,6 +15,12 @@ interface Client {
|
||||||
awayMessage: string;
|
awayMessage: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface ChannelState {
|
||||||
|
loaded: boolean;
|
||||||
|
channels: Channel[];
|
||||||
|
clients: Client[];
|
||||||
|
}
|
||||||
|
|
||||||
interface ChannelListProps {
|
interface ChannelListProps {
|
||||||
channels: Channel[];
|
channels: Channel[];
|
||||||
clients: Client[];
|
clients: Client[];
|
|
@ -14,7 +14,8 @@
|
||||||
"jsx-boolean-value": false,
|
"jsx-boolean-value": false,
|
||||||
"member-access": false,
|
"member-access": false,
|
||||||
"no-console": false,
|
"no-console": false,
|
||||||
"strict-type-predicates": false
|
"strict-type-predicates": false,
|
||||||
|
"interface-name": false
|
||||||
},
|
},
|
||||||
"rulesDirectory": []
|
"rulesDirectory": []
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue