summaryrefslogtreecommitdiff
path: root/front/src/components/post
diff options
context:
space:
mode:
Diffstat (limited to 'front/src/components/post')
-rw-r--r--front/src/components/post/Footer.tsx12
-rw-r--r--front/src/components/post/Reactions.tsx20
2 files changed, 29 insertions, 3 deletions
diff --git a/front/src/components/post/Footer.tsx b/front/src/components/post/Footer.tsx
index 3e4bbdc..d16f4fc 100644
--- a/front/src/components/post/Footer.tsx
+++ b/front/src/components/post/Footer.tsx
@@ -13,15 +13,25 @@ function Footer({ poast, refetch }: PostProps) {
const [_showMenu, setShowMenu] = useState(false);
const [location, navigate] = useLocation();
const [reposting, _setReposting] = useState(false);
- const { api, setComposerData, setModal } = useLocalState((s) => ({
+ const { api, setComposerData, setModal, addNotification } = useLocalState((s) => ({
api: s.api,
setComposerData: s.setComposerData,
setModal: s.setModal,
+ addNotification: s.addNotification,
}));
const our = api!.airlock.our!;
function doReply(e: React.MouseEvent) {
e.stopPropagation();
setComposerData({ type: "reply", post: { trill: poast } });
+ // Only add notification if replying to someone else's post
+ if (poast.author !== our) {
+ addNotification({
+ type: "reply",
+ from: our,
+ message: `You replied to ${poast.author}'s post`,
+ postId: poast.id,
+ });
+ }
}
function doQuote(e: React.MouseEvent) {
e.stopPropagation();
diff --git a/front/src/components/post/Reactions.tsx b/front/src/components/post/Reactions.tsx
index aabab61..ee40d26 100644
--- a/front/src/components/post/Reactions.tsx
+++ b/front/src/components/post/Reactions.tsx
@@ -110,9 +110,25 @@ export function stringToReact(s: string) {
}
export function TrillReactModal({ poast }: { poast: Poast }) {
- const { api } = useLocalState();
+ const { api, addNotification } = useLocalState((s) => ({
+ api: s.api,
+ addNotification: s.addNotification,
+ }));
+ const our = api!.airlock.our!;
+
async function sendReact(s: string) {
- return await api!.addReact(poast.host, poast.id, s);
+ const result = await api!.addReact(poast.host, poast.id, s);
+ // Only add notification if reacting to someone else's post
+ if (result && poast.author !== our) {
+ addNotification({
+ type: "react",
+ from: our,
+ message: `You reacted to ${poast.author}'s post`,
+ reaction: s,
+ postId: poast.id,
+ });
+ }
+ return result;
}
return <ReactModal send={sendReact} />;
}