Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a bug when expanding Expand will trigger auto cut #388

Merged
merged 1 commit into from
Aug 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions frontend/src/Components/ContentComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
div: HTMLDivElement,
setZoomedImg: (img: ZoomedImg | null) => void,
setMailboxKey: (key: MailboxKey | MailKey | null) => void,
setCut: (cut: boolean) => void,
currentUsername?: string
) {
div.querySelectorAll('img').forEach(img => {
Expand All @@ -83,7 +84,7 @@
});

div.querySelectorAll('details.expand').forEach(expand => {
updateExpand(expand as HTMLDetailsElement);
updateExpand(expand as HTMLDetailsElement, setCut);
});

div.querySelectorAll('span.secret-mailbox').forEach(mailbox => {
Expand Down Expand Up @@ -453,7 +454,7 @@

let el: HTMLElement | null = img;
while (el) {
if (el.tagName.toUpperCase() === 'A' ||

Check warning on line 457 in frontend/src/Components/ContentComponent.tsx

View workflow job for this annotation

GitHub Actions / build-lint (frontend)

Unexpected mix of '||' and '&&'. Use parentheses to clarify the intended order of operations
el.tagName.toUpperCase() === 'SPAN' && el.className.indexOf('secret-mail') !== -1) {
return;
}
Expand Down Expand Up @@ -491,11 +492,12 @@
spoiler.addEventListener('click', spoilerOnClickHandler);
}

function updateExpand(expand: HTMLDetailsElement) {
function updateExpand(expand: HTMLDetailsElement, setCut: (cut: boolean) => void) {
expand.addEventListener('toggle', () => {
if (!expand.open) {
stopInnerVideos(expand);
}
setCut(false);
});

const expandClose = expand.querySelector('div[role="button"]');
Expand Down Expand Up @@ -569,7 +571,7 @@
return;
}

updateContent(appState, content, setZoomedImg, setMailboxKey, props.currentUsername);
updateContent(appState, content, setZoomedImg, setMailboxKey, setCut, props.currentUsername);
let resizeObserver: ResizeObserver | null = null;

if (props.lowRating) {
Expand Down
Loading