Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Remove flickering of values due to setLoading of query

Oliver Günther26014cda504c
diff --git a/frontend/src/app/features/user-preferences/reminder-settings/page/reminder-settings-page.component.html b/frontend/src/app/features/user-preferences/reminder-settings/page/reminder-settings-page.component.html
index a4988c667ca..feca58b534e 100644
--- a/frontend/src/app/features/user-preferences/reminder-settings/page/reminder-settings-page.component.html
+++ b/frontend/src/app/features/user-preferences/reminder-settings/page/reminder-settings-page.component.html
@@ -24,10 +24,11 @@
<p [textContent]="text.alerts.explanation"></p>
<op-email-alerts-settings></op-email-alerts-settings>
</section>
- <div class="form--space"></div>
- <button
- class="button -highlight"
- [textContent]="text.save"
- type="submit"
- ></button>
+ <div class="form--space">
+ <button
+ class="button -highlight"
+ [textContent]="text.save"
+ type="submit"
+ ></button>
+ </div>
</form>
diff --git a/frontend/src/app/features/user-preferences/reminder-settings/page/reminder-settings-page.component.ts b/frontend/src/app/features/user-preferences/reminder-settings/page/reminder-settings-page.component.ts
index 8a6e57097bc..8f3ad56b266 100644
--- a/frontend/src/app/features/user-preferences/reminder-settings/page/reminder-settings-page.component.ts
+++ b/frontend/src/app/features/user-preferences/reminder-settings/page/reminder-settings-page.component.ts
@@ -24,9 +24,11 @@ import {
} from 'core-app/features/user-preferences/reminder-settings/email-alerts/email-alerts-settings.component';
import { UntilDestroyedMixin } from 'core-app/shared/helpers/angular/until-destroyed.mixin';
import {
+ distinctUntilChanged,
filter,
withLatestFrom,
} from 'rxjs/operators';
+import { filterObservable } from 'core-app/shared/helpers/rxjs/filterWith';
export const myReminderPageComponentSelector = 'op-reminders-page';
@@ -110,6 +112,7 @@ export class ReminderSettingsPageComponent extends UntilDestroyedMixin implement
.pipe(
filter((settings) => !!settings),
withLatestFrom(this.storeService.query.globalNotification$),
+ filterObservable(this.storeService.query.selectLoading(), (val) => !val),
)
.subscribe(([settings, globalSetting]) => {
this.form.get('immediateReminders.mentioned')?.setValue(settings.immediateReminders.mentioned);
diff --git a/frontend/src/app/shared/helpers/rxjs/filterWith.ts b/frontend/src/app/shared/helpers/rxjs/filterWith.ts
new file mode 100644
index 00000000000..64944859646
--- /dev/null
+++ b/frontend/src/app/shared/helpers/rxjs/filterWith.ts
@@ -0,0 +1,27 @@
+import {
+ filter,
+ map,
+ withLatestFrom,
+} from 'rxjs/operators';
+import { Observable } from 'rxjs';
+
+/**
+ * Filter emissions from the source observable
+ * using values from another observable.
+ *
+ * Applies the given filter function and maps to the original observable.
+ *
+ * @param other$ Other observable to observe values
+ * @param filterFn Filter to apply to values of other$
+ */
+export function filterObservable<T, V>(
+ other$:Observable<V>,
+ filterFn:(val:V) => boolean,
+):(source$:Observable<T>) => Observable<T> {
+ return (source$) => source$
+ .pipe(
+ withLatestFrom(other$),
+ filter(([, val]) => filterFn(val)),
+ map(([source]) => source),
+ );
+}