From 08b953c0aa0d9accea19fad0a18c3dd0c4bd174d Mon Sep 17 00:00:00 2001 From: Justin Hernandez Date: Wed, 1 Jul 2020 19:03:26 -0500 Subject: Remove karma count from search results --- ui/src/components/search.tsx | 4 ---- 1 file changed, 4 deletions(-) (limited to 'ui/src') diff --git a/ui/src/components/search.tsx b/ui/src/components/search.tsx index a02f035f..0e6bdfd3 100644 --- a/ui/src/components/search.tsx +++ b/ui/src/components/search.tsx @@ -263,9 +263,6 @@ export class Search extends Component { }} /> - {` - ${ - (i.data as UserView).comment_score - } comment karma`} )} @@ -339,7 +336,6 @@ export class Search extends Component { to={`/u/${user.name}`} >{`/u/${user.name}`} - {` - ${user.comment_score} comment karma`} ))} -- cgit v1.2.3 From 68e9755e593bbd8230eab2a123e822022721f071 Mon Sep 17 00:00:00 2001 From: Filip785 Date: Wed, 8 Jul 2020 02:28:47 +0200 Subject: Add cake day display in user page & posts/comments #682 --- ui/src/components/cake-day.tsx | 41 ++++++++++++++++++++++++++++++++++++++ ui/src/components/comment-node.tsx | 8 ++++++++ ui/src/components/post-listing.tsx | 9 +++++++++ ui/src/components/symbols.tsx | 3 +++ ui/src/components/user.tsx | 10 ++++++++++ ui/src/interfaces.ts | 2 ++ 6 files changed, 73 insertions(+) create mode 100644 ui/src/components/cake-day.tsx (limited to 'ui/src') diff --git a/ui/src/components/cake-day.tsx b/ui/src/components/cake-day.tsx new file mode 100644 index 00000000..67ac7f8b --- /dev/null +++ b/ui/src/components/cake-day.tsx @@ -0,0 +1,41 @@ +import { Component } from 'inferno'; +import moment from 'moment'; +import { i18n } from '../i18next'; + +interface CakeDayProps { + creator_name: string; + creator_published: string; +} + +export class CakeDay extends Component { + render() { + const { creator_name, creator_published } = this.props; + + return ( + this.isCakeDay(creator_published) && ( +
+ + + +
+ ) + ); + } + + isCakeDay(input: string): boolean { + const userCreationDate = moment.utc(input).local(); + const currentDate = moment(new Date()); + + return ( + userCreationDate.date() === currentDate.date() && + userCreationDate.month() === currentDate.month() + ); + } + + cakeDayTippy(creator_name: string): string { + return i18n.t('cake_day_info', { creator_name }); + } +} diff --git a/ui/src/components/comment-node.tsx b/ui/src/components/comment-node.tsx index 155efe8e..762344aa 100644 --- a/ui/src/components/comment-node.tsx +++ b/ui/src/components/comment-node.tsx @@ -33,6 +33,7 @@ import { CommentForm } from './comment-form'; import { CommentNodes } from './comment-nodes'; import { UserListing } from './user-listing'; import { i18n } from '../i18next'; +import { CakeDay } from './cake-day'; interface CommentNodeState { showReply: boolean; @@ -124,6 +125,7 @@ export class CommentNode extends Component { render() { let node = this.props.node; + const { creator_name, creator_published } = node.comment; return (
{ }} /> + + + {this.isMod && (
{i18n.t('mod')} diff --git a/ui/src/components/post-listing.tsx b/ui/src/components/post-listing.tsx index 3d608842..e6b9721c 100644 --- a/ui/src/components/post-listing.tsx +++ b/ui/src/components/post-listing.tsx @@ -35,6 +35,7 @@ import { previewLines, } from '../utils'; import { i18n } from '../i18next'; +import { CakeDay } from './cake-day'; interface PostListingState { showEdit: boolean; @@ -253,6 +254,8 @@ export class PostListing extends Component { listing() { let post = this.props.post; + const { creator_name, creator_published } = post; + return (
@@ -432,6 +435,12 @@ export class PostListing extends Component { actor_id: post.creator_actor_id, }} /> + + + {this.isMod && ( {i18n.t('mod')} diff --git a/ui/src/components/symbols.tsx b/ui/src/components/symbols.tsx index 77d7a086..3386dbe5 100644 --- a/ui/src/components/symbols.tsx +++ b/ui/src/components/symbols.tsx @@ -168,6 +168,9 @@ export class Symbols extends Component { + + + ); diff --git a/ui/src/components/user.tsx b/ui/src/components/user.tsx index 69914fd3..4f680324 100644 --- a/ui/src/components/user.tsx +++ b/ui/src/components/user.tsx @@ -46,6 +46,7 @@ import { ListingTypeSelect } from './listing-type-select'; import { CommentNodes } from './comment-nodes'; import { MomentTime } from './moment-time'; import { i18n } from '../i18next'; +import moment from 'moment'; enum View { Overview, @@ -412,6 +413,15 @@ export class User extends Component { )} +
+ + + + + {i18n.t('cake_day_title')}{' '} + {moment.utc(user.published).local().format('MMM DD, YYYY')} + +
{i18n.t('joined')}
diff --git a/ui/src/interfaces.ts b/ui/src/interfaces.ts index 7e29319f..774836a2 100644 --- a/ui/src/interfaces.ts +++ b/ui/src/interfaces.ts @@ -183,6 +183,7 @@ export interface Post { creator_actor_id: string; creator_local: boolean; creator_name: string; + creator_published: string; creator_avatar?: string; community_actor_id: string; community_local: boolean; @@ -227,6 +228,7 @@ export interface Comment { creator_local: boolean; creator_name: string; creator_avatar?: string; + creator_published: string; score: number; upvotes: number; downvotes: number; -- cgit v1.2.3 From 8fe8836bc263be11895fafa958409499c9e9fc9d Mon Sep 17 00:00:00 2001 From: Filip785 Date: Wed, 8 Jul 2020 19:46:18 +0200 Subject: Updates to PR as requested --- ui/src/components/cake-day.tsx | 35 ++++++++++++----------------------- ui/src/components/comment-node.tsx | 9 ++++----- ui/src/components/post-listing.tsx | 10 ++++------ ui/src/utils.ts | 11 +++++++++++ 4 files changed, 31 insertions(+), 34 deletions(-) (limited to 'ui/src') diff --git a/ui/src/components/cake-day.tsx b/ui/src/components/cake-day.tsx index 67ac7f8b..be807184 100644 --- a/ui/src/components/cake-day.tsx +++ b/ui/src/components/cake-day.tsx @@ -1,37 +1,26 @@ import { Component } from 'inferno'; -import moment from 'moment'; import { i18n } from '../i18next'; interface CakeDayProps { creator_name: string; - creator_published: string; + is_post_creator?: boolean; } export class CakeDay extends Component { render() { - const { creator_name, creator_published } = this.props; + const { creator_name, is_post_creator } = this.props; return ( - this.isCakeDay(creator_published) && ( -
- - - -
- ) - ); - } - - isCakeDay(input: string): boolean { - const userCreationDate = moment.utc(input).local(); - const currentDate = moment(new Date()); - - return ( - userCreationDate.date() === currentDate.date() && - userCreationDate.month() === currentDate.month() +
+ + + +
); } diff --git a/ui/src/components/comment-node.tsx b/ui/src/components/comment-node.tsx index ab9321bd..2d1426b0 100644 --- a/ui/src/components/comment-node.tsx +++ b/ui/src/components/comment-node.tsx @@ -26,6 +26,7 @@ import { isMod, setupTippy, colorList, + isCakeDay, } from '../utils'; import moment from 'moment'; import { MomentTime } from './moment-time'; @@ -126,7 +127,6 @@ export class CommentNode extends Component { render() { let node = this.props.node; - const { creator_name, creator_published } = node.comment; return (
{ /> - + {isCakeDay(node.comment.creator_published) && ( + + )} {this.isMod && (
diff --git a/ui/src/components/post-listing.tsx b/ui/src/components/post-listing.tsx index 7199510b..92a2f9cb 100644 --- a/ui/src/components/post-listing.tsx +++ b/ui/src/components/post-listing.tsx @@ -33,6 +33,7 @@ import { setupTippy, hostname, previewLines, + isCakeDay, } from '../utils'; import { i18n } from '../i18next'; import { CakeDay } from './cake-day'; @@ -258,8 +259,6 @@ export class PostListing extends Component { listing() { let post = this.props.post; - const { creator_name, creator_published } = post; - return (
@@ -440,10 +439,9 @@ export class PostListing extends Component { }} /> - + {isCakeDay(post.creator_published) && ( + + )} {this.isMod && ( diff --git a/ui/src/utils.ts b/ui/src/utils.ts index f65ca4e3..3ccaae12 100644 --- a/ui/src/utils.ts +++ b/ui/src/utils.ts @@ -53,6 +53,7 @@ import emojiShortName from 'emoji-short-name'; import Toastify from 'toastify-js'; import tippy from 'tippy.js'; import EmojiButton from '@joeattardi/emoji-button'; +import moment from 'moment'; export const repoUrl = 'https://github.com/LemmyNet/lemmy'; export const helpGuideUrl = '/docs/about_guide.html'; @@ -489,6 +490,16 @@ export function showAvatars(): boolean { ); } +export function isCakeDay(creator_published: string): boolean { + const userCreationDate = moment.utc(creator_published).local(); + const currentDate = moment(new Date()); + + return ( + userCreationDate.date() === currentDate.date() && + userCreationDate.month() === currentDate.month() + ); +} + // Converts to image thumbnail export function pictrsImage(hash: string, thumbnail: boolean = false): string { let root = `/pictrs/image`; -- cgit v1.2.3 From 75251f6e7868a12420be06d08168dbdf1ed4bc88 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Thu, 9 Jul 2020 09:47:26 -0400 Subject: Adding select quoting of text for comments. Fixes #790 --- ui/src/components/comment-form.tsx | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'ui/src') diff --git a/ui/src/components/comment-form.tsx b/ui/src/components/comment-form.tsx index 770c127c..32bc3786 100644 --- a/ui/src/components/comment-form.tsx +++ b/ui/src/components/comment-form.tsx @@ -98,7 +98,7 @@ export class CommentForm extends Component { } componentDidMount() { - var textarea: any = document.getElementById(this.id); + let textarea: any = document.getElementById(this.id); autosize(textarea); this.tribute.attach(textarea); textarea.addEventListener('tribute-replaced', () => { @@ -106,6 +106,22 @@ export class CommentForm extends Component { this.setState(this.state); autosize.update(textarea); }); + + // Quoting of selected text + let selectedText = window.getSelection().toString(); + if (selectedText) { + let quotedText = + selectedText + .split('\n') + .map(t => `> ${t}`) + .join('\n') + '\n\n'; + this.state.commentForm.content = quotedText; + this.setState(this.state); + // Not sure why this needs a delay + setTimeout(() => autosize.update(textarea), 10); + } + + textarea.focus(); } componentDidUpdate() { -- cgit v1.2.3 From 558644b8b364697159c5832908b8497a44d6179d Mon Sep 17 00:00:00 2001 From: Dessalines Date: Thu, 9 Jul 2020 10:15:12 -0400 Subject: Adding lemmy's devs / contributors to the sidebar. Fixes #743 --- ui/src/components/main.tsx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'ui/src') diff --git a/ui/src/components/main.tsx b/ui/src/components/main.tsx index 20735049..9e9027d6 100644 --- a/ui/src/components/main.tsx +++ b/ui/src/components/main.tsx @@ -373,17 +373,21 @@ export class Main extends Component { # # -

+

#

# -

+

# -

+

# # # # +

+ + # +

-- cgit v1.2.3 From 20f9bde88f52ce875be4d0dc4bd5dd346dfe6b84 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Thu, 9 Jul 2020 10:44:05 -0400 Subject: Making comment collapse and lightning buttons not spans. Fixes #884 --- ui/src/components/comment-node.tsx | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'ui/src') diff --git a/ui/src/components/comment-node.tsx b/ui/src/components/comment-node.tsx index 839a01dc..49b56629 100644 --- a/ui/src/components/comment-node.tsx +++ b/ui/src/components/comment-node.tsx @@ -189,8 +189,8 @@ export class CommentNode extends Component { )} -
{this.state.collapsed ? ( @@ -202,9 +202,11 @@ export class CommentNode extends Component { )} -
- + {/* This is an expanding spacer for mobile */} +
+ -- cgit v1.2.3 From 7c35fc546bb148047087db6ed95b1579bab08238 Mon Sep 17 00:00:00 2001 From: Filip785 Date: Thu, 9 Jul 2020 17:19:30 +0200 Subject: Create new migration to add `creator_published` field to the `post_view` and `comment_view` --- ui/src/utils.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'ui/src') diff --git a/ui/src/utils.ts b/ui/src/utils.ts index a418c569..e38834aa 100644 --- a/ui/src/utils.ts +++ b/ui/src/utils.ts @@ -503,7 +503,9 @@ export function showAvatars(): boolean { } export function isCakeDay(creator_published: string): boolean { - const userCreationDate = moment.utc(creator_published).local(); + // moment(undefined) or moment.utc(undefined) returns the current date/time + // moment(null) or moment.utc(null) returns null + const userCreationDate = moment.utc(creator_published || null).local(); const currentDate = moment(new Date()); return ( -- cgit v1.2.3 From db09730d5f391c37bde87f59ed2ea6f3418034e4 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Thu, 9 Jul 2020 13:32:23 -0400 Subject: Removing twemoji, and the massive emoji picker. Fixes #895 --- ui/src/components/comment-form.tsx | 29 ----------------------------- ui/src/components/post-form.tsx | 29 ----------------------------- ui/src/utils.ts | 17 +---------------- 3 files changed, 1 insertion(+), 74 deletions(-) (limited to 'ui/src') diff --git a/ui/src/components/comment-form.tsx b/ui/src/components/comment-form.tsx index 32bc3786..22f871d2 100644 --- a/ui/src/components/comment-form.tsx +++ b/ui/src/components/comment-form.tsx @@ -17,7 +17,6 @@ import { toast, setupTribute, wsJsonToRes, - emojiPicker, pictrsDeleteToast, } from '../utils'; import { WebSocketService, UserService } from '../services'; @@ -72,7 +71,6 @@ export class CommentForm extends Component { super(props, context); this.tribute = setupTribute(); - this.setupEmojiPicker(); this.state = this.emptyState; @@ -241,15 +239,6 @@ export class CommentForm extends Component { )} - - - - -
@@ -257,20 +246,6 @@ export class CommentForm extends Component { ); } - setupEmojiPicker() { - emojiPicker.on('emoji', twemojiHtmlStr => { - if (this.state.commentForm.content == null) { - this.state.commentForm.content = ''; - } - var el = document.createElement('div'); - el.innerHTML = twemojiHtmlStr; - let nativeUnicode = (el.childNodes[0] as HTMLElement).getAttribute('alt'); - let shortName = `:${emojiShortName[nativeUnicode]}:`; - this.state.commentForm.content += shortName; - this.setState(this.state); - }); - } - handleFinished(op: UserOperation, data: CommentResponse) { let isReply = this.props.node !== undefined && data.comment.parent_id !== null; @@ -318,10 +293,6 @@ export class CommentForm extends Component { i.setState(i.state); } - handleEmojiPickerClick(_i: CommentForm, event: any) { - emojiPicker.togglePicker(event.target); - } - handleCommentContentChange(i: CommentForm, event: any) { i.state.commentForm.content = event.target.value; i.setState(i.state); diff --git a/ui/src/components/post-form.tsx b/ui/src/components/post-form.tsx index a88d38c7..fc7884d7 100644 --- a/ui/src/components/post-form.tsx +++ b/ui/src/components/post-form.tsx @@ -33,7 +33,6 @@ import { randomStr, setupTribute, setupTippy, - emojiPicker, hostname, pictrsDeleteToast, } from '../utils'; @@ -95,7 +94,6 @@ export class PostForm extends Component { this.fetchPageTitle = debounce(this.fetchPageTitle).bind(this); this.tribute = setupTribute(); - this.setupEmojiPicker(); this.state = this.emptyState; @@ -332,15 +330,6 @@ export class PostForm extends Component { - - - - -
{!this.props.post && ( @@ -420,20 +409,6 @@ export class PostForm extends Component { ); } - setupEmojiPicker() { - emojiPicker.on('emoji', twemojiHtmlStr => { - if (this.state.postForm.body == null) { - this.state.postForm.body = ''; - } - var el = document.createElement('div'); - el.innerHTML = twemojiHtmlStr; - let nativeUnicode = (el.childNodes[0] as HTMLElement).getAttribute('alt'); - let shortName = `:${emojiShortName[nativeUnicode]}:`; - this.state.postForm.body += shortName; - this.setState(this.state); - }); - } - handlePostSubmit(i: PostForm, event: any) { event.preventDefault(); @@ -596,10 +571,6 @@ export class PostForm extends Component { }); } - handleEmojiPickerClick(_i: PostForm, event: any) { - emojiPicker.togglePicker(event.target); - } - parseMessage(msg: WebSocketJsonResponse) { let res = wsJsonToRes(msg); if (msg.error) { diff --git a/ui/src/utils.ts b/ui/src/utils.ts index 3b077794..b3d0f368 100644 --- a/ui/src/utils.ts +++ b/ui/src/utils.ts @@ -51,11 +51,9 @@ import Tribute from 'tributejs/src/Tribute.js'; import markdown_it from 'markdown-it'; import markdownitEmoji from 'markdown-it-emoji/light'; import markdown_it_container from 'markdown-it-container'; -import twemoji from 'twemoji'; import emojiShortName from 'emoji-short-name'; import Toastify from 'toastify-js'; import tippy from 'tippy.js'; -import EmojiButton from '@joeattardi/emoji-button'; export const repoUrl = 'https://github.com/LemmyNet/lemmy'; export const helpGuideUrl = '/docs/about_guide.html'; @@ -114,14 +112,6 @@ export const themes = [ 'litely', ]; -export const emojiPicker = new EmojiButton({ - // Use the emojiShortName from native - style: 'twemoji', - theme: 'dark', - position: 'auto-start', - // TODO i18n -}); - const DEFAULT_ALPHABET = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; @@ -178,10 +168,6 @@ export const md = new markdown_it({ defs: objectFlip(emojiShortName), }); -md.renderer.rules.emoji = function (token, idx) { - return twemoji.parse(token[idx].content); -}; - export function hotRankComment(comment: Comment): number { return hotRank(comment.score, comment.published); } @@ -590,8 +576,7 @@ export function setupTribute(): Tribute { trigger: ':', menuItemTemplate: (item: any) => { let shortName = `:${item.original.key}:`; - let twemojiIcon = twemoji.parse(item.original.val); - return `${twemojiIcon} ${shortName}`; + return `${item.original.val} ${shortName}`; }, selectTemplate: (item: any) => { return `:${item.original.key}:`; -- cgit v1.2.3 From d222c60cef289b57f0ce350e9f24ce2df4792ef5 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Thu, 9 Jul 2020 19:59:02 -0400 Subject: A few cake day fixes. #916 --- ui/src/components/cake-day.tsx | 15 +++++---------- ui/src/components/comment-node.tsx | 7 +------ ui/src/components/post-listing.tsx | 7 +------ ui/src/components/user-listing.tsx | 35 +++++++++++++++++++++++------------ ui/src/utils.ts | 4 ++-- 5 files changed, 32 insertions(+), 36 deletions(-) (limited to 'ui/src') diff --git a/ui/src/components/cake-day.tsx b/ui/src/components/cake-day.tsx index be807184..f28be33c 100644 --- a/ui/src/components/cake-day.tsx +++ b/ui/src/components/cake-day.tsx @@ -2,20 +2,15 @@ import { Component } from 'inferno'; import { i18n } from '../i18next'; interface CakeDayProps { - creator_name: string; - is_post_creator?: boolean; + creatorName: string; } export class CakeDay extends Component { render() { - const { creator_name, is_post_creator } = this.props; - return (
@@ -24,7 +19,7 @@ export class CakeDay extends Component { ); } - cakeDayTippy(creator_name: string): string { - return i18n.t('cake_day_info', { creator_name }); + cakeDayTippy(): string { + return i18n.t('cake_day_info', { creator_name: this.props.creatorName }); } } diff --git a/ui/src/components/comment-node.tsx b/ui/src/components/comment-node.tsx index 0e2d1d94..8e976e7c 100644 --- a/ui/src/components/comment-node.tsx +++ b/ui/src/components/comment-node.tsx @@ -26,7 +26,6 @@ import { isMod, setupTippy, colorList, - isCakeDay, } from '../utils'; import moment from 'moment'; import { MomentTime } from './moment-time'; @@ -34,7 +33,6 @@ import { CommentForm } from './comment-form'; import { CommentNodes } from './comment-nodes'; import { UserListing } from './user-listing'; import { i18n } from '../i18next'; -import { CakeDay } from './cake-day'; interface CommentNodeState { showReply: boolean; @@ -160,14 +158,11 @@ export class CommentNode extends Component { id: node.comment.creator_id, local: node.comment.creator_local, actor_id: node.comment.creator_actor_id, + published: node.comment.creator_published, }} /> - {isCakeDay(node.comment.creator_published) && ( - - )} - {this.isMod && (
{i18n.t('mod')} diff --git a/ui/src/components/post-listing.tsx b/ui/src/components/post-listing.tsx index 92a2f9cb..fa2a078e 100644 --- a/ui/src/components/post-listing.tsx +++ b/ui/src/components/post-listing.tsx @@ -33,10 +33,8 @@ import { setupTippy, hostname, previewLines, - isCakeDay, } from '../utils'; import { i18n } from '../i18next'; -import { CakeDay } from './cake-day'; interface PostListingState { showEdit: boolean; @@ -436,13 +434,10 @@ export class PostListing extends Component { id: post.creator_id, local: post.creator_local, actor_id: post.creator_actor_id, + published: post.creator_published, }} /> - {isCakeDay(post.creator_published) && ( - - )} - {this.isMod && ( {i18n.t('mod')} diff --git a/ui/src/components/user-listing.tsx b/ui/src/components/user-listing.tsx index 0e150b94..58475d3e 100644 --- a/ui/src/components/user-listing.tsx +++ b/ui/src/components/user-listing.tsx @@ -1,7 +1,13 @@ import { Component } from 'inferno'; import { Link } from 'inferno-router'; import { UserView } from '../interfaces'; -import { pictrsAvatarThumbnail, showAvatars, hostname } from '../utils'; +import { + pictrsAvatarThumbnail, + showAvatars, + hostname, + isCakeDay, +} from '../utils'; +import { CakeDay } from './cake-day'; interface UserOther { name: string; @@ -9,6 +15,7 @@ interface UserOther { avatar?: string; local?: boolean; actor_id?: string; + published?: string; } interface UserListingProps { @@ -35,17 +42,21 @@ export class UserListing extends Component { } return ( - - {user.avatar && showAvatars() && ( - - )} - {name_} - + <> + + {user.avatar && showAvatars() && ( + + )} + {name_} + + + {isCakeDay(user.published) && } + ); } } diff --git a/ui/src/utils.ts b/ui/src/utils.ts index e38834aa..22536043 100644 --- a/ui/src/utils.ts +++ b/ui/src/utils.ts @@ -502,10 +502,10 @@ export function showAvatars(): boolean { ); } -export function isCakeDay(creator_published: string): boolean { +export function isCakeDay(published: string): boolean { // moment(undefined) or moment.utc(undefined) returns the current date/time // moment(null) or moment.utc(null) returns null - const userCreationDate = moment.utc(creator_published || null).local(); + const userCreationDate = moment.utc(published || null).local(); const currentDate = moment(new Date()); return ( -- cgit v1.2.3 From 85c07e7154c82e5b387bb6a02aae70645cf1d8e0 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Thu, 9 Jul 2020 20:03:33 -0400 Subject: Correctly hide next / prev in paginators. Fixes #914 (#927) --- ui/src/components/communities.tsx | 2 +- ui/src/components/community.tsx | 2 +- ui/src/components/inbox.tsx | 30 ++++++++++++++++++------------ ui/src/components/main.tsx | 2 +- ui/src/components/search.tsx | 30 +++++++++++++++--------------- ui/src/components/user.tsx | 14 ++++++++------ 6 files changed, 44 insertions(+), 36 deletions(-) (limited to 'ui/src') diff --git a/ui/src/components/communities.tsx b/ui/src/components/communities.tsx index 441f7bb1..10a3ab80 100644 --- a/ui/src/components/communities.tsx +++ b/ui/src/components/communities.tsx @@ -160,7 +160,7 @@ export class Communities extends Component { )} - {this.state.communities.length == communityLimit && ( + {this.state.communities.length > 0 && ( )} - {this.state.posts.length == fetchLimit && ( + {this.state.posts.length > 0 && ( )} - + {this.unreadCount() > 0 && ( + + )}
); } @@ -534,15 +536,19 @@ export class Inbox extends Component { } sendUnreadCount() { - let count = + UserService.Instance.user.unreadCount = this.unreadCount(); + UserService.Instance.sub.next({ + user: UserService.Instance.user, + }); + } + + unreadCount(): number { + return ( this.state.replies.filter(r => !r.read).length + this.state.mentions.filter(r => !r.read).length + this.state.messages.filter( r => !r.read && r.creator_id !== UserService.Instance.user.id - ).length; - UserService.Instance.user.unreadCount = count; - UserService.Instance.sub.next({ - user: UserService.Instance.user, - }); + ).length + ); } } diff --git a/ui/src/components/main.tsx b/ui/src/components/main.tsx index 9e9027d6..9063a039 100644 --- a/ui/src/components/main.tsx +++ b/ui/src/components/main.tsx @@ -497,7 +497,7 @@ export class Main extends Component { {i18n.t('prev')} )} - {this.state.posts.length == fetchLimit && ( + {this.state.posts.length > 0 && (
); @@ -383,26 +383,26 @@ export class Search extends Component { {i18n.t('prev')} )} - + + {this.resultsCount() > 0 && ( + + )}
); } - noResults() { + resultsCount(): number { let res = this.state.searchResponse; return ( -
- {res && - res.posts.length == 0 && - res.comments.length == 0 && - res.communities.length == 0 && - res.users.length == 0 && {i18n.t('no_results')}} -
+ res.posts.length + + res.comments.length + + res.communities.length + + res.users.length ); } diff --git a/ui/src/components/user.tsx b/ui/src/components/user.tsx index 7e679ed1..af72a397 100644 --- a/ui/src/components/user.tsx +++ b/ui/src/components/user.tsx @@ -893,12 +893,14 @@ export class User extends Component { {i18n.t('prev')} )} - + {this.state.comments.length + this.state.posts.length > 0 && ( + + )}
); } -- cgit v1.2.3 From 50e6d81d0b40e1d9caa0db83d20026adf3aef631 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Thu, 9 Jul 2020 20:03:47 -0400 Subject: Redirect to login page for votes, comments, pages, etc. Fixes #849 (#926) --- ui/src/components/comment-form.tsx | 255 ++++++++++++++------------- ui/src/components/create-community.tsx | 7 +- ui/src/components/create-post.tsx | 7 +- ui/src/components/create-private-message.tsx | 7 +- ui/src/components/post-listing.tsx | 9 + 5 files changed, 163 insertions(+), 122 deletions(-) (limited to 'ui/src') diff --git a/ui/src/components/comment-form.tsx b/ui/src/components/comment-form.tsx index 32bc3786..a433dbd4 100644 --- a/ui/src/components/comment-form.tsx +++ b/ui/src/components/comment-form.tsx @@ -1,4 +1,5 @@ import { Component, linkEvent } from 'inferno'; +import { Link } from 'inferno-router'; import { Subscription } from 'rxjs'; import { retryWhen, delay, take } from 'rxjs/operators'; import { Prompt } from 'inferno-router'; @@ -25,6 +26,7 @@ import autosize from 'autosize'; import Tribute from 'tributejs/src/Tribute.js'; import emojiShortName from 'emoji-short-name'; import { i18n } from '../i18next'; +import { T } from 'inferno-i18next'; interface CommentFormProps { postId?: number; @@ -99,29 +101,31 @@ export class CommentForm extends Component { componentDidMount() { let textarea: any = document.getElementById(this.id); - autosize(textarea); - this.tribute.attach(textarea); - textarea.addEventListener('tribute-replaced', () => { - this.state.commentForm.content = textarea.value; - this.setState(this.state); - autosize.update(textarea); - }); + if (textarea) { + autosize(textarea); + this.tribute.attach(textarea); + textarea.addEventListener('tribute-replaced', () => { + this.state.commentForm.content = textarea.value; + this.setState(this.state); + autosize.update(textarea); + }); - // Quoting of selected text - let selectedText = window.getSelection().toString(); - if (selectedText) { - let quotedText = - selectedText - .split('\n') - .map(t => `> ${t}`) - .join('\n') + '\n\n'; - this.state.commentForm.content = quotedText; - this.setState(this.state); - // Not sure why this needs a delay - setTimeout(() => autosize.update(textarea), 10); - } + // Quoting of selected text + let selectedText = window.getSelection().toString(); + if (selectedText) { + let quotedText = + selectedText + .split('\n') + .map(t => `> ${t}`) + .join('\n') + '\n\n'; + this.state.commentForm.content = quotedText; + this.setState(this.state); + // Not sure why this needs a delay + setTimeout(() => autosize.update(textarea), 10); + } - textarea.focus(); + textarea.focus(); + } } componentDidUpdate() { @@ -144,115 +148,128 @@ export class CommentForm extends Component { when={this.state.commentForm.content} message={i18n.t('block_leaving')} /> -
-
-
-