msyavuz commented on code in PR #36486:
URL: https://github.com/apache/superset/pull/36486#discussion_r2665442738


##########
superset-frontend/packages/superset-ui-core/src/components/TimezoneSelector/index.tsx:
##########
@@ -45,118 +60,142 @@ const offsetsToName = {
   '060': ['GMT Standard Time - London', 'British Summer Time'],
 };
 
-export type TimezoneSelectorProps = {
-  onTimezoneChange: (value: string) => void;
-  timezone?: string | null;
-  minWidth?: string;
-};
+function getOffsetKey(timezoneName: string): string {
+  return (
+    JANUARY_REF.tz(timezoneName).utcOffset().toString() +
+    JULY_REF.tz(timezoneName).utcOffset().toString()
+  );
+}
+
+const timezoneCache = new TimezoneOptionsCache(getOffsetKey, offsetsToName);
+
+// Export function to check if options are cached (for parent components)
+export function areTimezoneOptionsCached(): boolean {
+  return timezoneCache.isCached();
+}
+
+function getTimezoneOptionsAsync(): Promise<TimezoneOption[]> {
+  return timezoneCache.getOptionsAsync();
+}

Review Comment:
   - Encapsulation is already broken - If you're exporting 
areTimezoneOptionsCached(), you're already coupling external code to the 
existence of a cache. The "encapsulation" benefit is minimal.
   
   - Principle of least privilege is misapplied here as it doesn't relate to 
API design but security. 
   
   I think the best course of action here is to just create and export a 
singleton from the cache file and use it.



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to