Skip to content

Commit 07e56c9

Browse files
author
Mateus Medeiros
committed
Fix rewind audio bug
1 parent 99e7196 commit 07e56c9

3 files changed

Lines changed: 7 additions & 35 deletions

File tree

src/webapp/src/app/listen-and-write/listen-and-write.component.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -274,8 +274,6 @@ export class ListenAndWriteComponent implements OnDestroy {
274274
pauseAudioWithTimerClear() {
275275
this.newsAudioComponent.pauseAudio();
276276
this.clearAutoPauseTimer();
277-
// Refocus textarea when audio is manually paused
278-
this.exerciseSectionComponent?.focusTextArea();
279277
}
280278

281279
clearAutoPauseTimer() {
@@ -342,8 +340,6 @@ export class ListenAndWriteComponent implements OnDestroy {
342340
this.newsAudioComponent.pauseAudio();
343341
}
344342
this.clearAutoPauseTimer();
345-
// Refocus textarea when audio is auto-paused
346-
this.exerciseSectionComponent?.focusTextArea();
347343
}, duration * 1000);
348344
}
349345
}
@@ -392,6 +388,9 @@ export class ListenAndWriteComponent implements OnDestroy {
392388

393389
onAudioPaused() {
394390
this.onSaveExerciseState();
391+
if (this.exerciseState() !== 'exercise') return;
392+
// When the user pauses via native controls, restore focus so shortcuts keep working.
393+
this.exerciseSectionComponent?.focusTextArea();
395394
}
396395

397396
onSaveExerciseState() {
Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import { CommonModule, IMAGE_LOADER, NgOptimizedImage } from '@angular/common';
2-
import { Component, HostListener, computed, effect, input, signal } from '@angular/core';
2+
import { Component, computed, effect, input, signal } from '@angular/core';
33
import { Proposition } from 'src/api/listen-and-write';
44
import { minioVariantImageLoader } from '../../shared/image-loaders/minio-variant-image.loader';
5-
import { BrowserService } from '../../core/services/browser.service';
65

76
@Component({
87
selector: 'app-news-image',
@@ -19,29 +18,18 @@ import { BrowserService } from '../../core/services/browser.service';
1918
export class NewsImageComponent {
2019

2120
proposition = input<Proposition | null>();
22-
private readonly mobileMaxWidth = 600;
23-
private readonly mobileSrcset = '320w, 512w, 640w';
24-
private readonly desktopSrcset = '320w, 512w, 640w, 1024w';
21+
private readonly unifiedSrcset = '320w, 512w, 640w, 1024w';
2522
readonly imageLoaderParams = { defaultWidth: 640 };
26-
readonly isMobileLayout = signal(false);
27-
readonly imageSrcset = computed(() => (
28-
this.isMobileLayout() ? this.mobileSrcset : this.desktopSrcset
29-
));
23+
readonly imageSrcset = computed(() => this.unifiedSrcset);
3024
imageLoadFailed = signal(false);
3125

3226
imageBaseId = computed(() => this.getImageBaseId(this.proposition()?.imageFileId));
3327

34-
constructor(private browserService: BrowserService) {
28+
constructor() {
3529
effect(() => {
3630
this.proposition();
3731
this.imageLoadFailed.set(false);
3832
});
39-
this.updateMobileLayout();
40-
}
41-
42-
@HostListener('window:resize')
43-
onWindowResize(): void {
44-
this.updateMobileLayout();
4533
}
4634

4735
onOptimizedImageError(): void {
@@ -56,9 +44,4 @@ export class NewsImageComponent {
5644
const baseId = lastDot > 0 ? imageFileId.slice(0, lastDot) : imageFileId;
5745
return baseId.replace(/_w\d+$/, '');
5846
}
59-
60-
private updateMobileLayout(): void {
61-
const width = this.browserService.getWindowWidth();
62-
this.isMobileLayout.set(width > 0 && width <= this.mobileMaxWidth);
63-
}
6447
}

src/webapp/src/index.html

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,6 @@
1515
<link rel="icon" type="image/x-icon" href="assets/app-icon.svg">
1616
<link rel="apple-touch-icon" href="assets/app-icon.svg">
1717

18-
<!-- LCP poster preload -->
19-
<link
20-
rel="preload"
21-
as="image"
22-
href="assets/hero-listening-640.webp"
23-
imagesrcset="assets/hero-listening-640.webp 640w, assets/hero-listening-1024.webp 1024w"
24-
imagesizes="(max-width: 900px) 92vw, 600px"
25-
type="image/webp"
26-
fetchpriority="high">
27-
2818
<!-- Preconnect + DNS-prefetch for external font hosts -->
2919
<link rel="dns-prefetch" href="https://fonts.googleapis.com">
3020
<link rel="dns-prefetch" href="https://fonts.gstatic.com">

0 commit comments

Comments
 (0)