mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
fix(hooks): handle pkc rebrand regressions
This commit is contained in:
@@ -76,10 +76,10 @@ describe('usePublishPost', () => {
|
||||
expect(latestValue.publishPost).toBe(testState.publishCommentMock);
|
||||
expect(latestValue.publishPostOptions).toMatchObject({
|
||||
author: { displayName: 'Alice' },
|
||||
communityAddress: 'music.eth',
|
||||
content: undefined,
|
||||
link: undefined,
|
||||
spoiler: true,
|
||||
subplebbitAddress: 'music.eth',
|
||||
title: 'Hello world',
|
||||
});
|
||||
expect(typeof latestValue.publishPostOptions.onChallengeVerification).toBe('function');
|
||||
|
||||
@@ -104,13 +104,13 @@ describe('usePublishReply', () => {
|
||||
expect(typeof latestValue.publishReply).toBe('function');
|
||||
expect(testState.lastPublishOptions).toMatchObject({
|
||||
author: { displayName: 'Bob' },
|
||||
communityAddress: 'music.eth',
|
||||
content: 'Replying to >>12',
|
||||
link: undefined,
|
||||
parentCid: 'parent-cid',
|
||||
postCid: 'parent-cid',
|
||||
quotedCids: ['quoted-cid'],
|
||||
spoiler: true,
|
||||
subplebbitAddress: 'music.eth',
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -32,7 +32,6 @@ const usePublishPost = ({ communityAddress: requestedCommunityAddress, subplebbi
|
||||
const createBaseOptions = useCallback(() => {
|
||||
const baseOptions: Comment = {
|
||||
communityAddress,
|
||||
subplebbitAddress: communityAddress,
|
||||
title,
|
||||
content,
|
||||
link,
|
||||
@@ -58,7 +57,17 @@ const usePublishPost = ({ communityAddress: requestedCommunityAddress, subplebbi
|
||||
{} as Partial<Comment>,
|
||||
);
|
||||
|
||||
const newOptions = { ...baseOptions, ...sanitizedOptions };
|
||||
const {
|
||||
communityAddress: nextCommunityAddress,
|
||||
subplebbitAddress: legacyCommunityAddress,
|
||||
...restOptions
|
||||
} = sanitizedOptions as Partial<Comment> & { subplebbitAddress?: string };
|
||||
const resolvedCommunityAddress = nextCommunityAddress ?? legacyCommunityAddress ?? baseOptions.communityAddress;
|
||||
const newOptions = {
|
||||
...baseOptions,
|
||||
...restOptions,
|
||||
...(resolvedCommunityAddress ? { communityAddress: resolvedCommunityAddress } : {}),
|
||||
};
|
||||
setPublishPostStore(newOptions);
|
||||
},
|
||||
[createBaseOptions, setPublishPostStore],
|
||||
|
||||
@@ -50,7 +50,6 @@ const usePublishReply = ({ cid, communityAddress: requestedCommunityAddress, sub
|
||||
const createBaseOptions = useCallback(() => {
|
||||
const baseOptions: Comment = {
|
||||
communityAddress,
|
||||
subplebbitAddress: communityAddress,
|
||||
parentCid,
|
||||
postCid: postCid ?? parentCid,
|
||||
content,
|
||||
@@ -77,7 +76,17 @@ const usePublishReply = ({ cid, communityAddress: requestedCommunityAddress, sub
|
||||
{} as Partial<Comment>,
|
||||
);
|
||||
|
||||
const newOptions = { ...baseOptions, ...sanitizedOptions };
|
||||
const {
|
||||
communityAddress: nextCommunityAddress,
|
||||
subplebbitAddress: legacyCommunityAddress,
|
||||
...restOptions
|
||||
} = sanitizedOptions as Partial<Comment> & { subplebbitAddress?: string };
|
||||
const resolvedCommunityAddress = nextCommunityAddress ?? legacyCommunityAddress ?? baseOptions.communityAddress;
|
||||
const newOptions = {
|
||||
...baseOptions,
|
||||
...restOptions,
|
||||
...(resolvedCommunityAddress ? { communityAddress: resolvedCommunityAddress } : {}),
|
||||
};
|
||||
setPublishReplyStore(newOptions);
|
||||
},
|
||||
[createBaseOptions, setPublishReplyStore],
|
||||
|
||||
Reference in New Issue
Block a user