diff --git a/apps/web/src/components/Composer/Actions/Attachment.tsx b/apps/web/src/components/Composer/Actions/Attachment.tsx index 6126ca17371..726ccec77b0 100644 --- a/apps/web/src/components/Composer/Actions/Attachment.tsx +++ b/apps/web/src/components/Composer/Actions/Attachment.tsx @@ -94,8 +94,8 @@ const Attachment: FC = () => { void; + isLoading: boolean; } -const Mirror: FC = ({ publication, showCount }) => { +const Mirror: FC = ({ publication, setIsLoading, isLoading }) => { const isMirror = publication.__typename === 'Mirror'; const userSigNonce = useNonceStore((state) => state.userSigNonce); const setUserSigNonce = useNonceStore((state) => state.setUserSigNonce); const currentProfile = useAppStore((state) => state.currentProfile); - const [isLoading, setIsLoading] = useState(false); - const count = isMirror - ? publication?.mirrorOf?.stats?.totalAmountOfMirrors - : publication?.stats?.totalAmountOfMirrors; const [mirrored, setMirrored] = useState( isMirror ? publication?.mirrorOf?.mirrors?.length > 0 @@ -62,6 +54,7 @@ const Mirror: FC = ({ publication, showCount }) => { cache.modify({ id: publicationKeyFields(isMirror ? publication?.mirrorOf : publication), fields: { + mirrors: (mirrors) => [...mirrors, currentProfile?.id], stats: (stats) => ({ ...stats, totalAmountOfMirrors: stats.totalAmountOfMirrors + 1 @@ -210,46 +203,24 @@ const Mirror: FC = ({ publication, showCount }) => { } }; - const iconClassName = showCount - ? 'w-[17px] sm:w-[20px]' - : 'w-[15px] sm:w-[18px]'; - return ( -
+ clsx( + { 'dropdown-active': active }, + mirrored ? 'text-green-500' : 'text-brand', + 'm-2 block cursor-pointer rounded-lg px-4 py-1.5 text-sm' + ) + } + onClick={createMirror} + disabled={isLoading} > - -
- {isLoading ? ( - - ) : ( - 0 ? t`${humanize(count)} Mirrors` : t`Mirror`} - withDelay - > - - - )} -
-
- {count > 0 && !showCount && ( - {nFormatter(count)} - )} -
+
+ +
{mirrored ? Unmirror : Mirror}
+
+
); }; diff --git a/apps/web/src/components/Publication/Actions/Share/index.tsx b/apps/web/src/components/Publication/Actions/Share/index.tsx new file mode 100644 index 00000000000..577755d7e87 --- /dev/null +++ b/apps/web/src/components/Publication/Actions/Share/index.tsx @@ -0,0 +1,85 @@ +import MenuTransition from '@components/Shared/MenuTransition'; +import { Menu } from '@headlessui/react'; +import { SwitchHorizontalIcon } from '@heroicons/react/outline'; +import type { Publication } from '@lenster/lens'; +import humanize from '@lenster/lib/humanize'; +import nFormatter from '@lenster/lib/nFormatter'; +import stopEventPropagation from '@lenster/lib/stopEventPropagation'; +import { Spinner, Tooltip } from '@lenster/ui'; +import { t } from '@lingui/macro'; +import clsx from 'clsx'; +import type { FC } from 'react'; +import { Fragment, useState } from 'react'; + +import Mirror from './Mirror'; + +interface PublicationMenuProps { + publication: Publication; + showCount: boolean; +} + +const ShareMenu: FC = ({ publication, showCount }) => { + const [isLoading, setIsLoading] = useState(false); + + const isMirror = publication.__typename === 'Mirror'; + const count = isMirror + ? publication?.mirrorOf?.stats?.totalAmountOfMirrors + : publication?.stats?.totalAmountOfMirrors; + const mirrored = isMirror + ? publication?.mirrorOf?.mirrors?.length > 0 + : // @ts-expect-error + publication?.mirrors?.length > 0; + const iconClassName = 'w-[15px] sm:w-[18px]'; + + return ( +
+ + + + + + + + + + + {count > 0 && !showCount && ( + {nFormatter(count)} + )} +
+ ); +}; + +export default ShareMenu; diff --git a/apps/web/src/components/Publication/Actions/index.tsx b/apps/web/src/components/Publication/Actions/index.tsx index ad79211ece3..fdf2b99a611 100644 --- a/apps/web/src/components/Publication/Actions/index.tsx +++ b/apps/web/src/components/Publication/Actions/index.tsx @@ -7,8 +7,8 @@ import { useAppStore } from 'src/store/app'; import Collect from './Collect'; import Comment from './Comment'; import Like from './Like'; -import Mirror from './Mirror'; import Mod from './Mod'; +import ShareMenu from './Share'; interface PublicationActionsProps { publication: Publication; @@ -33,7 +33,9 @@ const PublicationActions: FC = ({ aria-hidden="true" > - {canMirror && } + {canMirror && ( + + )} {collectModuleType !== 'RevertCollectModuleSettings' && ( = ({ publication, - showMore = false + showMore = false, + nestedEmbeds = true }) => { const canShowMore = publication?.metadata?.content?.length > 450 && showMore; const urls = getURLs(publication?.metadata?.content); @@ -49,7 +51,7 @@ const PublicationBody: FC = ({ const showAttachments = publication?.metadata?.media?.length > 0; const showSnapshot = snapshotProposalId; - const showPublicationEmbed = renderPublications.length > 0; + const showPublicationEmbed = renderPublications.length > 0 && nestedEmbeds; const showOembed = hasURLs && !showAttachments && !showSnapshot && !showPublicationEmbed; @@ -79,7 +81,7 @@ const PublicationBody: FC = ({ /> ) : null} {showPublicationEmbed ? ( - + ) : null} {showSnapshot ? : null} {showOembed ? : null} diff --git a/apps/web/src/components/Publication/QuotedPublication.tsx b/apps/web/src/components/Publication/QuotedPublication.tsx new file mode 100644 index 00000000000..f7b5c1351be --- /dev/null +++ b/apps/web/src/components/Publication/QuotedPublication.tsx @@ -0,0 +1,35 @@ +import PublicationWrapper from '@components/Shared/PublicationWrapper'; +import type { Publication } from '@lenster/lens'; +import type { FC } from 'react'; + +import HiddenPublication from './HiddenPublication'; +import PublicationBody from './PublicationBody'; +import PublicationHeader from './PublicationHeader'; + +interface QuotedPublicationProps { + publication: Publication; +} + +const QuotedPublication: FC = ({ publication }) => { + return ( + + +
+ {publication?.hidden ? ( + + ) : ( + + )} +
+
+ ); +}; + +export default QuotedPublication; diff --git a/apps/web/src/components/Publication/SinglePublication.tsx b/apps/web/src/components/Publication/SinglePublication.tsx index bd896df5025..5654477bba6 100644 --- a/apps/web/src/components/Publication/SinglePublication.tsx +++ b/apps/web/src/components/Publication/SinglePublication.tsx @@ -1,6 +1,6 @@ import ActionType from '@components/Home/Timeline/EventType'; +import PublicationWrapper from '@components/Shared/PublicationWrapper'; import type { ElectedMirror, FeedItem, Publication } from '@lenster/lens'; -import { useRouter } from 'next/router'; import type { FC } from 'react'; import PublicationActions from './Actions'; @@ -29,7 +29,6 @@ const SinglePublication: FC = ({ showThread = true, showMore = true }) => { - const { push } = useRouter(); const firstComment = feedItem?.comments && feedItem.comments[0]; const rootPublication = feedItem ? firstComment @@ -38,16 +37,9 @@ const SinglePublication: FC = ({ : publication; return ( -
{ - const selection = window.getSelection(); - if (!selection || selection.toString().length === 0) { - push(`/posts/${rootPublication?.id}`); - } - }} - data-testid={`publication-${publication.id}`} - aria-hidden="true" + publication={publication} > {feedItem ? ( @@ -83,7 +75,7 @@ const SinglePublication: FC = ({ )} -
+ ); }; diff --git a/apps/web/src/components/Publication/ThreadBody.tsx b/apps/web/src/components/Publication/ThreadBody.tsx index d969a2a158f..3a4f9322cf0 100644 --- a/apps/web/src/components/Publication/ThreadBody.tsx +++ b/apps/web/src/components/Publication/ThreadBody.tsx @@ -1,5 +1,5 @@ +import PublicationWrapper from '@components/Shared/PublicationWrapper'; import type { Publication } from '@lenster/lens'; -import { useRouter } from 'next/router'; import type { FC } from 'react'; import PublicationActions from './Actions'; @@ -12,18 +12,8 @@ interface ThreadBodyProps { } const ThreadBody: FC = ({ publication }) => { - const { push } = useRouter(); - return ( -
{ - const selection = window.getSelection(); - if (!selection || selection.toString().length === 0) { - push(`/posts/${publication?.id}`); - } - }} - aria-hidden="true" - > +
@@ -38,7 +28,7 @@ const ThreadBody: FC = ({ publication }) => { )}
-
+ ); }; diff --git a/apps/web/src/components/Shared/Embed/Publication.tsx b/apps/web/src/components/Shared/Embed/Quote.tsx similarity index 58% rename from apps/web/src/components/Shared/Embed/Publication.tsx rename to apps/web/src/components/Shared/Embed/Quote.tsx index 6b083bfc8c7..aa8fc0100f1 100644 --- a/apps/web/src/components/Shared/Embed/Publication.tsx +++ b/apps/web/src/components/Shared/Embed/Quote.tsx @@ -1,5 +1,6 @@ -import SinglePublication from '@components/Publication/SinglePublication'; -import { Publication, usePublicationQuery } from '@lenster/lens'; +import QuotedPublication from '@components/Publication/QuotedPublication'; +import type { Publication } from '@lenster/lens'; +import { usePublicationQuery } from '@lenster/lens'; import type { FC } from 'react'; import PublicationShimmer from '../Shimmer/PublicationShimmer'; @@ -9,7 +10,7 @@ interface PublicationProps { publicationIds: string[]; } -const Publication: FC = ({ publicationIds }) => { +const Quote: FC = ({ publicationIds }) => { const { data, loading, error } = usePublicationQuery({ variables: { request: { publicationId: publicationIds[0] } } }); @@ -28,15 +29,9 @@ const Publication: FC = ({ publicationIds }) => { return ( - + ); }; -export default Publication; +export default Quote; diff --git a/apps/web/src/components/Shared/PublicationWrapper.tsx b/apps/web/src/components/Shared/PublicationWrapper.tsx new file mode 100644 index 00000000000..e690f5d3fce --- /dev/null +++ b/apps/web/src/components/Shared/PublicationWrapper.tsx @@ -0,0 +1,36 @@ +import type { Publication } from '@lenster/lens'; +import clsx from 'clsx'; +import { useRouter } from 'next/router'; +import type { FC, ReactNode } from 'react'; + +interface PublicationWrapperProps { + publication: Publication; + className?: string; + children: ReactNode[]; +} + +const PublicationWrapper: FC = ({ + publication, + className = '', + children +}) => { + const { push } = useRouter(); + + return ( +
{ + const selection = window.getSelection(); + if (!selection || selection.toString().length === 0) { + push(`/posts/${publication?.id}`); + } + }} + data-testid={`publication-${publication.id}`} + aria-hidden="true" + > + {children} +
+ ); +}; + +export default PublicationWrapper; diff --git a/apps/web/src/locales/en/messages.po b/apps/web/src/locales/en/messages.po index be79fd2c7ea..3165277c220 100644 --- a/apps/web/src/locales/en/messages.po +++ b/apps/web/src/locales/en/messages.po @@ -313,7 +313,7 @@ msgid "What's happening?" msgstr "" #: src/components/Composer/NewPublication.tsx -#: src/components/Publication/Actions/Mirror.tsx +#: src/components/Publication/Actions/Share/Mirror.tsx msgid "Momoka is currently in beta - during this time certain actions are not available to all profiles." msgstr "Momoka is currently in beta - during this time certain actions are not available to all profiles." @@ -1547,18 +1547,6 @@ msgstr "" msgid "Translate" msgstr "" -#: src/components/Publication/Actions/Mirror.tsx -msgid "Post has been mirrored!" -msgstr "Post has been mirrored!" - -#: src/components/Publication/Actions/Mirror.tsx -msgid "{0} Mirrors" -msgstr "" - -#: src/components/Publication/Actions/Mirror.tsx -msgid "Mirror" -msgstr "" - #: src/components/Publication/Actions/Mod.tsx #: src/components/Shared/GlobalAlerts.tsx msgid "Mod actions" @@ -1576,6 +1564,23 @@ msgstr "Poor content" msgid "Stop Sponsor" msgstr "Stop Sponsor" +#: src/components/Publication/Actions/Share/Mirror.tsx +msgid "Post has been mirrored!" +msgstr "Post has been mirrored!" + +#: src/components/Publication/Actions/Share/Mirror.tsx +msgid "Unmirror" +msgstr "Unmirror" + +#: src/components/Publication/Actions/Share/Mirror.tsx +#: src/components/Publication/Actions/Share/index.tsx +msgid "Mirror" +msgstr "" + +#: src/components/Publication/Actions/Share/index.tsx +msgid "{0} Mirrors" +msgstr "" + #: src/components/Publication/DecryptedPublicationBody.tsx msgid "To view this..." msgstr "" @@ -2741,8 +2746,8 @@ msgid "Unfollow" msgstr "" #: src/components/Shared/Uniswap.tsx -msgid "You don't have enough <0>{0}" -msgstr "" +msgid "You don't have enough <0>{currency}" +msgstr "You don't have enough <0>{currency}" #: src/components/Shared/Uniswap.tsx msgid "Swap in Uniswap" diff --git a/apps/web/src/locales/fr/messages.po b/apps/web/src/locales/fr/messages.po index 937627669d8..76368843554 100644 --- a/apps/web/src/locales/fr/messages.po +++ b/apps/web/src/locales/fr/messages.po @@ -313,7 +313,7 @@ msgid "What's happening?" msgstr "" #: src/components/Composer/NewPublication.tsx -#: src/components/Publication/Actions/Mirror.tsx +#: src/components/Publication/Actions/Share/Mirror.tsx msgid "Momoka is currently in beta - during this time certain actions are not available to all profiles." msgstr "" @@ -1547,18 +1547,6 @@ msgstr "" msgid "Translate" msgstr "" -#: src/components/Publication/Actions/Mirror.tsx -msgid "Post has been mirrored!" -msgstr "" - -#: src/components/Publication/Actions/Mirror.tsx -msgid "{0} Mirrors" -msgstr "" - -#: src/components/Publication/Actions/Mirror.tsx -msgid "Mirror" -msgstr "" - #: src/components/Publication/Actions/Mod.tsx #: src/components/Shared/GlobalAlerts.tsx msgid "Mod actions" @@ -1576,6 +1564,23 @@ msgstr "" msgid "Stop Sponsor" msgstr "" +#: src/components/Publication/Actions/Share/Mirror.tsx +msgid "Post has been mirrored!" +msgstr "" + +#: src/components/Publication/Actions/Share/Mirror.tsx +msgid "Unmirror" +msgstr "" + +#: src/components/Publication/Actions/Share/Mirror.tsx +#: src/components/Publication/Actions/Share/index.tsx +msgid "Mirror" +msgstr "" + +#: src/components/Publication/Actions/Share/index.tsx +msgid "{0} Mirrors" +msgstr "" + #: src/components/Publication/DecryptedPublicationBody.tsx msgid "To view this..." msgstr "" @@ -2741,7 +2746,7 @@ msgid "Unfollow" msgstr "" #: src/components/Shared/Uniswap.tsx -msgid "You don't have enough <0>{0}" +msgid "You don't have enough <0>{currency}" msgstr "" #: src/components/Shared/Uniswap.tsx @@ -2903,4 +2908,3 @@ msgstr "" #: src/pages/500.tsx msgid "We track these errors automatically, but if the problem persists feel free to contact us. In the meantime, try refreshing." msgstr "" - diff --git a/apps/web/src/locales/ru/messages.po b/apps/web/src/locales/ru/messages.po index e0956c0baa2..8905a761f0f 100644 --- a/apps/web/src/locales/ru/messages.po +++ b/apps/web/src/locales/ru/messages.po @@ -313,7 +313,7 @@ msgid "What's happening?" msgstr "Что происходит?" #: src/components/Composer/NewPublication.tsx -#: src/components/Publication/Actions/Mirror.tsx +#: src/components/Publication/Actions/Share/Mirror.tsx msgid "Momoka is currently in beta - during this time certain actions are not available to all profiles." msgstr "" @@ -1547,18 +1547,6 @@ msgstr "Скопировано в буфер обмена!" msgid "Translate" msgstr "Перевести" -#: src/components/Publication/Actions/Mirror.tsx -msgid "Post has been mirrored!" -msgstr "" - -#: src/components/Publication/Actions/Mirror.tsx -msgid "{0} Mirrors" -msgstr "" - -#: src/components/Publication/Actions/Mirror.tsx -msgid "Mirror" -msgstr "" - #: src/components/Publication/Actions/Mod.tsx #: src/components/Shared/GlobalAlerts.tsx msgid "Mod actions" @@ -1576,6 +1564,23 @@ msgstr "Некачественный контент" msgid "Stop Sponsor" msgstr "Прекратить спонсорство" +#: src/components/Publication/Actions/Share/Mirror.tsx +msgid "Post has been mirrored!" +msgstr "" + +#: src/components/Publication/Actions/Share/Mirror.tsx +msgid "Unmirror" +msgstr "" + +#: src/components/Publication/Actions/Share/Mirror.tsx +#: src/components/Publication/Actions/Share/index.tsx +msgid "Mirror" +msgstr "" + +#: src/components/Publication/Actions/Share/index.tsx +msgid "{0} Mirrors" +msgstr "" + #: src/components/Publication/DecryptedPublicationBody.tsx msgid "To view this..." msgstr "Чтобы просмотреть это..." @@ -2741,8 +2746,8 @@ msgid "Unfollow" msgstr "Отписаться" #: src/components/Shared/Uniswap.tsx -msgid "You don't have enough <0>{0}" -msgstr "Вам не хватает <0>{0}" +msgid "You don't have enough <0>{currency}" +msgstr "" #: src/components/Shared/Uniswap.tsx msgid "Swap in Uniswap" @@ -2903,4 +2908,3 @@ msgstr "Похоже, что-то пошло не так!" #: src/pages/500.tsx msgid "We track these errors automatically, but if the problem persists feel free to contact us. In the meantime, try refreshing." msgstr "Мы автоматически отслеживаем эти ошибки, но если проблема не устранена, не стесняйтесь обращаться к нам. А пока попробуйте обновить страницу." - diff --git a/apps/web/src/locales/ta/messages.po b/apps/web/src/locales/ta/messages.po index 8581e0fa815..3c5d9e1eabf 100644 --- a/apps/web/src/locales/ta/messages.po +++ b/apps/web/src/locales/ta/messages.po @@ -313,7 +313,7 @@ msgid "What's happening?" msgstr "என்ன நடக்கிறது?" #: src/components/Composer/NewPublication.tsx -#: src/components/Publication/Actions/Mirror.tsx +#: src/components/Publication/Actions/Share/Mirror.tsx msgid "Momoka is currently in beta - during this time certain actions are not available to all profiles." msgstr "" @@ -1547,18 +1547,6 @@ msgstr "கிளிப்போர்டுக்கு நகலெடுக msgid "Translate" msgstr "மொழிபெயர்" -#: src/components/Publication/Actions/Mirror.tsx -msgid "Post has been mirrored!" -msgstr "இடுகை மிரர் செய்யப்பட்டது!" - -#: src/components/Publication/Actions/Mirror.tsx -msgid "{0} Mirrors" -msgstr "{0} மிரர்கள்" - -#: src/components/Publication/Actions/Mirror.tsx -msgid "Mirror" -msgstr "மிரர்" - #: src/components/Publication/Actions/Mod.tsx #: src/components/Shared/GlobalAlerts.tsx msgid "Mod actions" @@ -1576,6 +1564,23 @@ msgstr "" msgid "Stop Sponsor" msgstr "ஸ்பான்சரை நிறுத்து" +#: src/components/Publication/Actions/Share/Mirror.tsx +msgid "Post has been mirrored!" +msgstr "இடுகை மிரர் செய்யப்பட்டது!" + +#: src/components/Publication/Actions/Share/Mirror.tsx +msgid "Unmirror" +msgstr "" + +#: src/components/Publication/Actions/Share/Mirror.tsx +#: src/components/Publication/Actions/Share/index.tsx +msgid "Mirror" +msgstr "மிரர்" + +#: src/components/Publication/Actions/Share/index.tsx +msgid "{0} Mirrors" +msgstr "{0} மிரர்கள்" + #: src/components/Publication/DecryptedPublicationBody.tsx msgid "To view this..." msgstr "இதைக் காண..." @@ -2741,8 +2746,8 @@ msgid "Unfollow" msgstr "பின்தொடராதே" #: src/components/Shared/Uniswap.tsx -msgid "You don't have enough <0>{0}" -msgstr "உங்களிடம் போதுமான <0>{0} இல்லை" +msgid "You don't have enough <0>{currency}" +msgstr "" #: src/components/Shared/Uniswap.tsx msgid "Swap in Uniswap" @@ -2903,4 +2908,3 @@ msgstr "ஏதோ தவறாகிவிட்டது போல் தெர #: src/pages/500.tsx msgid "We track these errors automatically, but if the problem persists feel free to contact us. In the meantime, try refreshing." msgstr "இந்தப் பிழைகளைத் தானாகக் கண்காணிக்கிறோம், ஆனால் சிக்கல் தொடர்ந்தால், எங்களைத் தொடர்பு கொள்ளலாம். இதற்கிடையில், புதுப்பித்து முயற்சிக்கவும்." - diff --git a/apps/web/src/locales/zh/messages.po b/apps/web/src/locales/zh/messages.po index 88417cad771..ba0318f7aa1 100644 --- a/apps/web/src/locales/zh/messages.po +++ b/apps/web/src/locales/zh/messages.po @@ -313,7 +313,7 @@ msgid "What's happening?" msgstr "正在发生什么?" #: src/components/Composer/NewPublication.tsx -#: src/components/Publication/Actions/Mirror.tsx +#: src/components/Publication/Actions/Share/Mirror.tsx msgid "Momoka is currently in beta - during this time certain actions are not available to all profiles." msgstr "" @@ -1547,18 +1547,6 @@ msgstr "已复制到剪贴板!" msgid "Translate" msgstr "翻译" -#: src/components/Publication/Actions/Mirror.tsx -msgid "Post has been mirrored!" -msgstr "帖子已被转发!" - -#: src/components/Publication/Actions/Mirror.tsx -msgid "{0} Mirrors" -msgstr "{0} 次转发" - -#: src/components/Publication/Actions/Mirror.tsx -msgid "Mirror" -msgstr "转发" - #: src/components/Publication/Actions/Mod.tsx #: src/components/Shared/GlobalAlerts.tsx msgid "Mod actions" @@ -1576,6 +1564,23 @@ msgstr "" msgid "Stop Sponsor" msgstr "" +#: src/components/Publication/Actions/Share/Mirror.tsx +msgid "Post has been mirrored!" +msgstr "帖子已被转发!" + +#: src/components/Publication/Actions/Share/Mirror.tsx +msgid "Unmirror" +msgstr "" + +#: src/components/Publication/Actions/Share/Mirror.tsx +#: src/components/Publication/Actions/Share/index.tsx +msgid "Mirror" +msgstr "转发" + +#: src/components/Publication/Actions/Share/index.tsx +msgid "{0} Mirrors" +msgstr "{0} 次转发" + #: src/components/Publication/DecryptedPublicationBody.tsx msgid "To view this..." msgstr "要查看此..." @@ -2741,8 +2746,8 @@ msgid "Unfollow" msgstr "取消关注" #: src/components/Shared/Uniswap.tsx -msgid "You don't have enough <0>{0}" -msgstr "您没有足够的 <0>{0}" +msgid "You don't have enough <0>{currency}" +msgstr "" #: src/components/Shared/Uniswap.tsx msgid "Swap in Uniswap" @@ -2903,4 +2908,3 @@ msgstr "系统似乎出现了故障!" #: src/pages/500.tsx msgid "We track these errors automatically, but if the problem persists feel free to contact us. In the meantime, try refreshing." msgstr "我们会自动追踪这些错误,但如果问题仍然存在,请随时与我们联系。 与此同时,您可以尝试刷新页面。" -