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<CakeDayProps, any> {
render() {
- const { creator_name, creator_published } = this.props;
+ const { creator_name, is_post_creator } = this.props;
return (
- this.isCakeDay(creator_published) && (
- <div
- className="mr-lg-2 d-inline-block unselectable pointer mx-2"
- data-tippy-content={this.cakeDayTippy(creator_name)}
- >
- <svg class="icon icon-inline">
- <use xlinkHref="#icon-cake"></use>
- </svg>
- </div>
- )
- );
- }
-
- isCakeDay(input: string): boolean {
- const userCreationDate = moment.utc(input).local();
- const currentDate = moment(new Date());
-
- return (
- userCreationDate.date() === currentDate.date() &&
- userCreationDate.month() === currentDate.month()
+ <div
+ className={`mr-lg-2 d-inline-block unselectable pointer${
+ is_post_creator ? ' mx-2' : ''
+ }`}
+ data-tippy-content={this.cakeDayTippy(creator_name)}
+ >
+ <svg class="icon icon-inline">
+ <use xlinkHref="#icon-cake"></use>
+ </svg>
+ </div>
);
}
isMod,
setupTippy,
colorList,
+ isCakeDay,
} from '../utils';
import moment from 'moment';
import { MomentTime } from './moment-time';
render() {
let node = this.props.node;
- const { creator_name, creator_published } = node.comment;
return (
<div
className={`comment ${
/>
</span>
- <CakeDay
- creator_name={creator_name}
- creator_published={creator_published}
- />
+ {isCakeDay(node.comment.creator_published) && (
+ <CakeDay creator_name={node.comment.creator_name} />
+ )}
{this.isMod && (
<div className="badge badge-light d-none d-sm-inline mr-2">
setupTippy,
hostname,
previewLines,
+ isCakeDay,
} from '../utils';
import { i18n } from '../i18next';
import { CakeDay } from './cake-day';
listing() {
let post = this.props.post;
- const { creator_name, creator_published } = post;
-
return (
<div class="row">
<div className={`vote-bar col-1 pr-0 small text-center`}>
}}
/>
- <CakeDay
- creator_name={creator_name}
- creator_published={creator_published}
- />
+ {isCakeDay(post.creator_published) && (
+ <CakeDay creator_name={post.creator_name} is_post_creator />
+ )}
{this.isMod && (
<span className="mx-1 badge badge-light">
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';
);
}
+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`;