mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-03-21 21:29:20 +01:00
"Delete" status feature
This commit is contained in:
parent
84e064ff30
commit
89c03945a3
3 changed files with 76 additions and 22 deletions
|
@ -65,6 +65,7 @@ const ICONS = {
|
||||||
exit: 'mingcute:exit-line',
|
exit: 'mingcute:exit-line',
|
||||||
translate: 'mingcute:translate-line',
|
translate: 'mingcute:translate-line',
|
||||||
play: 'mingcute:play-fill',
|
play: 'mingcute:play-fill',
|
||||||
|
trash: 'mingcute:delete-2-line',
|
||||||
};
|
};
|
||||||
|
|
||||||
const modules = import.meta.glob('/node_modules/@iconify-icons/mingcute/*.js');
|
const modules = import.meta.glob('/node_modules/@iconify-icons/mingcute/*.js');
|
||||||
|
|
|
@ -810,6 +810,10 @@ a.card:is(:hover, :focus) {
|
||||||
border-top: var(--hairline-width) solid var(--outline-color);
|
border-top: var(--hairline-width) solid var(--outline-color);
|
||||||
margin-top: 8px;
|
margin-top: 8px;
|
||||||
}
|
}
|
||||||
|
.status.large .actions.disabled {
|
||||||
|
pointer-events: none;
|
||||||
|
opacity: 0.5;
|
||||||
|
}
|
||||||
.status .action.has-count {
|
.status .action.has-count {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
}
|
}
|
||||||
|
@ -984,3 +988,14 @@ a.card:is(:hover, :focus) {
|
||||||
border: 1px solid var(--outline-color);
|
border: 1px solid var(--outline-color);
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* DELETED */
|
||||||
|
|
||||||
|
.status-deleted {
|
||||||
|
opacity: 0.75;
|
||||||
|
}
|
||||||
|
.status-deleted-tag {
|
||||||
|
color: var(--text-insignificant-color);
|
||||||
|
text-transform: uppercase;
|
||||||
|
font-size: 80%;
|
||||||
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ import htmlContentLength from '../utils/html-content-length';
|
||||||
import niceDateTime from '../utils/nice-date-time';
|
import niceDateTime from '../utils/nice-date-time';
|
||||||
import shortenNumber from '../utils/shorten-number';
|
import shortenNumber from '../utils/shorten-number';
|
||||||
import showToast from '../utils/show-toast';
|
import showToast from '../utils/show-toast';
|
||||||
import states, { saveStatus, statusKey } from '../utils/states';
|
import states, { getStatus, saveStatus, statusKey } from '../utils/states';
|
||||||
import store from '../utils/store';
|
import store from '../utils/store';
|
||||||
import visibilityIconsMap from '../utils/visibility-icons-map';
|
import visibilityIconsMap from '../utils/visibility-icons-map';
|
||||||
|
|
||||||
|
@ -543,6 +543,29 @@ function Status({
|
||||||
<Icon icon="pencil" />
|
<Icon icon="pencil" />
|
||||||
<span>Edit</span>
|
<span>Edit</span>
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
|
{isSizeLarge && (
|
||||||
|
<MenuItem
|
||||||
|
onClick={() => {
|
||||||
|
const yes = confirm('Delete this post?');
|
||||||
|
if (yes) {
|
||||||
|
(async () => {
|
||||||
|
try {
|
||||||
|
await masto.v1.statuses.remove(id);
|
||||||
|
const cachedStatus = getStatus(id, instance);
|
||||||
|
cachedStatus._deleted = true;
|
||||||
|
showToast('Deleted');
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e);
|
||||||
|
showToast('Unable to delete');
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Icon icon="trash" />
|
||||||
|
<span>Delete…</span>
|
||||||
|
</MenuItem>
|
||||||
|
)}
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
|
@ -582,12 +605,13 @@ function Status({
|
||||||
m: 'medium',
|
m: 'medium',
|
||||||
l: 'large',
|
l: 'large',
|
||||||
}[size]
|
}[size]
|
||||||
}`}
|
} ${_deleted ? 'status-deleted' : ''}`}
|
||||||
onMouseEnter={debugHover}
|
onMouseEnter={debugHover}
|
||||||
onContextMenu={(e) => {
|
onContextMenu={(e) => {
|
||||||
if (size === 'l') return;
|
if (size === 'l') return;
|
||||||
if (e.metaKey) return;
|
if (e.metaKey) return;
|
||||||
if (previewMode) return;
|
if (previewMode) return;
|
||||||
|
if (_deleted) return;
|
||||||
// console.log('context menu', e);
|
// console.log('context menu', e);
|
||||||
const link = e.target.closest('a');
|
const link = e.target.closest('a');
|
||||||
if (link && /^https?:\/\//.test(link.getAttribute('href'))) return;
|
if (link && /^https?:\/\//.test(link.getAttribute('href'))) return;
|
||||||
|
@ -672,7 +696,9 @@ function Status({
|
||||||
)} */}
|
)} */}
|
||||||
{/* </span> */}{' '}
|
{/* </span> */}{' '}
|
||||||
{size !== 'l' &&
|
{size !== 'l' &&
|
||||||
(url && !previewMode ? (
|
(_deleted ? (
|
||||||
|
<span class="status-deleted-tag">Deleted</span>
|
||||||
|
) : url && !previewMode ? (
|
||||||
<Menu
|
<Menu
|
||||||
instanceRef={menuInstanceRef}
|
instanceRef={menuInstanceRef}
|
||||||
portal={{
|
portal={{
|
||||||
|
@ -931,29 +957,41 @@ function Status({
|
||||||
{isSizeLarge && (
|
{isSizeLarge && (
|
||||||
<>
|
<>
|
||||||
<div class="extra-meta">
|
<div class="extra-meta">
|
||||||
<Icon icon={visibilityIconsMap[visibility]} alt={visibility} />{' '}
|
{_deleted ? (
|
||||||
<a href={url} target="_blank">
|
<span class="status-deleted-tag">Deleted</span>
|
||||||
<time class="created" datetime={createdAtDate.toISOString()}>
|
) : (
|
||||||
{createdDateText}
|
|
||||||
</time>
|
|
||||||
</a>
|
|
||||||
{editedAt && (
|
|
||||||
<>
|
<>
|
||||||
{' '}
|
<Icon
|
||||||
• <Icon icon="pencil" alt="Edited" />{' '}
|
icon={visibilityIconsMap[visibility]}
|
||||||
<time
|
alt={visibility}
|
||||||
class="edited"
|
/>{' '}
|
||||||
datetime={editedAtDate.toISOString()}
|
<a href={url} target="_blank">
|
||||||
onClick={() => {
|
<time
|
||||||
setShowEdited(id);
|
class="created"
|
||||||
}}
|
datetime={createdAtDate.toISOString()}
|
||||||
>
|
>
|
||||||
{editedDateText}
|
{createdDateText}
|
||||||
</time>
|
</time>
|
||||||
|
</a>
|
||||||
|
{editedAt && (
|
||||||
|
<>
|
||||||
|
{' '}
|
||||||
|
• <Icon icon="pencil" alt="Edited" />{' '}
|
||||||
|
<time
|
||||||
|
class="edited"
|
||||||
|
datetime={editedAtDate.toISOString()}
|
||||||
|
onClick={() => {
|
||||||
|
setShowEdited(id);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{editedDateText}
|
||||||
|
</time>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div class="actions">
|
<div class={`actions ${_deleted ? 'disabled' : ''}`}>
|
||||||
<div class="action has-count">
|
<div class="action has-count">
|
||||||
<StatusButton
|
<StatusButton
|
||||||
title="Reply"
|
title="Reply"
|
||||||
|
|
Loading…
Reference in a new issue