From 46dfd9aab0924bc53b1823732389b1b836aa506b Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Thu, 18 Jan 2024 19:05:12 +0800 Subject: [PATCH] MVP-ish pin/unpin post --- src/components/icon.jsx | 1 + src/components/status.jsx | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/src/components/icon.jsx b/src/components/icon.jsx index 5942cfd1..96aab287 100644 --- a/src/components/icon.jsx +++ b/src/components/icon.jsx @@ -66,6 +66,7 @@ export const ICONS = { user: () => import('@iconify-icons/mingcute/user-4-line'), following: () => import('@iconify-icons/mingcute/walk-line'), pin: () => import('@iconify-icons/mingcute/pin-line'), + unpin: [() => import('@iconify-icons/mingcute/pin-line'), '180deg'], bus: () => import('@iconify-icons/mingcute/bus-2-line'), link: () => import('@iconify-icons/mingcute/link-2-line'), history: () => import('@iconify-icons/mingcute/history-line'), diff --git a/src/components/status.jsx b/src/components/status.jsx index 1cafe762..158bfa5f 100644 --- a/src/components/status.jsx +++ b/src/components/status.jsx @@ -937,6 +937,40 @@ function Status({ )} )} + {isSelf && /(public|unlisted|private)/i.test(visibility) && ( + { + try { + const newStatus = await masto.v1.statuses + .$select(id) + [_pinned ? 'unpin' : 'pin'](); + // saveStatus(newStatus, instance); + showToast( + _pinned + ? 'Post unpinned from profile' + : 'Post pinned to profile', + ); + } catch (e) { + console.error(e); + showToast( + _pinned ? 'Unable to unpin post' : 'Unable to pin post', + ); + } + }} + > + {_pinned ? ( + <> + + Unpin from profile + + ) : ( + <> + + Pin to profile + + )} + + )} {isSelf && (