highlight mentions

This commit is contained in:
2026-06-07 18:31:10 +03:00
parent b6450a29fd
commit 5dfe477607
3 changed files with 30 additions and 3 deletions

View File

@@ -1,11 +1,13 @@
export const b = {
init: 'activatePostImages',
init: 'activatePostImages getUserData',
}
const POST_IMAGES_SELECTOR = 'img.post-image:not(aside img.post-image)'
const WHOAMI_ENDPOINT = '/api/whoami/'
let images = [];
let currentIndex = 0;
let currentUser = null;
export function activatePostImages(_, __, ___) {
const images = document.querySelectorAll(POST_IMAGES_SELECTOR);
@@ -62,3 +64,16 @@ export function lightboxPrevious(_, __, ___) {
}
b.trigger('showLightbox');
}
export async function getUserData(_, __, ___) {
currentUser = await b.getData(WHOAMI_ENDPOINT);
b.trigger('highlightMentions');
}
export function highlightMentions(_, __, el) {
if (!el) return;
if (el.dataset.username === currentUser.username) {
el.classList.add('me');
}
}