From 2be380ef762cda0ea9d0e0ac0aafe3ec732f387d Mon Sep 17 00:00:00 2001 From: Dessalines Date: Sat, 23 Jan 2021 16:40:24 -0500 Subject: [PATCH] Adding tippy to new comments. Fixes #92 --- src/shared/components/post.tsx | 1 + src/shared/utils.ts | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/shared/components/post.tsx b/src/shared/components/post.tsx index 2bbd7e8..2068305 100644 --- a/src/shared/components/post.tsx +++ b/src/shared/components/post.tsx @@ -485,6 +485,7 @@ export class Post extends Component { this.state.postRes.comments.unshift(data.comment_view); this.state.postRes.post_view.counts.comments++; this.setState(this.state); + setupTippy(); } } else if ( op == UserOperation.EditComment || diff --git a/src/shared/utils.ts b/src/shared/utils.ts index b04fd05..564fd61 100644 --- a/src/shared/utils.ts +++ b/src/shared/utils.ts @@ -52,7 +52,7 @@ import { } from './interfaces'; import { UserService, WebSocketService } from './services'; -var Tribute; +var Tribute: any; if (isBrowser()) { Tribute = require('tributejs'); } @@ -635,8 +635,8 @@ function notify(info: NotifyInfo, router: any) { body: info.body, }); - notification.onclick = () => { - event.preventDefault(); + notification.onclick = (ev: Event): any => { + ev.preventDefault(); router.history.push(info.link); }; } @@ -708,14 +708,14 @@ export function setupTribute() { }); } -var tippyInstance; +var tippyInstance: any; if (isBrowser()) { tippyInstance = tippy('[data-tippy-content]'); } export function setupTippy() { if (isBrowser()) { - tippyInstance.forEach(e => e.destroy()); + tippyInstance.forEach((e: any) => e.destroy()); tippyInstance = tippy('[data-tippy-content]', { delay: [500, 0], // Display on "long press" -- 2.44.1