Merge pull request #1044 from PR0M3TH3AN/codex/update-getcommentcachekey-for-videoeventid

Normalize comment cache keys for mixed-case IDs
This commit is contained in:
thePR0M3TH3AN authored and GitHub committed 2025-12-12 10:36:37 -05:00
commit 5c5cd7b60c
2 files changed
+40 -1

No files matched your search

+5 -1
View File
@@ -324,7 +324,11 @@ export default class CommentThreadService {
getCommentCacheKey(videoEventId) {
const normalized = normalizeString(videoEventId);
return normalized ? `${COMMENT_CACHE_PREFIX}${normalized}` : "";
if (!normalized) {
return "";
}
return `${COMMENT_CACHE_PREFIX}${normalized.toLowerCase()}`;
}
getCachedComments(videoEventId) {
+35
View File
@@ -88,6 +88,41 @@ test.after(() => {
}
});
test("CommentThreadService caches mixed-case video ids consistently", () => {
const videoEventId = "VideoMixed123";
const service = new CommentThreadService();
const comments = [
{
id: "comment-1",
pubkey: "authorpk",
content: "Cached comment",
created_at: 1700000000,
tags: [],
},
];
service.cacheComments(videoEventId, comments);
const cachedKeys = [];
for (let index = 0; index < localStorage.length; index += 1) {
cachedKeys.push(localStorage.key(index));
}
assert.deepEqual(
cachedKeys,
["bitvid:comments:videomixed123"],
"cache key should normalize mixed-case ids",
);
const cached = service.getCachedComments(videoEventId.toLowerCase());
assert.deepEqual(
cached,
comments,
"mixed-case ids should retrieve cached entries",
);
});
test(
"listVideoComments accepts builder events without parent ids and filters replies",
async () => {