diff options
author | Dessalines <tyhou13@gmx.com> | 2019-09-08 23:14:13 -0700 |
---|---|---|
committer | Dessalines <tyhou13@gmx.com> | 2019-09-08 23:14:13 -0700 |
commit | 3f6b2be2cccedc4b743e8d80b84fde704980ea32 (patch) | |
tree | a1303dd130b753ee2076a9d4136b02f51a7973c8 /ui/src | |
parent | 48a30089b251c4723a3c9fd91b052c1379b46c03 (diff) |
Adding stickied posts.
- Fixes #245
Diffstat (limited to 'ui/src')
-rw-r--r-- | ui/src/components/modlog.tsx | 13 | ||||
-rw-r--r-- | ui/src/components/post-listing.tsx | 19 | ||||
-rw-r--r-- | ui/src/interfaces.ts | 15 | ||||
-rw-r--r-- | ui/src/translations/en.ts | 3 |
4 files changed, 48 insertions, 2 deletions
diff --git a/ui/src/components/modlog.tsx b/ui/src/components/modlog.tsx index ba1fe5a2..3af122a8 100644 --- a/ui/src/components/modlog.tsx +++ b/ui/src/components/modlog.tsx @@ -2,14 +2,15 @@ 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 { UserOperation, GetModlogForm, GetModlogResponse, ModRemovePost, ModLockPost, ModStickyPost, ModRemoveComment, ModRemoveCommunity, ModBanFromCommunity, ModBan, ModAddCommunity, ModAdd } from '../interfaces'; import { WebSocketService } from '../services'; import { msgOp, addTypeInfo, fetchLimit } from '../utils'; import { MomentTime } from './moment-time'; import * as moment from 'moment'; +import { i18n } from '../i18next'; interface ModlogState { - combined: Array<{type_: string, data: ModRemovePost | ModLockPost | ModRemoveCommunity | ModAdd | ModBan}>, + combined: Array<{type_: string, data: ModRemovePost | ModLockPost | ModStickyPost | ModRemoveCommunity | ModAdd | ModBan}>, communityId?: number, communityName?: string, page: number; @@ -51,6 +52,7 @@ export class Modlog extends Component<any, ModlogState> { setCombined(res: GetModlogResponse) { let removed_posts = addTypeInfo(res.removed_posts, "removed_posts"); let locked_posts = addTypeInfo(res.locked_posts, "locked_posts"); + let stickied_posts = addTypeInfo(res.stickied_posts, "stickied_posts"); let removed_comments = addTypeInfo(res.removed_comments, "removed_comments"); let removed_communities = addTypeInfo(res.removed_communities, "removed_communities"); let banned_from_community = addTypeInfo(res.banned_from_community, "banned_from_community"); @@ -61,6 +63,7 @@ export class Modlog extends Component<any, ModlogState> { this.state.combined.push(...removed_posts); this.state.combined.push(...locked_posts); + this.state.combined.push(...stickied_posts); this.state.combined.push(...removed_comments); this.state.combined.push(...removed_communities); this.state.combined.push(...banned_from_community); @@ -99,6 +102,12 @@ export class Modlog extends Component<any, ModlogState> { <span> Post <Link to={`/post/${(i.data as ModLockPost).post_id}`}>{(i.data as ModLockPost).post_name}</Link></span> </> } + {i.type_ == 'stickied_posts' && + <> + {(i.data as ModStickyPost).stickied? 'Stickied' : 'Unstickied'} + <span> Post <Link to={`/post/${(i.data as ModStickyPost).post_id}`}>{(i.data as ModStickyPost).post_name}</Link></span> + </> + } {i.type_ == 'removed_comments' && <> {(i.data as ModRemoveComment).removed? 'Removed' : 'Restored'} diff --git a/ui/src/components/post-listing.tsx b/ui/src/components/post-listing.tsx index 8234cc8a..94cbef10 100644 --- a/ui/src/components/post-listing.tsx +++ b/ui/src/components/post-listing.tsx @@ -129,6 +129,9 @@ export class PostListing extends Component<PostListingProps, PostListingState> { {post.locked && <small className="ml-2 text-muted font-italic"><T i18nKey="locked">#</T></small> } + {post.stickied && + <small className="ml-2 text-muted font-italic"><T i18nKey="stickied">#</T></small> + } {post.nsfw && <small className="ml-2 text-muted font-italic"><T i18nKey="nsfw">#</T></small> } @@ -202,6 +205,9 @@ export class PostListing extends Component<PostListingProps, PostListingState> { <li className="list-inline-item"> <span class="pointer" onClick={linkEvent(this, this.handleModLock)}>{post.locked ? i18n.t('unlock') : i18n.t('lock')}</span> </li> + <li className="list-inline-item"> + <span class="pointer" onClick={linkEvent(this, this.handleModSticky)}>{post.stickied ? i18n.t('unsticky') : i18n.t('sticky')}</span> + </li> </> } {/* Mods can ban from community, and appoint as mods to community */} @@ -459,6 +465,19 @@ export class PostListing extends Component<PostListingProps, PostListingState> { WebSocketService.Instance.editPost(form); } + handleModSticky(i: PostListing) { + let form: PostFormI = { + name: i.props.post.name, + community_id: i.props.post.community_id, + edit_id: i.props.post.id, + creator_id: i.props.post.creator_id, + nsfw: i.props.post.nsfw, + stickied: !i.props.post.stickied, + auth: null, + }; + WebSocketService.Instance.editPost(form); + } + handleModBanFromCommunityShow(i: PostListing) { i.state.showBanDialog = true; i.state.banType = BanType.Community; diff --git a/ui/src/interfaces.ts b/ui/src/interfaces.ts index f2675eb3..8c78d7d8 100644 --- a/ui/src/interfaces.ts +++ b/ui/src/interfaces.ts @@ -77,6 +77,7 @@ export interface Post { removed: boolean; deleted: boolean; locked: boolean; + stickied: boolean; nsfw: boolean; banned: boolean; banned_from_community: boolean; @@ -235,6 +236,7 @@ export interface GetModlogResponse { op: string; removed_posts: Array<ModRemovePost>, locked_posts: Array<ModLockPost>, + stickied_posts: Array<ModStickyPost>, removed_comments: Array<ModRemoveComment>, removed_communities: Array<ModRemoveCommunity>, banned_from_community: Array<ModBanFromCommunity>, @@ -268,6 +270,18 @@ export interface ModLockPost { community_name: string, } +export interface ModStickyPost { + id: number, + mod_user_id: number, + post_id: number, + stickied?: boolean, + when_: string, + mod_user_name: string, + post_name: string, + community_id: number, + community_name: string, +} + export interface ModRemoveComment { id: number, mod_user_id: number, @@ -425,6 +439,7 @@ export interface PostForm { deleted?: boolean; nsfw: boolean; locked?: boolean; + stickied?: boolean; reason?: string; auth: string; } diff --git a/ui/src/translations/en.ts b/ui/src/translations/en.ts index f89a9879..5ec03671 100644 --- a/ui/src/translations/en.ts +++ b/ui/src/translations/en.ts @@ -32,6 +32,8 @@ export const en = { view_source: 'view source', unlock: 'unlock', lock: 'lock', + sticky: 'sticky', + unsticky: 'unsticky', link: 'link', mod: 'mod', mods: 'mods', @@ -47,6 +49,7 @@ export const en = { remove: 'remove', removed: 'removed', locked: 'locked', + stickied: 'stickied', reason: 'Reason', mark_as_read: 'mark as read', mark_as_unread: 'mark as unread', |