mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-30 14:57:59 +01:00
adjustments based on PR comments
This commit is contained in:
parent
aade85a0ff
commit
87f37ab8d4
4 changed files with 13 additions and 12 deletions
|
@ -381,6 +381,8 @@ describe('DOM Utilities', () => {
|
|||
|
||||
fireEvent.click(element, { button: 0 });
|
||||
|
||||
expect(mockCallback).toHaveBeenCalledTimes(1);
|
||||
|
||||
// Remove the listener
|
||||
localCleanup();
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { $$ } from './dom';
|
||||
|
||||
let dragSrcEl: HTMLElement | undefined;
|
||||
let dragSrcEl: HTMLElement | null = null;
|
||||
|
||||
function dragStart(event: DragEvent, target: HTMLElement) {
|
||||
target.classList.add('dragging');
|
||||
|
@ -83,6 +83,5 @@ export function clearDragSource() {
|
|||
if (!dragSrcEl) return;
|
||||
|
||||
dragSrcEl.classList.remove('dragging');
|
||||
// eslint-disable-next-line no-undefined
|
||||
dragSrcEl = undefined;
|
||||
dragSrcEl = null;
|
||||
}
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
import { clearEl } from './dom';
|
||||
import store from './store';
|
||||
|
||||
function showVideoThumb(img: HTMLDivElement, size: string, urisString: string) {
|
||||
const uris = JSON.parse(urisString);
|
||||
function showVideoThumb(img: HTMLDivElement, size: string, uris: Record<string, string>) {
|
||||
const thumbUri = uris[size];
|
||||
|
||||
const vidEl = img.querySelector('video');
|
||||
|
@ -31,11 +30,11 @@ export function showThumb(img: HTMLDivElement) {
|
|||
const urisString = img.dataset.uris;
|
||||
if (!size || !urisString) return false;
|
||||
|
||||
const uris = JSON.parse(urisString);
|
||||
const uris: Record<string, string> = JSON.parse(urisString);
|
||||
const thumbUri = uris[size].replace(/webm$/, 'gif');
|
||||
|
||||
const picEl = img.querySelector('picture');
|
||||
if (!picEl) return showVideoThumb(img, size, urisString);
|
||||
if (!picEl) return showVideoThumb(img, size, uris);
|
||||
|
||||
const imgEl = picEl.querySelector('img');
|
||||
if (!imgEl || imgEl.src.indexOf(thumbUri) !== -1) return false;
|
||||
|
@ -128,15 +127,16 @@ export function spoilerThumb(img: HTMLDivElement, spoilerUri: string, reason: st
|
|||
export function spoilerBlock(img: HTMLDivElement, spoilerUri: string, reason: string) {
|
||||
const imgFiltered = img.querySelector('.image-filtered');
|
||||
const imgEl = imgFiltered?.querySelector<HTMLImageElement>('img');
|
||||
const imgReason = img.querySelector<HTMLElement>('.filter-explanation');
|
||||
|
||||
if (!imgEl) return;
|
||||
|
||||
const imgReason = img.querySelector<HTMLElement>('.filter-explanation');
|
||||
const imageShow = img.querySelector('.image-show');
|
||||
|
||||
imgEl.src = spoilerUri;
|
||||
if (imgReason) {
|
||||
imgReason.innerHTML = reason;
|
||||
}
|
||||
|
||||
img.querySelector('.image-show')?.classList.add('hidden');
|
||||
imageShow?.classList.add('hidden');
|
||||
if (imgFiltered) imgFiltered.classList.remove('hidden');
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue