gem3 flash lint fix
This commit is contained in:
@@ -43,11 +43,15 @@ export function useProfile() {
|
||||
.then((data) => {
|
||||
profileCache = data;
|
||||
profileError = null;
|
||||
subscribers.forEach((sub) => sub(data, null));
|
||||
subscribers.forEach((sub) => {
|
||||
sub(data, null);
|
||||
});
|
||||
})
|
||||
.catch((err) => {
|
||||
profileError = err instanceof Error ? err : new Error(String(err));
|
||||
subscribers.forEach((sub) => sub(profileCache, profileError));
|
||||
subscribers.forEach((sub) => {
|
||||
sub(profileCache, profileError);
|
||||
});
|
||||
})
|
||||
.finally(() => {
|
||||
isFetching = false;
|
||||
@@ -62,17 +66,23 @@ export function useProfile() {
|
||||
const refreshProfile = async () => {
|
||||
isFetching = true;
|
||||
profileError = null;
|
||||
subscribers.forEach((sub) => sub(profileCache, null));
|
||||
subscribers.forEach((sub) => {
|
||||
sub(profileCache, null);
|
||||
});
|
||||
|
||||
try {
|
||||
const data = await api.getProfile();
|
||||
profileCache = data;
|
||||
profileError = null;
|
||||
subscribers.forEach((sub) => sub(data, null));
|
||||
subscribers.forEach((sub) => {
|
||||
sub(data, null);
|
||||
});
|
||||
return data;
|
||||
} catch (err) {
|
||||
profileError = err instanceof Error ? err : new Error(String(err));
|
||||
subscribers.forEach((sub) => sub(profileCache, profileError));
|
||||
subscribers.forEach((sub) => {
|
||||
sub(profileCache, profileError);
|
||||
});
|
||||
throw profileError;
|
||||
} finally {
|
||||
isFetching = false;
|
||||
|
||||
@@ -15,7 +15,7 @@ describe("useSettings", () => {
|
||||
|
||||
it("fetches settings on mount if not already cached", async () => {
|
||||
const mockSettings = { showSponsorInfo: false };
|
||||
(api.getSettings as any).mockResolvedValue(mockSettings);
|
||||
vi.mocked(api.getSettings).mockResolvedValue(mockSettings as any);
|
||||
|
||||
const { result } = renderHook(() => useSettings());
|
||||
|
||||
@@ -31,7 +31,7 @@ describe("useSettings", () => {
|
||||
});
|
||||
|
||||
it("uses default values when settings are null", async () => {
|
||||
(api.getSettings as any).mockResolvedValue(null);
|
||||
vi.mocked(api.getSettings).mockResolvedValue(null as any);
|
||||
|
||||
const { result } = renderHook(() => useSettings());
|
||||
|
||||
@@ -45,8 +45,8 @@ describe("useSettings", () => {
|
||||
const initialSettings = { showSponsorInfo: true };
|
||||
const updatedSettings = { showSponsorInfo: false };
|
||||
|
||||
(api.getSettings as any).mockResolvedValueOnce(initialSettings);
|
||||
(api.getSettings as any).mockResolvedValueOnce(updatedSettings);
|
||||
vi.mocked(api.getSettings).mockResolvedValueOnce(initialSettings as any);
|
||||
vi.mocked(api.getSettings).mockResolvedValueOnce(updatedSettings as any);
|
||||
|
||||
const { result } = renderHook(() => useSettings());
|
||||
|
||||
@@ -54,7 +54,7 @@ describe("useSettings", () => {
|
||||
expect(result.current.settings).toEqual(initialSettings);
|
||||
});
|
||||
|
||||
let refreshed;
|
||||
let refreshed: any;
|
||||
await waitFor(async () => {
|
||||
refreshed = await result.current.refreshSettings();
|
||||
});
|
||||
@@ -66,7 +66,7 @@ describe("useSettings", () => {
|
||||
|
||||
it("handles errors when fetching settings", async () => {
|
||||
const mockError = new Error("Failed to fetch");
|
||||
(api.getSettings as any).mockRejectedValue(mockError);
|
||||
vi.mocked(api.getSettings).mockRejectedValue(mockError);
|
||||
|
||||
const { result } = renderHook(() => useSettings());
|
||||
|
||||
|
||||
@@ -39,11 +39,15 @@ export function useSettings() {
|
||||
.then((data) => {
|
||||
settingsCache = data;
|
||||
settingsError = null;
|
||||
subscribers.forEach((sub) => sub(data, null));
|
||||
subscribers.forEach((sub) => {
|
||||
sub(data, null);
|
||||
});
|
||||
})
|
||||
.catch((err) => {
|
||||
settingsError = err instanceof Error ? err : new Error(String(err));
|
||||
subscribers.forEach((sub) => sub(settingsCache, settingsError));
|
||||
subscribers.forEach((sub) => {
|
||||
sub(settingsCache, settingsError);
|
||||
});
|
||||
})
|
||||
.finally(() => {
|
||||
isFetching = false;
|
||||
@@ -58,17 +62,23 @@ export function useSettings() {
|
||||
const refreshSettings = async () => {
|
||||
isFetching = true;
|
||||
settingsError = null;
|
||||
subscribers.forEach((sub) => sub(settingsCache, null));
|
||||
subscribers.forEach((sub) => {
|
||||
sub(settingsCache, null);
|
||||
});
|
||||
|
||||
try {
|
||||
const data = await api.getSettings();
|
||||
settingsCache = data;
|
||||
settingsError = null;
|
||||
subscribers.forEach((sub) => sub(data, null));
|
||||
subscribers.forEach((sub) => {
|
||||
sub(data, null);
|
||||
});
|
||||
return data;
|
||||
} catch (err) {
|
||||
settingsError = err instanceof Error ? err : new Error(String(err));
|
||||
subscribers.forEach((sub) => sub(settingsCache, settingsError));
|
||||
subscribers.forEach((sub) => {
|
||||
sub(settingsCache, settingsError);
|
||||
});
|
||||
throw settingsError;
|
||||
} finally {
|
||||
isFetching = false;
|
||||
|
||||
Reference in New Issue
Block a user