Skip to content

Commit

Permalink
Merge branch 'base' into production
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastianKohler committed Feb 19, 2024
2 parents 83523c3 + 308186e commit fe500d7
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 17 deletions.
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/), and this



## [1.3.1] – 2024-02-19

### Fixes

- Memory leak related to BehaviorSubject-subscription in the download-texts modal. Also, as a precation, unsubscribe from all route subscriptions on component destruction. ([b32dfe4](https://github.com/slsfi/digital-edition-frontend-ng/commit/b32dfe4e74393ecb64aad4f83d415fa60f2f37bb))



## [1.3.0] – 2024-02-16

### Added
Expand Down Expand Up @@ -303,7 +311,8 @@ siteLogoDimensions: {



[unreleased]: https://github.com/slsfi/digital-edition-frontend-ng/compare/1.3.0...HEAD
[unreleased]: https://github.com/slsfi/digital-edition-frontend-ng/compare/1.3.1...HEAD
[1.3.1]: https://github.com/slsfi/digital-edition-frontend-ng/compare/1.3.0...1.3.1
[1.3.0]: https://github.com/slsfi/digital-edition-frontend-ng/compare/1.2.3...1.3.0
[1.2.3]: https://github.com/slsfi/digital-edition-frontend-ng/compare/1.2.2...1.2.3
[1.2.2]: https://github.com/slsfi/digital-edition-frontend-ng/compare/1.2.1...1.2.2
Expand Down
14 changes: 9 additions & 5 deletions src/app/dialogs/modals/download-texts/download-texts.modal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export class DownloadTextsModal implements OnDestroy, OnInit {
manuscriptsList$: Observable<any[]>;
readTextLanguages: string[] = [];
referenceData: any = null;
pageTitleSubscr: Subscription | null = null;
printTextSubscription: Subscription | null = null;
printTranslation: string = '';
publicationData$: Observable<any>;
Expand Down Expand Up @@ -167,11 +168,13 @@ export class DownloadTextsModal implements OnDestroy, OnInit {

if (this.readTextsMode) {
// Get publication title
this.headService.getCurrentPageTitle().subscribe((pubTitle: string) => {
this.publicationTitle = pubTitle?.slice(-1) === '.'
? pubTitle.slice(0, -1)
: pubTitle;
});
this.pageTitleSubscr = this.headService.getCurrentPageTitle().subscribe(
(pubTitle: string) => {
this.publicationTitle = pubTitle?.slice(-1) === '.'
? pubTitle.slice(0, -1)
: pubTitle;
}
);

if (this.downloadFormatsEst.length || this.downloadFormatsCom.length) {
// Get publication data in order to determine if reading-texts and
Expand Down Expand Up @@ -214,6 +217,7 @@ export class DownloadTextsModal implements OnDestroy, OnInit {
ngOnDestroy() {
this.downloadTextSubscription?.unsubscribe();
this.printTextSubscription?.unsubscribe();
this.pageTitleSubscr?.unsubscribe();
}

dismiss() {
Expand Down
8 changes: 6 additions & 2 deletions src/app/dialogs/modals/named-entity/named-entity.modal.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, Input, OnInit } from '@angular/core';
import { Component, Input, OnDestroy, OnInit } from '@angular/core';
import { AsyncPipe, NgFor, NgIf } from '@angular/common';
import { NavigationEnd, Router, RouterModule } from '@angular/router';
import { IonicModule, ModalController } from '@ionic/angular';
Expand All @@ -18,7 +18,7 @@ import { isEmptyObject } from '@utility-functions';
styleUrls: ['./named-entity.modal.scss'],
imports: [AsyncPipe, NgFor, NgIf, IonicModule, OccurrencesAccordionComponent, RouterModule]
})
export class NamedEntityModal implements OnInit {
export class NamedEntityModal implements OnDestroy, OnInit {
@Input() id: string = '';
@Input() type: string = '';

Expand Down Expand Up @@ -67,6 +67,10 @@ export class NamedEntityModal implements OnInit {
});
}

ngOnDestroy() {
this.routerEventsSubscription?.unsubscribe();
}

ionViewWillLeave() {
this.routerEventsSubscription?.unsubscribe();
}
Expand Down
12 changes: 9 additions & 3 deletions src/app/pages/ebook/ebook.page.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Component, OnInit } from '@angular/core';
import { Component, OnDestroy, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { Subscription } from 'rxjs';

import { config } from '@config';

Expand All @@ -9,17 +10,18 @@ import { config } from '@config';
templateUrl: './ebook.page.html',
styleUrls: ['./ebook.page.scss'],
})
export class EbookPage implements OnInit {
export class EbookPage implements OnDestroy, OnInit {
ebookType: string = '';
filename: string = '';
routeParamsSubscr: Subscription | null = null;
title: string = '';

constructor(
private route: ActivatedRoute
) {}

ngOnInit() {
this.route.params.subscribe(params => {
this.routeParamsSubscr = this.route.params.subscribe(params => {
this.filename = '';
this.ebookType = '';
const availableEbooks: any[] = config.ebooks ?? [];
Expand All @@ -36,4 +38,8 @@ export class EbookPage implements OnInit {
});
}

ngOnDestroy() {
this.routeParamsSubscr?.unsubscribe();
}

}
6 changes: 3 additions & 3 deletions src/app/services/document-head.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { config } from '@config';
providedIn: 'root',
})
export class DocumentHeadService {
private currentPageTitle: BehaviorSubject<string> = new BehaviorSubject('');
private currentPageTitle$: BehaviorSubject<string> = new BehaviorSubject('');
private currentRouterUrl: string | undefined = undefined;
private openGraphTags: any = undefined;
private languages: any[] = [];
Expand Down Expand Up @@ -203,11 +203,11 @@ export class DocumentHeadService {
}

setCurrentPageTitle(newTitle: string) {
this.currentPageTitle.next(newTitle);
this.currentPageTitle$.next(newTitle);
}

getCurrentPageTitle(): Observable<string> {
return this.currentPageTitle.asObservable();
return this.currentPageTitle$.asObservable();
}

}
6 changes: 3 additions & 3 deletions src/app/services/view-options.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class ViewOptionsService {
};

private epubAlertDismissed: boolean = false;
private textsizeSubject: BehaviorSubject<Textsize> = new BehaviorSubject<Textsize>(Textsize.Small);
private textsizeSubject$: BehaviorSubject<Textsize> = new BehaviorSubject<Textsize>(Textsize.Small);

constructor() {
const defaultViewOptions: string[] = config.page?.text?.defaultViewOptions ?? [];
Expand All @@ -35,11 +35,11 @@ export class ViewOptionsService {
}

getTextsize(): Observable<Textsize> {
return this.textsizeSubject.asObservable();
return this.textsizeSubject$.asObservable();
}

setTextsize(textsize: Textsize) {
this.textsizeSubject.next(textsize);
this.textsizeSubject$.next(textsize);
}

epubAlertIsDismissed() {
Expand Down

0 comments on commit fe500d7

Please sign in to comment.