diff --git a/server/src/websocket_server/server.rs b/server/src/websocket_server/server.rs index 4f0efb0..c4afa69 100644 --- a/server/src/websocket_server/server.rs +++ b/server/src/websocket_server/server.rs @@ -1806,9 +1806,9 @@ impl Perform for GetModlog { let mut added = Vec::new(); if self.community_id.is_none() { - removed_communities = ModRemoveCommunityView::list(&conn, self.mod_user_id, self.limit, self.page).unwrap(); - banned = ModBanView::list(&conn, self.mod_user_id, self.limit, self.page).unwrap(); - added = ModAddView::list(&conn, self.mod_user_id, self.limit, self.page).unwrap(); + removed_communities = ModRemoveCommunityView::list(&conn, self.mod_user_id, self.page, self.limit).unwrap(); + banned = ModBanView::list(&conn, self.mod_user_id, self.page, self.limit).unwrap(); + added = ModAddView::list(&conn, self.mod_user_id, self.page, self.limit).unwrap(); } // Return the jwt diff --git a/ui/src/components/modlog.tsx b/ui/src/components/modlog.tsx index e456788..56b08a7 100644 --- a/ui/src/components/modlog.tsx +++ b/ui/src/components/modlog.tsx @@ -1,10 +1,10 @@ -import { Component } from 'inferno'; +import { Component, linkEvent } from 'inferno'; import { Link } from 'inferno-router'; import { Subscription } from "rxjs"; import { retryWhen, delay, take } from 'rxjs/operators'; import { UserOperation, GetModlogForm, GetModlogResponse, ModRemovePost, ModLockPost, ModRemoveComment, ModRemoveCommunity, ModBanFromCommunity, ModBan, ModAddCommunity, ModAdd } from '../interfaces'; import { WebSocketService } from '../services'; -import { msgOp, addTypeInfo } from '../utils'; +import { msgOp, addTypeInfo, fetchLimit } from '../utils'; import { MomentTime } from './moment-time'; import * as moment from 'moment'; @@ -12,6 +12,7 @@ interface ModlogState { combined: Array<{type_: string, data: ModRemovePost | ModLockPost | ModRemoveCommunity}>, communityId?: number, communityName?: string, + page: number; loading: boolean; } @@ -19,6 +20,7 @@ export class Modlog extends Component { private subscription: Subscription; private emptyState: ModlogState = { combined: [], + page: 1, loading: true, } @@ -35,10 +37,7 @@ export class Modlog extends Component { () => console.log('complete') ); - let modlogForm: GetModlogForm = { - community_id: this.state.communityId - }; - WebSocketService.Instance.getModlog(modlogForm); + this.refetch(); } componentWillUnmount() { @@ -52,6 +51,7 @@ export class Modlog extends Component { let removed_communities = addTypeInfo(res.removed_communities, "removed_communities"); let banned_from_community = addTypeInfo(res.banned_from_community, "banned_from_community"); let added_to_community = addTypeInfo(res.added_to_community, "added_to_community"); + this.state.combined = []; this.state.combined.push(...removed_posts); this.state.combined.push(...locked_posts); @@ -153,6 +153,7 @@ export class Modlog extends Component { {this.combined()} + {this.paginator()} } @@ -160,6 +161,38 @@ export class Modlog extends Component { ); } + paginator() { + return ( +
+ {this.state.page > 1 && + + } + +
+ ); + } + + nextPage(i: Modlog) { + i.state.page++; + i.setState(i.state); + i.refetch(); + } + + prevPage(i: Modlog) { + i.state.page--; + i.setState(i.state); + i.refetch(); + } + + refetch(){ + let modlogForm: GetModlogForm = { + community_id: this.state.communityId, + page: this.state.page, + limit: fetchLimit, + }; + WebSocketService.Instance.getModlog(modlogForm); + } + parseMessage(msg: any) { console.log(msg); let op: UserOperation = msgOp(msg);