{
e.preventDefault();
e.stopPropagation();
@@ -485,23 +784,13 @@ function Status({
)}
- {size === 'l' && (
+ {isSizeLarge && (
<>
- {/* TODO: if visibility = private, only can reblog own statuses */}
- {visibility !== 'direct' && (
+ {canBoost && (
{
- if (!sameInstance || !authenticated) {
- return alert(unauthInteractionErrorMessage);
- }
- try {
- if (!reblogged) {
- const yes = confirm('Boost this post?');
- if (!yes) {
- return;
- }
- }
- // Optimistic
- states.statuses[sKey] = {
- ...status,
- reblogged: !reblogged,
- reblogsCount: reblogsCount + (reblogged ? -1 : 1),
- };
- if (reblogged) {
- const newStatus = await masto.v1.statuses.unreblog(
- id,
- );
- saveStatus(newStatus, instance);
- } else {
- const newStatus = await masto.v1.statuses.reblog(id);
- saveStatus(newStatus, instance);
- }
- } catch (e) {
- console.error(e);
- // Revert optimistism
- states.statuses[sKey] = status;
- }
- }}
+ onClick={boostStatus}
/>
)}
@@ -601,33 +841,7 @@ function Status({
class="favourite-button"
icon="heart"
count={favouritesCount}
- onClick={async () => {
- if (!sameInstance || !authenticated) {
- return alert(unauthInteractionErrorMessage);
- }
- try {
- // Optimistic
- states.statuses[sKey] = {
- ...status,
- favourited: !favourited,
- favouritesCount:
- favouritesCount + (favourited ? -1 : 1),
- };
- if (favourited) {
- const newStatus = await masto.v1.statuses.unfavourite(
- id,
- );
- saveStatus(newStatus, instance);
- } else {
- const newStatus = await masto.v1.statuses.favourite(id);
- saveStatus(newStatus, instance);
- }
- } catch (e) {
- console.error(e);
- // Revert optimistism
- states.statuses[sKey] = status;
- }
- }}
+ onClick={favouriteStatus}
/>
@@ -637,61 +851,33 @@ function Status({
alt={['Bookmark', 'Bookmarked']}
class="bookmark-button"
icon="bookmark"
- onClick={async () => {
- if (!sameInstance || !authenticated) {
- return alert(unauthInteractionErrorMessage);
- }
- try {
- // Optimistic
- states.statuses[sKey] = {
- ...status,
- bookmarked: !bookmarked,
- };
- if (bookmarked) {
- const newStatus = await masto.v1.statuses.unbookmark(
- id,
- );
- saveStatus(newStatus, instance);
- } else {
- const newStatus = await masto.v1.statuses.bookmark(id);
- saveStatus(newStatus, instance);
- }
- } catch (e) {
- console.error(e);
- // Revert optimistism
- states.statuses[sKey] = status;
- }
- }}
+ onClick={bookmarkStatus}
/>
- {isSelf && (
-
- )}
+
+
+
+ }
+ >
+ {StatusMenuItems}
+
>
)}
diff --git a/src/index.css b/src/index.css
index 479d565e..4910509a 100644
--- a/src/index.css
+++ b/src/index.css
@@ -297,6 +297,9 @@ code {
.insignificant {
color: var(--text-insignificant-color);
}
+.more-insignificant {
+ opacity: 0.5;
+}
.hide-until-focus-visible {
display: none;
diff --git a/src/pages/hashtag.jsx b/src/pages/hashtag.jsx
index 67de91aa..6219c0c3 100644
--- a/src/pages/hashtag.jsx
+++ b/src/pages/hashtag.jsx
@@ -7,11 +7,11 @@ import {
} from '@szhsin/react-menu';
import { useEffect, useRef, useState } from 'preact/hooks';
import { useNavigate, useParams } from 'react-router-dom';
-import Toastify from 'toastify-js';
import Icon from '../components/icon';
import Timeline from '../components/timeline';
import { api } from '../utils/api';
+import showToast from '../utils/show-toast';
import states from '../utils/states';
import useTitle from '../utils/useTitle';
@@ -142,14 +142,7 @@ function Hashtags(props) {
.unfollow(hashtag)
.then(() => {
setInfo({ ...info, following: false });
- const toast = Toastify({
- className: 'shiny-pill',
- text: `Unfollowed #${hashtag}`,
- duration: 3000,
- gravity: 'bottom',
- position: 'center',
- });
- toast.showToast();
+ showToast(`Unfollowed #${hashtag}`);
})
.catch((e) => {
alert(e);
@@ -163,14 +156,7 @@ function Hashtags(props) {
.follow(hashtag)
.then(() => {
setInfo({ ...info, following: true });
- const toast = Toastify({
- className: 'shiny-pill',
- text: `Followed #${hashtag}`,
- duration: 3000,
- gravity: 'bottom',
- position: 'center',
- });
- toast.showToast();
+ showToast(`Followed #${hashtag}`);
})
.catch((e) => {
alert(e);
@@ -247,9 +233,11 @@ function Hashtags(props) {
);
}}
>
- {' '}
-
- {t}
+
+
+ #
+ {t}
+
))}
@@ -278,14 +266,7 @@ function Hashtags(props) {
alert('This shortcut already exists');
} else {
states.shortcuts.push(shortcut);
- const toast = Toastify({
- className: 'shiny-pill',
- text: `Hashtag shortcut added`,
- duration: 3000,
- gravity: 'bottom',
- position: 'center',
- });
- toast.showToast();
+ showToast(`Hashtag shortcut added`);
}
}}
>
diff --git a/src/utils/show-toast.js b/src/utils/show-toast.js
new file mode 100644
index 00000000..8cb02521
--- /dev/null
+++ b/src/utils/show-toast.js
@@ -0,0 +1,26 @@
+import Toastify from 'toastify-js';
+
+function showToast(props) {
+ if (typeof props === 'string') {
+ props = { text: props };
+ }
+ const { onClick = () => {}, delay, ...rest } = props;
+ const toast = Toastify({
+ className: 'shiny-pill',
+ gravity: 'bottom',
+ position: 'center',
+ ...rest,
+ onClick: () => {
+ onClick(toast); // Pass in the object itself!
+ },
+ });
+ if (delay) {
+ setTimeout(() => {
+ toast.showToast();
+ }, delay);
+ } else {
+ toast.showToast();
+ }
+}
+
+export default showToast;