mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
fix(mobile): hide empty mobile reply backlink wrapper (#1060)
getRenderableMobileBacklinks() now filters mobile backlinks down to replies that can actually render, so ReplyBacklinks only mounts mobileReplyBacklinks when there is visible content. This adds a regression test for the gap where a newly published reply exists before it receives its post number.
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
import type { Comment } from '@bitsocialnet/bitsocial-react-hooks';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { getRenderableMobileBacklinks } from '../reply-backlink-utils';
|
||||
|
||||
const createReply = (overrides: Partial<Comment> = {}) =>
|
||||
({
|
||||
cid: 'reply-cid',
|
||||
parentCid: 'target-cid',
|
||||
subplebbitAddress: 'music.eth',
|
||||
...overrides,
|
||||
}) as Comment;
|
||||
|
||||
describe('getRenderableMobileBacklinks', () => {
|
||||
it('does not report mobile reply backlinks until a renderable backlink exists', () => {
|
||||
const unpublishedReply = createReply({
|
||||
number: undefined,
|
||||
});
|
||||
|
||||
const beforePublish = getRenderableMobileBacklinks({
|
||||
cid: 'target-cid',
|
||||
parentCid: 'op-cid',
|
||||
quotedByMap: new Map([['target-cid', [unpublishedReply]]]),
|
||||
directRepliesByParentCid: new Map([['target-cid', [unpublishedReply]]]),
|
||||
});
|
||||
|
||||
expect(beforePublish.directReplyBacklinks).toHaveLength(0);
|
||||
expect(beforePublish.quotedReplyBacklinks).toHaveLength(0);
|
||||
|
||||
const publishedReply = createReply({
|
||||
cid: 'published-reply-cid',
|
||||
number: 42,
|
||||
});
|
||||
|
||||
const afterPublish = getRenderableMobileBacklinks({
|
||||
cid: 'target-cid',
|
||||
parentCid: 'op-cid',
|
||||
quotedByMap: new Map([['target-cid', [publishedReply]]]),
|
||||
directRepliesByParentCid: new Map([['target-cid', [publishedReply]]]),
|
||||
});
|
||||
|
||||
expect(afterPublish.directReplyBacklinks).toEqual([publishedReply]);
|
||||
expect(afterPublish.quotedReplyBacklinks).toHaveLength(0);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user