Skip to content

Commit

Permalink
Fix: Preview reload after synchronizing (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
RikudouSage authored Sep 14, 2023
1 parent 37dcd3f commit b521874
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ <h3>Preview</h3>

<ng-template #previewTable>
<app-blacklist-diff
[originalList]="originallyBlockedInstances"
[originalList]="sourceBlockedInstances"
[newList]="instancesToBanPreview!"
[purgeMode]="purgeMode ?? false"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export class SynchronizeLemmyComponent implements OnInit {
public currentMode: SynchronizationMode | null = null;
public purgeMode: boolean | null = null;
public originallyBlockedInstances: string[] = [];
public sourceBlockedInstances: string[] = [];
public instancesToBanPreview: InstanceDetailResponse[] | null = null;

public saveSettingsCallback: SaveSettingsCallback<LemmySynchronizationSettings> = (database, settings) => {
Expand Down Expand Up @@ -75,6 +76,7 @@ export class SynchronizeLemmyComponent implements OnInit {
return;
}
this.originallyBlockedInstances = instances;
this.sourceBlockedInstances = instances;

this.form.valueChanges.pipe(
debounceTime(500),
Expand Down Expand Up @@ -202,6 +204,13 @@ export class SynchronizeLemmyComponent implements OnInit {
}

this.messageService.createSuccess('The list was successfully synchronized');

const newBlockedInstances = await this.getBlockedInstancesFromSource(this.authManager.currentInstanceSnapshot.name);
if (newBlockedInstances === null) {
this.messageService.createError('Failed to fetch the updated list from your instance, please refresh the page');
} else {
this.sourceBlockedInstances = newBlockedInstances;
}
} finally {
this.loading = false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ <h3>Preview</h3>

<ng-template #previewTable>
<app-blacklist-diff
[originalList]="originallyBlockedInstances"
[originalList]="sourceBlockedInstances"
[newList]="instancesToBanPreview!"
[purgeMode]="purgeMode ?? false"
[originalToStringCallback]="instanceToStringCallback"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export class SynchronizeMastodonComponent implements OnInit {
});

public originallyBlockedInstances: MastodonBlacklistItem[] = [];
public sourceBlockedInstances: MastodonBlacklistItem[] = [];

public loading: boolean = true;
public oauthSetupFinished: boolean = true;
Expand Down Expand Up @@ -121,6 +122,7 @@ export class SynchronizeMastodonComponent implements OnInit {
return;
}
this.originallyBlockedInstances = instances;
this.sourceBlockedInstances = instances;
}

public async saveOauth(): Promise<void> {
Expand Down Expand Up @@ -244,6 +246,13 @@ export class SynchronizeMastodonComponent implements OnInit {
} catch (e) {
this.messageService.createError('Failed to update the blacklist.')
}

const newBlockedInstances = await this.getBlockedInstancesFromSource(this.authManager.currentInstanceSnapshot.name);
if (newBlockedInstances === null) {
this.messageService.createError('Failed to fetch the updated list from your instance, please refresh the page');
} else {
this.sourceBlockedInstances = newBlockedInstances;
}
this.loading = false;
}

Expand Down

0 comments on commit b521874

Please sign in to comment.