diff options
Diffstat (limited to 'ui/src/components/modlog.tsx')
-rw-r--r-- | ui/src/components/modlog.tsx | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/ui/src/components/modlog.tsx b/ui/src/components/modlog.tsx index 425710dd..dd651092 100644 --- a/ui/src/components/modlog.tsx +++ b/ui/src/components/modlog.tsx @@ -17,9 +17,9 @@ import { ModAdd, } from '../interfaces'; import { WebSocketService } from '../services'; -import { msgOp, addTypeInfo, fetchLimit } from '../utils'; +import { wsJsonToRes, addTypeInfo, fetchLimit, toast } from '../utils'; import { MomentTime } from './moment-time'; -import * as moment from 'moment'; +import moment from 'moment'; import { i18n } from '../i18next'; interface ModlogState { @@ -55,14 +55,7 @@ export class Modlog extends Component<any, ModlogState> { ? Number(this.props.match.params.community_id) : undefined; this.subscription = WebSocketService.Instance.subject - .pipe( - retryWhen(errors => - errors.pipe( - delay(3000), - take(10) - ) - ) - ) + .pipe(retryWhen(errors => errors.pipe(delay(3000), take(10)))) .subscribe( msg => this.parseMessage(msg), err => console.error(err), @@ -429,17 +422,17 @@ export class Modlog extends Component<any, ModlogState> { WebSocketService.Instance.getModlog(modlogForm); } - parseMessage(msg: any) { + parseMessage(msg: WebSocketJsonResponse) { console.log(msg); - let op: UserOperation = msgOp(msg); - if (msg.error) { - alert(i18n.t(msg.error)); + let res = wsJsonToRes(msg); + if (res.error) { + toast(i18n.t(msg.error), 'danger'); return; - } else if (op == UserOperation.GetModlog) { - let res: GetModlogResponse = msg; + } else if (res.op == UserOperation.GetModlog) { + let data = res.data as GetModlogResponse; this.state.loading = false; window.scrollTo(0, 0); - this.setCombined(res); + this.setCombined(data); } } } |