MVP-ish pin/unpin post

This commit is contained in:
Lim Chee Aun 2024-01-18 19:05:12 +08:00
parent 59d0138ca8
commit 46dfd9aab0
2 changed files with 35 additions and 0 deletions

View file

@ -66,6 +66,7 @@ export const ICONS = {
user: () => import('@iconify-icons/mingcute/user-4-line'), user: () => import('@iconify-icons/mingcute/user-4-line'),
following: () => import('@iconify-icons/mingcute/walk-line'), following: () => import('@iconify-icons/mingcute/walk-line'),
pin: () => import('@iconify-icons/mingcute/pin-line'), pin: () => import('@iconify-icons/mingcute/pin-line'),
unpin: [() => import('@iconify-icons/mingcute/pin-line'), '180deg'],
bus: () => import('@iconify-icons/mingcute/bus-2-line'), bus: () => import('@iconify-icons/mingcute/bus-2-line'),
link: () => import('@iconify-icons/mingcute/link-2-line'), link: () => import('@iconify-icons/mingcute/link-2-line'),
history: () => import('@iconify-icons/mingcute/history-line'), history: () => import('@iconify-icons/mingcute/history-line'),

View file

@ -937,6 +937,40 @@ function Status({
)} )}
</MenuItem> </MenuItem>
)} )}
{isSelf && /(public|unlisted|private)/i.test(visibility) && (
<MenuItem
onClick={async () => {
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 ? (
<>
<Icon icon="unpin" />
<span>Unpin from profile</span>
</>
) : (
<>
<Icon icon="pin" />
<span>Pin to profile</span>
</>
)}
</MenuItem>
)}
{isSelf && ( {isSelf && (
<div class="menu-horizontal"> <div class="menu-horizontal">
<MenuItem <MenuItem