From 15ab7ba56eb92416802e6d8ce1077498867ff2ac Mon Sep 17 00:00:00 2001 From: Nicolas Constant Date: Fri, 10 Apr 2020 23:27:29 -0400 Subject: [PATCH] added settings to disable remote status fetching --- .../floating-column/settings/settings.component.html | 9 +++++++++ .../floating-column/settings/settings.component.ts | 8 ++++++++ src/app/components/stream/thread/thread.component.ts | 6 ++++++ src/app/states/settings.state.ts | 6 ++++-- 4 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/app/components/floating-column/settings/settings.component.html b/src/app/components/floating-column/settings/settings.component.html index af7ea1c5..25cb6d8c 100644 --- a/src/app/components/floating-column/settings/settings.component.html +++ b/src/app/components/floating-column/settings/settings.component.html @@ -94,6 +94,15 @@
this settings needs a reload to be effective.
+

Other

+
+ + +
+
+

About

Sengi version: {{version}}
diff --git a/src/app/components/floating-column/settings/settings.component.ts b/src/app/components/floating-column/settings/settings.component.ts index aa9f8d25..959111ed 100644 --- a/src/app/components/floating-column/settings/settings.component.ts +++ b/src/app/components/floating-column/settings/settings.component.ts @@ -21,6 +21,7 @@ export class SettingsComponent implements OnInit { notificationForm: FormGroup; disableAutofocusEnabled: boolean; + disableRemoteStatusFetchingEnabled: boolean; disableAvatarNotificationsEnabled: boolean; disableSoundsEnabled: boolean; version: string; @@ -78,6 +79,7 @@ export class SettingsComponent implements OnInit { this.disableAutofocusEnabled = settings.disableAutofocus; this.disableAvatarNotificationsEnabled = settings.disableAvatarNotifications; this.disableSoundsEnabled = settings.disableSounds; + this.disableRemoteStatusFetchingEnabled = settings.disableRemoteStatusFetching; if (!settings.columnSwitchingWinAlt) { this.columnShortcutEnabled = ColumnShortcut.Ctrl; @@ -172,6 +174,12 @@ export class SettingsComponent implements OnInit { this.toolsService.saveSettings(settings); } + onDisableRemoteStatusFetchingChanged() { + let settings = this.toolsService.getSettings(); + settings.disableRemoteStatusFetching = this.disableRemoteStatusFetchingEnabled; + this.toolsService.saveSettings(settings); + } + onDisableAvatarNotificationsChanged() { let settings = this.toolsService.getSettings(); settings.disableAvatarNotifications = this.disableAvatarNotificationsEnabled; diff --git a/src/app/components/stream/thread/thread.component.ts b/src/app/components/stream/thread/thread.component.ts index e80579b8..bb6d7576 100644 --- a/src/app/components/stream/thread/thread.component.ts +++ b/src/app/components/stream/thread/thread.component.ts @@ -22,6 +22,7 @@ export class ThreadComponent implements OnInit, OnDestroy { isLoading = true; isThread = true; hasContentWarnings = false; + private remoteStatusFetchingDisabled = false; bufferStream: Status[] = []; //html compatibility only @@ -57,6 +58,9 @@ export class ThreadComponent implements OnInit, OnDestroy { private readonly mastodonService: MastodonWrapperService) { } ngOnInit() { + let settings = this.toolsService.getSettings(); + this.remoteStatusFetchingDisabled = settings.disableRemoteStatusFetching; + if (this.refreshEventEmitter) { this.refreshSubscription = this.refreshEventEmitter.subscribe(() => { this.refresh(); @@ -219,6 +223,8 @@ export class ThreadComponent implements OnInit, OnDestroy { } private async retrieveRemoteThread(status: Status): Promise { + if(this.remoteStatusFetchingDisabled) return []; + try { let url = status.url; let splitUrl = url.replace('https://', '').split('/'); diff --git a/src/app/states/settings.state.ts b/src/app/states/settings.state.ts index e048c2bb..085f8d18 100644 --- a/src/app/states/settings.state.ts +++ b/src/app/states/settings.state.ts @@ -51,14 +51,15 @@ export class GlobalSettings { disableAutofocus = false; disableAvatarNotifications = false; disableSounds = false; - + disableRemoteStatusFetching = false; + notificationSoundFileId: string = '0'; contentWarningPolicy: ContentWarningPolicy = new ContentWarningPolicy(); columnSwitchingWinAlt = false; - accountSettings: AccountSettings[] = []; + accountSettings: AccountSettings[] = []; } export interface SettingsStateModel { @@ -143,6 +144,7 @@ export class SettingsState { newSettings.disableSounds = oldSettings.disableSounds; newSettings.notificationSoundFileId = oldSettings.notificationSoundFileId; newSettings.columnSwitchingWinAlt = oldSettings.columnSwitchingWinAlt; + newSettings.disableRemoteStatusFetching = oldSettings.disableRemoteStatusFetching; return newSettings; }