Something went wrong. Try again.
A live media wall for your Bluesky follows
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374import assert from 'node:assert/strict';import { test } from 'node:test';import { hiddenPostsKey, readHiddenPosts, updateHiddenPost, withoutHiddenPosts} from './hidden-posts.js';import { reconcileWallItems } from './masonry.js';
const account = 'did:plc:alice';const otherAccount = 'did:plc:bob';const uri = 'at://did:plc:author/app.bsky.feed.post/first';const otherUri = 'at://did:plc:author/app.bsky.feed.post/second';const photo = { uri, id: `${uri}#image-0`, provisional: true };const otherPhoto = { uri, id: `${uri}#image-1` };const otherPost = { uri: otherUri, id: `${otherUri}#video` };
function inMemoryStorage() { const data = new Map<string, string>(); return { getItem: (key: string) => data.get(key) ?? null, setItem: (key: string, value: string) => { data.set(key, value); } };}
void test('account-local hide persists by post URI and removes cached and new tiles even while paused', () => { const storage = inMemoryStorage(); updateHiddenPost(account, uri, 'author.test', storage); const hidden = readHiddenPosts(account, storage); const displayed = [photo, otherPost]; const arriving = [{ ...photo, provisional: false }, otherPhoto, otherPost]; const visible = withoutHiddenPosts(arriving, hidden); assert.deepEqual(visible, [otherPost]); assert.deepEqual(reconcileWallItems(displayed, visible, true), [otherPost]); assert.deepEqual(withoutHiddenPosts(arriving, readHiddenPosts(otherAccount, storage)), arriving); assert.deepEqual(hidden.get(uri), { uri, author: 'author.test' });});
void test('unhide removes only the chosen local rule and does not restore posts removed upstream', () => { const storage = inMemoryStorage(); updateHiddenPost(account, uri, 'author.test', storage); updateHiddenPost(account, otherUri, 'author.test', storage); updateHiddenPost(otherAccount, uri, 'author.test', storage); const restored = updateHiddenPost(account, uri, null, storage)!; assert.deepEqual(withoutHiddenPosts([photo, otherPhoto, otherPost], restored), [ photo, otherPhoto ]); assert.deepEqual(withoutHiddenPosts([otherPost], restored), []); assert.ok(readHiddenPosts(otherAccount, storage).has(uri));});
void test('malformed rules are ignored and failed writes do not appear to succeed', () => { const storage = inMemoryStorage(); storage.setItem( hiddenPostsKey(account), JSON.stringify([null, { uri }, { uri: `${uri}#image-0`, author: 'author' }]) ); assert.equal(readHiddenPosts(account, storage).size, 0); assert.equal(updateHiddenPost(account, `${uri}#image-0`, 'author', storage), null); assert.equal( updateHiddenPost(account, uri, 'author', { ...storage, setItem() { throw new Error('denied'); } }), null );});