xuang7 commented on code in PR #6116:
URL: https://github.com/apache/texera/pull/6116#discussion_r3524140700


##########
frontend/src/app/dashboard/service/admin/settings/admin-settings.service.ts:
##########
@@ -31,9 +31,29 @@ import { map } from "rxjs/operators";
   providedIn: "root",
 })
 export class AdminSettingsService {
-  private readonly BASE_URL = "/api/admin/settings";
+  private readonly BASE_URL = "/api/config/settings";
+
+  // One request for all user-visible settings, shared by every consumer.
+  // The admin settings page reloads the whole window after saving, so a
+  // per-page-load cache never serves stale values.
+  private publicSettings$?: Observable<Record<string, string>>;
+
   constructor(private http: HttpClient) {}
 
+  /**
+   * Reads one of the user-visible settings (branding, sidebar tabs, upload
+   * limits) through the aggregated REGULAR-accessible endpoint.
+   */
+  getPublicSetting(key: string): Observable<string> {
+    if (!this.publicSettings$) {
+      this.publicSettings$ = this.http.get<Record<string, 
string>>(`${this.BASE_URL}/public`).pipe(shareReplay(1));
+    }
+    return this.publicSettings$.pipe(map(settings => settings[key] ?? null));

Review Comment:
   `getPublicSetting` does not currently handle errors, and `shareReplay(1)` 
may cache the error. If the first `/settings/public` fetch fails, the error 
could be replayed to every consumer with no retry.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to