highlight mentions
This commit is contained in:
@@ -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');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user