Skip to content

Commit

Permalink
Bugfix for saveChanges check
Browse files Browse the repository at this point in the history
  • Loading branch information
cjmalloy committed Dec 13, 2024
1 parent df9f4d4 commit d6299c3
Show file tree
Hide file tree
Showing 26 changed files with 30 additions and 29 deletions.
6 changes: 3 additions & 3 deletions src/app/component/comment/comment.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,9 @@ export class CommentComponent implements OnInit, AfterViewInit, OnChanges, OnDes
}

saveChanges() {
return !!this.editComponent?.saveChanges()
&& !!this.replyComponent?.saveChanges()
&& !!this.threadComponent?.saveChanges();
return (!this.editComponent || this.editComponent.saveChanges())
&& (!this.replyComponent || this.replyComponent.saveChanges())
&& (!this.threadComponent || this.threadComponent.saveChanges());
}

ngOnInit(): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export class ForceDirectedComponent implements AfterViewInit, OnDestroy, HasChan
}

saveChanges() {
return !!this.list?.saveChanges();
return !this.list || this.list.saveChanges();
}

ngOnDestroy() {
Expand Down
2 changes: 1 addition & 1 deletion src/app/component/ref/ref.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ export class RefComponent implements OnChanges, AfterViewInit, OnDestroy, HasCha

saveChanges() {
return (!this.editing || !this.editForm.dirty)
&& (!this.replying || !!this.reply?.saveChanges());
&& (!this.reply || this.reply.saveChanges());
}

init() {
Expand Down
2 changes: 1 addition & 1 deletion src/app/guard/pending-changes.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ export interface HasChanges {

export const pendingChangesGuard: CanDeactivateFn<HasChanges> = (component, currentRoute, currentState, nextState) => {
if (!component?.saveChanges || component.saveChanges()) return true;
return confirm($localize`Discard draft?`);
return confirm($localize`Discard draft?`);
};
2 changes: 1 addition & 1 deletion src/app/page/home/home.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export class HomePage implements OnInit, OnDestroy, HasChanges {
}

saveChanges() {
return !!this.lens?.saveChanges();
return !this.lens || this.lens.saveChanges();
}

ngOnInit(): void {
Expand Down
2 changes: 1 addition & 1 deletion src/app/page/inbox/alarms/alarms.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export class InboxAlarmsPage implements OnInit, OnDestroy, HasChanges {
}

saveChanges() {
return !!this.list?.saveChanges();
return !this.list || this.list.saveChanges();
}

ngOnInit(): void {
Expand Down
2 changes: 1 addition & 1 deletion src/app/page/inbox/all/all.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export class InboxAllPage implements OnInit, OnDestroy, HasChanges {
}

saveChanges() {
return !!this.list?.saveChanges();
return !this.list || this.list.saveChanges();
}

ngOnInit(): void {
Expand Down
2 changes: 1 addition & 1 deletion src/app/page/inbox/dms/dms.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export class InboxDmsPage implements OnInit, OnDestroy, HasChanges {
}

saveChanges() {
return !!this.list?.saveChanges();
return !this.list || this.list.saveChanges();
}

ngOnInit(): void {
Expand Down
2 changes: 1 addition & 1 deletion src/app/page/inbox/modlist/modlist.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class InboxModlistPage implements OnInit, OnDestroy, HasChanges {
}

saveChanges() {
return !!this.list?.saveChanges();
return !this.list || this.list.saveChanges();
}

ngOnInit(): void {
Expand Down
2 changes: 1 addition & 1 deletion src/app/page/inbox/ref/ref.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class InboxRefPage implements OnInit, OnDestroy, HasChanges {
}

saveChanges() {
return !!this.list?.saveChanges();
return !this.list || this.list.saveChanges();
}

ngOnInit(): void {
Expand Down
2 changes: 1 addition & 1 deletion src/app/page/inbox/reports/reports.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class InboxReportsPage implements OnInit, OnDestroy, HasChanges {
}

saveChanges() {
return !!this.list?.saveChanges();
return !this.list || this.list.saveChanges();
}

ngOnInit(): void {
Expand Down
2 changes: 1 addition & 1 deletion src/app/page/inbox/sent/sent.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export class InboxSentPage implements OnInit, OnDestroy, HasChanges {
}

saveChanges() {
return !!this.list?.saveChanges();
return !this.list || this.list.saveChanges();
}

ngOnInit(): void {
Expand Down
2 changes: 1 addition & 1 deletion src/app/page/ref/alts/alts.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class RefAltsComponent implements OnInit, OnDestroy, HasChanges {
}

saveChanges() {
return !!this.list?.saveChanges();
return !this.list || this.list.saveChanges();
}

ngOnInit(): void {
Expand Down
2 changes: 1 addition & 1 deletion src/app/page/ref/comments/comments.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class RefCommentsComponent implements OnInit, OnDestroy, HasChanges {
}

saveChanges() {
return !!this.reply?.saveChanges();
return !this.reply || this.reply.saveChanges();
}

ngOnInit(): void {
Expand Down
2 changes: 1 addition & 1 deletion src/app/page/ref/errors/errors.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export class RefErrorsComponent implements HasChanges {
}

saveChanges() {
return !!this.list?.saveChanges();
return !this.list || this.list.saveChanges();
}

ngOnInit(): void {
Expand Down
2 changes: 1 addition & 1 deletion src/app/page/ref/responses/responses.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class RefResponsesComponent implements OnInit, OnDestroy, HasChanges {
}

saveChanges() {
return !!this.list?.saveChanges();
return !this.list || this.list.saveChanges();
}

ngOnInit(): void {
Expand Down
2 changes: 1 addition & 1 deletion src/app/page/ref/sources/sources.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class RefSourcesComponent implements OnInit, OnDestroy, HasChanges {
}

saveChanges() {
return !!this.list?.saveChanges();
return !this.list || this.list.saveChanges();
}

ngOnInit(): void {
Expand Down
4 changes: 2 additions & 2 deletions src/app/page/ref/summary/summary.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ export class RefSummaryComponent implements OnInit, OnDestroy, HasChanges {
}

saveChanges() {
return !!this.reply?.saveChanges()
&& !!this.list?.saveChanges()
return (!this.reply || this.reply.saveChanges())
&& (!this.list || this.list.saveChanges())
&& !this.threadComponents?.find(t => !t.saveChanges());
}

Expand Down
3 changes: 2 additions & 1 deletion src/app/page/ref/thread/thread.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ export class RefThreadComponent implements HasChanges {
}

saveChanges() {
return !!this.reply?.saveChanges() && !!this.list?.saveChanges();
return (!this.reply || this.reply.saveChanges())
&& (!this.list || this.list.saveChanges());
}

ngOnInit(): void {
Expand Down
2 changes: 1 addition & 1 deletion src/app/page/ref/versions/versions.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class RefVersionsComponent implements OnInit, OnDestroy, HasChanges {
}

saveChanges() {
return !!this.list?.saveChanges();
return !this.list || this.list.saveChanges();
}

ngOnInit(): void {
Expand Down
2 changes: 1 addition & 1 deletion src/app/page/settings/plugin/plugin.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class SettingsPluginPage implements OnInit, OnDestroy, HasChanges {
}

saveChanges() {
return !!this.list?.saveChanges();
return !this.list || this.list.saveChanges();
}

ngOnInit(): void {
Expand Down
2 changes: 1 addition & 1 deletion src/app/page/settings/ref/ref.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class SettingsRefPage implements OnInit, OnDestroy, HasChanges {
}

saveChanges() {
return !!this.list?.saveChanges();
return !this.list || this.list.saveChanges();
}

ngOnInit(): void {
Expand Down
2 changes: 1 addition & 1 deletion src/app/page/settings/template/template.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export class SettingsTemplatePage implements OnInit, OnDestroy, HasChanges {
}

saveChanges() {
return !!this.list?.saveChanges();
return !this.list || this.list.saveChanges();
}

ngOnInit(): void {
Expand Down
2 changes: 1 addition & 1 deletion src/app/page/settings/user/user.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class SettingsUserPage implements OnInit, OnDestroy, HasChanges {
}

saveChanges() {
return !!this.list?.saveChanges();
return !this.list || this.list.saveChanges();
}

ngOnInit(): void {
Expand Down
2 changes: 1 addition & 1 deletion src/app/page/tag/tag.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export class TagPage implements OnInit, OnDestroy, HasChanges {
}

saveChanges() {
return !!this.lens?.saveChanges();
return !this.lens || this.lens.saveChanges();
}

ngOnInit() {
Expand Down
2 changes: 1 addition & 1 deletion src/app/page/tags/tags.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export class TagsPage implements OnInit, OnDestroy, HasChanges {
}

saveChanges() {
return !!this.list?.saveChanges();
return !this.list || this.list.saveChanges();
}

ngOnInit(): void {
Expand Down

0 comments on commit d6299c3

Please sign in to comment.