Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion packages/next-common/components/appendants/common/item.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { SystemActivity } from "@osn/icons/subsquare";
import { formatTimeAgo } from "next-common/utils/viewfuncs/formatTimeAgo";
import Tooltip from "next-common/components/tooltip";
import useIsAppendantAuthor from "../useIsAppendantAuthor";
import correctionIpfsEndpointPlugin from "next-common/utils/previewerPlugins/correctionIpfsEndpoint";

function SplitDot() {
return <span className="text-textTertiary text12Medium mx-2">·</span>;
Expand Down Expand Up @@ -62,7 +63,10 @@ function Content({ data }) {
{data.contentType === "markdown" && (
<MarkdownPreviewer
content={data.content || ""}
plugins={[renderMentionIdentityUserPlugin(<IdentityOrAddr />)]}
plugins={[
renderMentionIdentityUserPlugin(<IdentityOrAddr />),
correctionIpfsEndpointPlugin(),
]}
markedOptions={{
breaks: true,
}}
Expand All @@ -75,6 +79,7 @@ function Content({ data }) {
renderMentionIdentityUserPlugin(<IdentityOrAddr />, {
targetElement: { tag: "span" },
}),
correctionIpfsEndpointPlugin(),
]}
/>
)}
Expand Down
3 changes: 3 additions & 0 deletions packages/next-common/components/comment/item.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { getRealField } from "next-common/sima/actions/common";
import useIsCommentProxyAuthor from "next-common/hooks/useIsCommentProxyAuthor";
import { useRootCommentContext, useRootCommentData } from "./rootComment";
import { SubsquareCommentSource } from "./commentSource";
import correctionIpfsEndpointPlugin from "next-common/utils/previewerPlugins/correctionIpfsEndpoint";

function useIsShouldUseSimaCommentEdit() {
const comment = useComment();
Expand Down Expand Up @@ -114,6 +115,7 @@ function CommentItemImpl({ isSecondLevel, scrollToTopLevelCommentBottom }) {
content={comment.content || ""}
plugins={[
renderMentionIdentityUserPlugin(<IdentityOrAddr />),
correctionIpfsEndpointPlugin(),
]}
markedOptions={{
breaks: true,
Expand All @@ -127,6 +129,7 @@ function CommentItemImpl({ isSecondLevel, scrollToTopLevelCommentBottom }) {
renderMentionIdentityUserPlugin(<IdentityOrAddr />, {
targetElement: { tag: "span" },
}),
correctionIpfsEndpointPlugin(),
]}
/>
)}
Expand Down
3 changes: 3 additions & 0 deletions packages/next-common/components/commentSimple.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { hashEllipsis, textEllipsis } from "next-common/utils";
import { isNil } from "lodash-es";
import { formatTimeAgo } from "next-common/utils/viewfuncs/formatTimeAgo";
import { getChildBountyIndex } from "next-common/utils/viewfuncs/treasury/childBounty";
import correctionIpfsEndpointPlugin from "next-common/utils/previewerPlugins/correctionIpfsEndpoint";

const Wrapper = styled(HoverSecondaryCard)`
display: flex;
Expand Down Expand Up @@ -270,6 +271,7 @@ export default function CommentSimple({ data }) {
content={data.content || ""}
plugins={[
renderMentionIdentityUserPlugin(<IdentityOrAddr />),
correctionIpfsEndpointPlugin(),
]}
maxLines={2}
markedOptions={{
Expand All @@ -284,6 +286,7 @@ export default function CommentSimple({ data }) {
renderMentionIdentityUserPlugin(<IdentityOrAddr />, {
targetElement: { tag: "span" },
}),
correctionIpfsEndpointPlugin(),
]}
maxLines={2}
/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { HtmlPreviewer, MarkdownPreviewer } from "@osn/previewer";
import correctionIpfsEndpointPlugin from "next-common/utils/previewerPlugins/correctionIpfsEndpoint";

export default function ReferendaDelegateeDetailPopupAnnouncement({
delegate,
Expand Down Expand Up @@ -39,8 +40,12 @@ export default function ReferendaDelegateeDetailPopupAnnouncement({
markedOptions={{
breaks: true,
}}
plugins={[correctionIpfsEndpointPlugin()]}
/>
) : (
<HtmlPreviewer content={content} />
<HtmlPreviewer
content={content}
plugins={[correctionIpfsEndpointPlugin()]}
/>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
} from "@osn/previewer";
import IdentityOrAddr from "next-common/components/IdentityOrAddr";
import { prettyHTML } from "next-common/utils/viewfuncs";
import correctionIpfsEndpointPlugin from "next-common/utils/previewerPlugins/correctionIpfsEndpoint";

function AppendItem({ index, data }) {
return (
Expand All @@ -23,7 +24,10 @@ function AppendItem({ index, data }) {
{data.contentType === "markdown" && (
<MarkdownPreviewer
content={data.content || ""}
plugins={[renderMentionIdentityUserPlugin(<IdentityOrAddr />)]}
plugins={[
renderMentionIdentityUserPlugin(<IdentityOrAddr />),
correctionIpfsEndpointPlugin(),
]}
markedOptions={{
breaks: true,
}}
Expand All @@ -36,6 +40,7 @@ function AppendItem({ index, data }) {
renderMentionIdentityUserPlugin(<IdentityOrAddr />, {
targetElement: { tag: "span" },
}),
correctionIpfsEndpointPlugin(),
]}
/>
)}
Expand Down
7 changes: 4 additions & 3 deletions packages/next-common/utils/collective/getCidByEvidence.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import { create as createDigest } from "multiformats/hashes/digest";
const SHA_256_CODE = 0x12;

export function getCidByEvidence(evidence) {
return CID.createV0(createDigest(SHA_256_CODE, hexToU8a(evidence)))
.toV1()
.toString();
const evidenceDigest = createDigest(SHA_256_CODE, hexToU8a(evidence));
const cidV0 = CID.createV0(evidenceDigest);

return cidV0.toString();
}
13 changes: 12 additions & 1 deletion packages/next-common/utils/env/storageLink.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
import { CID } from "multiformats";

export function convertToCidV0(cid) {
try {
return CID.parse(cid).toV0().toString();
} catch {
// Keep CIDv1 and non-CID storage keys unchanged.
return cid;
}
}

export default function getStorageLink(cid) {
const endpoint = process.env.NEXT_PUBLIC_PREVIEW_IMG_ENDPOINT;

return `${endpoint}/${cid}`;
return `${endpoint}/${convertToCidV0(cid)}`;
}
Loading