aboutsummaryrefslogtreecommitdiff
path: root/FrontEnd/src/pages/timeline/view
diff options
context:
space:
mode:
Diffstat (limited to 'FrontEnd/src/pages/timeline/view')
-rw-r--r--FrontEnd/src/pages/timeline/view/MarkdownPostView.tsx23
-rw-r--r--FrontEnd/src/pages/timeline/view/PlainTextPostView.tsx23
2 files changed, 22 insertions, 24 deletions
diff --git a/FrontEnd/src/pages/timeline/view/MarkdownPostView.tsx b/FrontEnd/src/pages/timeline/view/MarkdownPostView.tsx
index 9bb9f980..d0a43f7d 100644
--- a/FrontEnd/src/pages/timeline/view/MarkdownPostView.tsx
+++ b/FrontEnd/src/pages/timeline/view/MarkdownPostView.tsx
@@ -1,4 +1,4 @@
-import { useMemo, useState } from "react";
+import { useEffect, useMemo, useState } from "react";
import { marked } from "marked";
import classNames from "classnames";
@@ -7,7 +7,7 @@ import {
getHttpTimelineClient,
} from "~src/http/timeline";
-import { useAutoUnsubscribePromise } from "~src/components/hooks";
+import { subscribePromise } from "~src/components/utilities";
import Skeleton from "~src/components/Skeleton";
import "./MarkdownPostView.css";
@@ -23,19 +23,18 @@ export default function MarkdownPostView({
}: MarkdownPostViewProps) {
const [markdown, setMarkdown] = useState<string | null>(null);
- useAutoUnsubscribePromise(
- () => {
- if (post) {
- return getHttpTimelineClient().getPostDataAsString(
+ useEffect(() => {
+ if (post) {
+ return subscribePromise(
+ getHttpTimelineClient().getPostDataAsString(
post.timelineOwnerV2,
post.timelineNameV2,
post.id,
- );
- }
- },
- setMarkdown,
- [post],
- );
+ ),
+ setMarkdown,
+ );
+ }
+ }, [post]);
const markdownHtml = useMemo<string | null>(() => {
if (markdown == null) return null;
diff --git a/FrontEnd/src/pages/timeline/view/PlainTextPostView.tsx b/FrontEnd/src/pages/timeline/view/PlainTextPostView.tsx
index b964187d..d66bf05b 100644
--- a/FrontEnd/src/pages/timeline/view/PlainTextPostView.tsx
+++ b/FrontEnd/src/pages/timeline/view/PlainTextPostView.tsx
@@ -1,4 +1,4 @@
-import { useState } from "react";
+import { useEffect, useState } from "react";
import classNames from "classnames";
import {
@@ -6,8 +6,8 @@ import {
getHttpTimelineClient,
} from "~src/http/timeline";
+import { subscribePromise } from "~src/components/utilities";
import Skeleton from "~src/components/Skeleton";
-import { useAutoUnsubscribePromise } from "~src/components/hooks";
import "./PlainTextPostView.css";
@@ -22,19 +22,18 @@ export default function PlainTextPostView({
}: PlainTextPostViewProps) {
const [text, setText] = useState<string | null>(null);
- useAutoUnsubscribePromise(
- () => {
- if (post) {
- return getHttpTimelineClient().getPostDataAsString(
+ useEffect(() => {
+ if (post) {
+ return subscribePromise(
+ getHttpTimelineClient().getPostDataAsString(
post.timelineOwnerV2,
post.timelineNameV2,
post.id,
- );
- }
- },
- setText,
- [post],
- );
+ ),
+ setText,
+ );
+ }
+ }, [post]);
return (
<div