Skip to content

Commit d690500

Browse files
Copilothotlong
andcommitted
fix: address code review feedback — type safety, deps, unused import
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent 611ffba commit d690500

5 files changed

Lines changed: 17 additions & 16 deletions

File tree

apps/console/src/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ export function AppContent() {
150150
type: 'report',
151151
});
152152
}
153-
}, [location.pathname]); // eslint-disable-line react-hooks/exhaustive-deps
153+
}, [location.pathname, activeApp, allObjects, objectNameFromPath, cleanParts, addRecentItem]);
154154

155155
const handleEdit = (record: any) => {
156156
setEditingRecord(record);

apps/console/src/__tests__/SkeletonComponents.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Tests for skeleton loading components
33
*/
44
import { describe, it, expect } from 'vitest';
5-
import { render, screen } from '@testing-library/react';
5+
import { render } from '@testing-library/react';
66
import '@testing-library/jest-dom';
77
import { SkeletonGrid } from '../components/skeletons/SkeletonGrid';
88
import { SkeletonDashboard } from '../components/skeletons/SkeletonDashboard';

apps/console/src/components/DashboardView.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@ export function DashboardView({ dataSource }: { dataSource?: any }) {
1818
const [isLoading, setIsLoading] = useState(true);
1919

2020
useEffect(() => {
21-
// Simulate initial data load; real implementation would await dataSource readiness
22-
const timer = setTimeout(() => setIsLoading(false), 0);
23-
return () => clearTimeout(timer);
21+
// Reset loading on navigation; the actual DashboardRenderer handles data fetching
22+
setIsLoading(true);
23+
// Use microtask to let React render the skeleton before the heavy dashboard
24+
queueMicrotask(() => setIsLoading(false));
2425
}, [dashboardName]);
2526

2627
// Find dashboard definition in config

apps/console/src/components/RecordDetailView.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ export function RecordDetailView({ dataSource, objects, onEdit }: RecordDetailVi
2727
const objectDef = objects.find((o: any) => o.name === objectName);
2828

2929
useEffect(() => {
30+
// Reset loading on navigation; the actual DetailView handles data fetching
3031
setIsLoading(true);
31-
const timer = setTimeout(() => setIsLoading(false), 0);
32-
return () => clearTimeout(timer);
32+
queueMicrotask(() => setIsLoading(false));
3333
}, [objectName, recordId]);
3434

3535
if (isLoading) {

packages/data-objectstack/src/index.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ export class ObjectStackAdapter<T = unknown> implements DataSource<T> {
9696
private maxReconnectAttempts: number;
9797
private reconnectDelay: number;
9898
private reconnectAttempts: number = 0;
99+
private baseUrl: string;
100+
private token?: string;
99101

100102
constructor(config: {
101103
baseUrl: string;
@@ -114,6 +116,8 @@ export class ObjectStackAdapter<T = unknown> implements DataSource<T> {
114116
this.autoReconnect = config.autoReconnect ?? true;
115117
this.maxReconnectAttempts = config.maxReconnectAttempts ?? 3;
116118
this.reconnectDelay = config.reconnectDelay ?? 1000;
119+
this.baseUrl = config.baseUrl;
120+
this.token = config.token;
117121
}
118122

119123
/**
@@ -720,8 +724,7 @@ export class ObjectStackAdapter<T = unknown> implements DataSource<T> {
720724
formData.append('metadata', JSON.stringify(options.metadata));
721725
}
722726

723-
const baseUrl = (this.client as any).baseUrl || '';
724-
const url = `${baseUrl}/api/data/${encodeURIComponent(resource)}/upload`;
727+
const url = `${this.baseUrl}/api/data/${encodeURIComponent(resource)}/upload`;
725728

726729
const response = await fetch(url, {
727730
method: 'POST',
@@ -779,8 +782,7 @@ export class ObjectStackAdapter<T = unknown> implements DataSource<T> {
779782
formData.append('metadata', JSON.stringify(options.metadata));
780783
}
781784

782-
const baseUrl = (this.client as any).baseUrl || '';
783-
const url = `${baseUrl}/api/data/${encodeURIComponent(resource)}/upload`;
785+
const url = `${this.baseUrl}/api/data/${encodeURIComponent(resource)}/upload`;
784786

785787
const response = await fetch(url, {
786788
method: 'POST',
@@ -803,14 +805,12 @@ export class ObjectStackAdapter<T = unknown> implements DataSource<T> {
803805
}
804806

805807
/**
806-
* Get authorization headers from the underlying client (if any).
808+
* Get authorization headers from the adapter config.
807809
*/
808810
private getAuthHeaders(): Record<string, string> {
809811
const headers: Record<string, string> = {};
810-
// Access token from client config if available
811-
const token = (this.client as any).token || (this.client as any).config?.token;
812-
if (token) {
813-
headers['Authorization'] = `Bearer ${token}`;
812+
if (this.token) {
813+
headers['Authorization'] = `Bearer ${this.token}`;
814814
}
815815
return headers;
816816
}

0 commit comments

Comments
 (0)