add share button to posts for pleb.bz link

This commit is contained in:
plebeius.eth
2023-08-22 14:17:38 +02:00
parent a05e733d30
commit c4361ce78b
10 changed files with 108 additions and 18 deletions
+9 -2
View File
@@ -34,6 +34,7 @@ import handleAddressClick from '../../utils/handleAddressClick';
import handleImageClick from '../../utils/handleImageClick'; import handleImageClick from '../../utils/handleImageClick';
import handleQuoteClick from '../../utils/handleQuoteClick'; import handleQuoteClick from '../../utils/handleQuoteClick';
import handleQuoteHover from '../../utils/handleQuoteHover'; import handleQuoteHover from '../../utils/handleQuoteHover';
import handleShareClick from '../../utils/handleShareClick';
import handleStyleChange from '../../utils/handleStyleChange'; import handleStyleChange from '../../utils/handleStyleChange';
import removeHighlight from '../../utils/removeHighlight'; import removeHighlight from '../../utils/removeHighlight';
import useAnonModeRef from '../../hooks/useAnonModeRef'; import useAnonModeRef from '../../hooks/useAnonModeRef';
@@ -926,7 +927,10 @@ const All = () => {
style={{ display: openMenuCid === thread.cid ? 'block' : 'none' }} style={{ display: openMenuCid === thread.cid ? 'block' : 'none' }}
> >
<ul className="post-menu-catalog"> <ul className="post-menu-catalog">
<li onClick={() => handleOptionClick(thread.cid)}>Hide thread</li> <li onClick={() => {
handleOptionClick(thread.cid);
handleShareClick(selectedAddress, thread.cid);
}}>Share thread</li>
<VerifiedAuthor commentCid={thread.cid}>{({ authorAddress }) => ( <VerifiedAuthor commentCid={thread.cid}>{({ authorAddress }) => (
<> <>
{authorAddress === account?.author.address || {authorAddress === account?.author.address ||
@@ -1258,7 +1262,10 @@ const All = () => {
style={{ display: openMenuCid === reply.cid ? 'block' : 'none' }} style={{ display: openMenuCid === reply.cid ? 'block' : 'none' }}
> >
<ul className="post-menu-catalog"> <ul className="post-menu-catalog">
<li onClick={() => handleOptionClick(reply.cid)}>Hide post</li> <li onClick={() => {
handleOptionClick(reply.cid);
handleShareClick(selectedAddress, thread.cid);
}}>Share thread</li>
<VerifiedAuthor commentCid={reply.cid}>{({ authorAddress }) => ( <VerifiedAuthor commentCid={reply.cid}>{({ authorAddress }) => (
<> <>
{authorAddress === account?.author.address || {authorAddress === account?.author.address ||
+5 -1
View File
@@ -21,6 +21,7 @@ import OfflineIndicator from '../OfflineIndicator';
import SettingsModal from '../modals/SettingsModal'; import SettingsModal from '../modals/SettingsModal';
import countLinks from '../../utils/countLinks'; import countLinks from '../../utils/countLinks';
import getCommentMediaInfo from '../../utils/getCommentMediaInfo'; import getCommentMediaInfo from '../../utils/getCommentMediaInfo';
import handleShareClick from '../../utils/handleShareClick';
import handleStyleChange from '../../utils/handleStyleChange'; import handleStyleChange from '../../utils/handleStyleChange';
import useError from '../../hooks/useError'; import useError from '../../hooks/useError';
import useFeedRows from '../../hooks/useFeedRows'; import useFeedRows from '../../hooks/useFeedRows';
@@ -383,7 +384,10 @@ const CatalogPost = ({post}) => {
style={{ display: openMenuCid === thread.cid ? 'block' : 'none' }} style={{ display: openMenuCid === thread.cid ? 'block' : 'none' }}
> >
<ul className="post-menu-catalog"> <ul className="post-menu-catalog">
<li onClick={() => handleOptionClick(thread.cid)}>Hide thread</li> <li onClick={() => {
handleOptionClick(thread.cid);
handleShareClick(selectedAddress, thread.cid);
}}>Share thread</li>
<VerifiedAuthor commentCid={thread.cid}>{({ authorAddress }) => ( <VerifiedAuthor commentCid={thread.cid}>{({ authorAddress }) => (
<> <>
{authorAddress === account?.author.address || {authorAddress === account?.author.address ||
+23 -5
View File
@@ -36,6 +36,7 @@ import handleAddressClick from '../../utils/handleAddressClick';
import handleImageClick from '../../utils/handleImageClick'; import handleImageClick from '../../utils/handleImageClick';
import handleQuoteClick from '../../utils/handleQuoteClick'; import handleQuoteClick from '../../utils/handleQuoteClick';
import handleQuoteHover from '../../utils/handleQuoteHover'; import handleQuoteHover from '../../utils/handleQuoteHover';
import handleShareClick from '../../utils/handleShareClick';
import handleStyleChange from '../../utils/handleStyleChange'; import handleStyleChange from '../../utils/handleStyleChange';
import removeHighlight from '../../utils/removeHighlight'; import removeHighlight from '../../utils/removeHighlight';
import useAnonModeRef from '../../hooks/useAnonModeRef'; import useAnonModeRef from '../../hooks/useAnonModeRef';
@@ -1000,7 +1001,12 @@ const Board = () => {
style={{ display: openMenuCid === "rules" ? 'block' : 'none' }} style={{ display: openMenuCid === "rules" ? 'block' : 'none' }}
> >
<ul className="post-menu-catalog"> <ul className="post-menu-catalog">
<li onClick={() => handleOptionClick("rules")}>Hide thread</li> <li onClick={() => {
handleOptionClick("rules");
handleShareClick(selectedAddress, "rules");
}}>
Share thread
</li>
{/* {isModerator ? ( {/* {isModerator ? (
<> <>
change rules change rules
@@ -1131,7 +1137,10 @@ const Board = () => {
style={{ display: openMenuCid === "rules" ? 'block' : 'none' }} style={{ display: openMenuCid === "rules" ? 'block' : 'none' }}
> >
<ul className="post-menu-catalog"> <ul className="post-menu-catalog">
<li onClick={() => handleOptionClick("rules")}>Hide thread</li> <li onClick={() => {
handleOptionClick("rules");
handleShareClick(selectedAddress, "rules");
}}>Share thread</li>
{/* {isModerator ? ( {/* {isModerator ? (
<> <>
change rules change rules
@@ -1284,7 +1293,10 @@ const Board = () => {
style={{ display: openMenuCid === subplebbit.pubsubTopic ? 'block' : 'none' }} style={{ display: openMenuCid === subplebbit.pubsubTopic ? 'block' : 'none' }}
> >
<ul className="post-menu-catalog"> <ul className="post-menu-catalog">
<li onClick={() => handleOptionClick(subplebbit.pubsubTopic)}>Hide thread</li> <li onClick={() => {
handleOptionClick("description");
handleShareClick(selectedAddress, "description");
}}>Share thread</li>
{/* {isModerator ? ( {/* {isModerator ? (
<> <>
change description change description
@@ -1615,7 +1627,10 @@ const Board = () => {
style={{ display: openMenuCid === thread.cid ? 'block' : 'none' }} style={{ display: openMenuCid === thread.cid ? 'block' : 'none' }}
> >
<ul className="post-menu-catalog"> <ul className="post-menu-catalog">
<li onClick={() => handleOptionClick(thread.cid)}>Hide thread</li> <li onClick={() => {
handleOptionClick(thread.cid);
handleShareClick(selectedAddress, thread.cid);
}}>Share thread</li>
<VerifiedAuthor commentCid={thread.cid}>{({ authorAddress }) => ( <VerifiedAuthor commentCid={thread.cid}>{({ authorAddress }) => (
<> <>
{authorAddress === account?.author.address || {authorAddress === account?.author.address ||
@@ -1941,7 +1956,10 @@ const Board = () => {
style={{ display: openMenuCid === reply.cid ? 'block' : 'none' }} style={{ display: openMenuCid === reply.cid ? 'block' : 'none' }}
> >
<ul className="post-menu-catalog"> <ul className="post-menu-catalog">
<li onClick={() => handleOptionClick(reply.cid)}>Hide post</li> <li onClick={() => {
handleOptionClick(reply.cid);
handleShareClick(selectedAddress, thread.cid);
}}>Share thread</li>
<VerifiedAuthor commentCid={reply.cid}>{({ authorAddress }) => ( <VerifiedAuthor commentCid={reply.cid}>{({ authorAddress }) => (
<> <>
{authorAddress === account?.author.address || {authorAddress === account?.author.address ||
+13 -3
View File
@@ -22,6 +22,7 @@ import OfflineIndicator from '../OfflineIndicator';
import SettingsModal from '../modals/SettingsModal'; import SettingsModal from '../modals/SettingsModal';
import countLinks from '../../utils/countLinks'; import countLinks from '../../utils/countLinks';
import getCommentMediaInfo from '../../utils/getCommentMediaInfo'; import getCommentMediaInfo from '../../utils/getCommentMediaInfo';
import handleShareClick from '../../utils/handleShareClick';
import handleStyleChange from '../../utils/handleStyleChange'; import handleStyleChange from '../../utils/handleStyleChange';
import useAnonModeRef from '../../hooks/useAnonModeRef'; import useAnonModeRef from '../../hooks/useAnonModeRef';
import useClickForm from '../../hooks/useClickForm'; import useClickForm from '../../hooks/useClickForm';
@@ -317,7 +318,10 @@ const CatalogPost = ({post}) => {
style={{ display: openMenuCid === "rules" ? 'block' : 'none' }} style={{ display: openMenuCid === "rules" ? 'block' : 'none' }}
> >
<ul className="post-menu-catalog"> <ul className="post-menu-catalog">
<li onClick={() => handleOptionClick("rules")}>Hide thread</li> <li onClick={() => {
handleOptionClick("rules");
handleShareClick(selectedAddress, "rules");
}}>Share thread</li>
{/* {isModerator ? ( {/* {isModerator ? (
<> <>
change rules change rules
@@ -405,7 +409,10 @@ const CatalogPost = ({post}) => {
style={{ display: openMenuCid === "description" ? 'block' : 'none' }} style={{ display: openMenuCid === "description" ? 'block' : 'none' }}
> >
<ul className="post-menu-catalog"> <ul className="post-menu-catalog">
<li onClick={() => handleOptionClick("description")}>Hide thread</li> <li onClick={() => {
handleOptionClick("description");
handleShareClick(selectedAddress, "description");
}}>Share thread</li>
{/* {isModerator ? ( {/* {isModerator ? (
<> <>
change description change description
@@ -581,7 +588,10 @@ const CatalogPost = ({post}) => {
style={{ display: openMenuCid === thread.cid ? 'block' : 'none' }} style={{ display: openMenuCid === thread.cid ? 'block' : 'none' }}
> >
<ul className="post-menu-catalog"> <ul className="post-menu-catalog">
<li onClick={() => handleOptionClick(thread.cid)}>Hide thread</li> <li onClick={() => {
handleOptionClick(thread.cid);
handleShareClick(selectedAddress, thread.cid);
}}>Share thread</li>
<VerifiedAuthor commentCid={thread.cid}>{({ authorAddress }) => ( <VerifiedAuthor commentCid={thread.cid}>{({ authorAddress }) => (
<> <>
{authorAddress === account?.author.address || {authorAddress === account?.author.address ||
+5 -1
View File
@@ -16,6 +16,7 @@ import OfflineIndicator from '../OfflineIndicator';
import SettingsModal from '../modals/SettingsModal'; import SettingsModal from '../modals/SettingsModal';
import getDate from '../../utils/getDate'; import getDate from '../../utils/getDate';
import handleImageClick from '../../utils/handleImageClick'; import handleImageClick from '../../utils/handleImageClick';
import handleShareClick from '../../utils/handleShareClick';
import handleStyleChange from '../../utils/handleStyleChange'; import handleStyleChange from '../../utils/handleStyleChange';
import useGeneralStore from '../../hooks/stores/useGeneralStore'; import useGeneralStore from '../../hooks/stores/useGeneralStore';
import packageJson from '../../../package.json'; import packageJson from '../../../package.json';
@@ -363,7 +364,10 @@ const Description = () => {
style={{ display: openMenuCid === subplebbit.pubsubTopic ? 'block' : 'none' }} style={{ display: openMenuCid === subplebbit.pubsubTopic ? 'block' : 'none' }}
> >
<ul className="post-menu-catalog"> <ul className="post-menu-catalog">
<li onClick={() => handleOptionClick(subplebbit.pubsubTopic)}>Hide thread</li> <li onClick={() => {
handleOptionClick("description");
handleShareClick(selectedAddress, "description");
}}>Share thread</li>
{/* {isModerator ? ( {/* {isModerator ? (
<> <>
change description change description
+5 -1
View File
@@ -14,6 +14,7 @@ import AdminListModal from '../modals/AdminListModal';
import OfflineIndicator from '../OfflineIndicator'; import OfflineIndicator from '../OfflineIndicator';
import SettingsModal from '../modals/SettingsModal'; import SettingsModal from '../modals/SettingsModal';
import getDate from '../../utils/getDate'; import getDate from '../../utils/getDate';
import handleShareClick from '../../utils/handleShareClick';
import handleStyleChange from '../../utils/handleStyleChange'; import handleStyleChange from '../../utils/handleStyleChange';
import useGeneralStore from '../../hooks/stores/useGeneralStore'; import useGeneralStore from '../../hooks/stores/useGeneralStore';
import packageJson from '../../../package.json'; import packageJson from '../../../package.json';
@@ -345,7 +346,10 @@ const Rules = () => {
style={{ display: openMenuCid === "rules" ? 'block' : 'none' }} style={{ display: openMenuCid === "rules" ? 'block' : 'none' }}
> >
<ul className="post-menu-catalog"> <ul className="post-menu-catalog">
<li onClick={() => handleOptionClick("rules")}>Hide thread</li> <li onClick={() => {
handleOptionClick("rules");
handleShareClick(selectedAddress, "rules");
}}>Share thread</li>
{/* {isModerator ? ( {/* {isModerator ? (
<> <>
change rules change rules
+9 -2
View File
@@ -35,6 +35,7 @@ import handleAddressClick from '../../utils/handleAddressClick';
import handleImageClick from '../../utils/handleImageClick'; import handleImageClick from '../../utils/handleImageClick';
import handleQuoteClick from '../../utils/handleQuoteClick'; import handleQuoteClick from '../../utils/handleQuoteClick';
import handleQuoteHover from '../../utils/handleQuoteHover'; import handleQuoteHover from '../../utils/handleQuoteHover';
import handleShareClick from '../../utils/handleShareClick';
import handleStyleChange from '../../utils/handleStyleChange'; import handleStyleChange from '../../utils/handleStyleChange';
import removeHighlight from '../../utils/removeHighlight'; import removeHighlight from '../../utils/removeHighlight';
import useAnonModeRef from '../../hooks/useAnonModeRef'; import useAnonModeRef from '../../hooks/useAnonModeRef';
@@ -937,7 +938,10 @@ const Subscriptions = () => {
style={{ display: openMenuCid === thread.cid ? 'block' : 'none' }} style={{ display: openMenuCid === thread.cid ? 'block' : 'none' }}
> >
<ul className="post-menu-catalog"> <ul className="post-menu-catalog">
<li onClick={() => handleOptionClick(thread.cid)}>Hide thread</li> <li onClick={() => {
handleOptionClick(thread.cid);
handleShareClick(selectedAddress, thread.cid);
}}>Share thread</li>
<VerifiedAuthor commentCid={thread.cid}>{({ authorAddress }) => ( <VerifiedAuthor commentCid={thread.cid}>{({ authorAddress }) => (
<> <>
{authorAddress === account?.author.address || {authorAddress === account?.author.address ||
@@ -1269,7 +1273,10 @@ const Subscriptions = () => {
style={{ display: openMenuCid === reply.cid ? 'block' : 'none' }} style={{ display: openMenuCid === reply.cid ? 'block' : 'none' }}
> >
<ul className="post-menu-catalog"> <ul className="post-menu-catalog">
<li onClick={() => handleOptionClick(reply.cid)}>Hide post</li> <li onClick={() => {
handleOptionClick(reply.cid);
handleShareClick(selectedAddress, thread.cid);
}}>Share thread</li>
<VerifiedAuthor commentCid={reply.cid}>{({ authorAddress }) => ( <VerifiedAuthor commentCid={reply.cid}>{({ authorAddress }) => (
<> <>
{authorAddress === account?.author.address || {authorAddress === account?.author.address ||
@@ -21,6 +21,7 @@ import OfflineIndicator from '../OfflineIndicator';
import SettingsModal from '../modals/SettingsModal'; import SettingsModal from '../modals/SettingsModal';
import countLinks from '../../utils/countLinks'; import countLinks from '../../utils/countLinks';
import getCommentMediaInfo from '../../utils/getCommentMediaInfo'; import getCommentMediaInfo from '../../utils/getCommentMediaInfo';
import handleShareClick from '../../utils/handleShareClick';
import handleStyleChange from '../../utils/handleStyleChange'; import handleStyleChange from '../../utils/handleStyleChange';
import useError from '../../hooks/useError'; import useError from '../../hooks/useError';
import useFeedRows from '../../hooks/useFeedRows'; import useFeedRows from '../../hooks/useFeedRows';
@@ -383,7 +384,10 @@ const CatalogPost = ({post}) => {
style={{ display: openMenuCid === thread.cid ? 'block' : 'none' }} style={{ display: openMenuCid === thread.cid ? 'block' : 'none' }}
> >
<ul className="post-menu-catalog"> <ul className="post-menu-catalog">
<li onClick={() => handleOptionClick(thread.cid)}>Hide thread</li> <li onClick={() => {
handleOptionClick(thread.cid);
handleShareClick(selectedAddress, thread.cid);
}}>Share thread</li>
<VerifiedAuthor commentCid={thread.cid}>{({ authorAddress }) => ( <VerifiedAuthor commentCid={thread.cid}>{({ authorAddress }) => (
<> <>
{authorAddress === account?.author.address || {authorAddress === account?.author.address ||
+9 -2
View File
@@ -33,6 +33,7 @@ import handleAddressClick from '../../utils/handleAddressClick';
import handleImageClick from '../../utils/handleImageClick'; import handleImageClick from '../../utils/handleImageClick';
import handleQuoteClick from '../../utils/handleQuoteClick'; import handleQuoteClick from '../../utils/handleQuoteClick';
import handleQuoteHover from '../../utils/handleQuoteHover'; import handleQuoteHover from '../../utils/handleQuoteHover';
import handleShareClick from '../../utils/handleShareClick';
import handleStyleChange from '../../utils/handleStyleChange'; import handleStyleChange from '../../utils/handleStyleChange';
import removeHighlight from '../../utils/removeHighlight'; import removeHighlight from '../../utils/removeHighlight';
import useAnonMode from '../../hooks/useAnonMode'; import useAnonMode from '../../hooks/useAnonMode';
@@ -1067,7 +1068,10 @@ const Thread = () => {
style={{ display: openMenuCid === comment.cid ? 'block' : 'none' }} style={{ display: openMenuCid === comment.cid ? 'block' : 'none' }}
> >
<ul className="post-menu-catalog"> <ul className="post-menu-catalog">
<li onClick={() => handleOptionClick(comment.cid)}>Hide thread</li> <li onClick={() => {
handleOptionClick(comment.cid);
handleShareClick(selectedAddress, comment.cid);
}}>Share thread</li>
<VerifiedAuthor commentCid={comment.cid}>{({ authorAddress }) => ( <VerifiedAuthor commentCid={comment.cid}>{({ authorAddress }) => (
<> <>
{authorAddress === account?.author.address || {authorAddress === account?.author.address ||
@@ -1360,7 +1364,10 @@ const Thread = () => {
style={{ display: openMenuCid === reply.cid ? 'block' : 'none' }} style={{ display: openMenuCid === reply.cid ? 'block' : 'none' }}
> >
<ul className="post-menu-catalog"> <ul className="post-menu-catalog">
<li onClick={() => handleOptionClick(reply.cid)}>Hide post</li> <li onClick={() => {
handleOptionClick(reply.cid);
handleShareClick(selectedAddress, comment.cid);
}}>Share thread</li>
<VerifiedAuthor commentCid={reply.cid}>{({ authorAddress }) => ( <VerifiedAuthor commentCid={reply.cid}>{({ authorAddress }) => (
<> <>
{authorAddress === account?.author.address || {authorAddress === account?.author.address ||
+25
View File
@@ -0,0 +1,25 @@
function handleShareClick(selectedAddress, cid) {
const plebBzBaseURL = "https://pleb.bz/p/";
let shareLink = `${plebBzBaseURL}${selectedAddress}/`;
if (cid === "rules" || cid === "description") {
shareLink += cid;
} else {
shareLink += `c/${cid}`;
}
shareLink += `?redirect=plebchan.eth.limo`;
if (navigator.clipboard) {
navigator.clipboard.writeText(shareLink).then(() => {
console.log("Link copied to clipboard!");
}).catch(err => {
console.error('Could not copy text: ', err);
});
} else {
return;
}
}
export default handleShareClick;