Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion hooks/useCreateOrganization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const useCreateOrganization = () => {
if (response.ok) {
const data = await response.json();
// Invalidate the organizations query to refetch
await queryClient.invalidateQueries({ queryKey: ["userOrganizations"] });
await queryClient.invalidateQueries({ queryKey: ["accountOrganizations"] });
// Select the new org
setSelectedOrgId(data.organization.id);
// Reset and close
Expand Down
14 changes: 10 additions & 4 deletions hooks/useInitialArtists.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,12 @@ const useInitialArtists = (
useEffect(() => {
const savedArtist = selections[orgKey];
if (savedArtist && Object.keys(savedArtist).length > 0) {
setSelectedArtist(savedArtist);
// Only update if the saved artist differs from current selection
if (savedArtist.account_id !== selectedArtist?.account_id) {
setSelectedArtist(savedArtist);
}
}
}, [orgKey, selections, setSelectedArtist]);
}, [orgKey, selections, selectedArtist?.account_id, setSelectedArtist]);

// Update selected artist with fresh data from artists list
useEffect(() => {
Expand All @@ -41,10 +44,13 @@ const useInitialArtists = (
(artist: ArtistRecord) =>
artist.account_id === selectedArtist.account_id,
);
if (currentArtist && !selectedArtist?.isWrapped)
if (currentArtist && !selectedArtist?.isWrapped) {
setSelectedArtist(currentArtist);
// Persist fresh data to localStorage so page reload shows updated image
saveSelection(currentArtist);
}
}
}, [artists, selectedArtist, setSelectedArtist]);
}, [artists, selectedArtist, setSelectedArtist, saveSelection]);

const handleSelectArtist = (artist: ArtistRecord | null) => {
setSelectedArtist(artist);
Expand Down
6 changes: 5 additions & 1 deletion hooks/useOrgSettings.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useState, useEffect, useRef, useCallback } from "react";
import { useQueryClient } from "@tanstack/react-query";
import { uploadFile } from "@/lib/arweave/uploadFile";
import { getFileMimeType } from "@/utils/getFileMimeType";
import { NEW_API_BASE_URL } from "@/lib/consts";
Expand All @@ -20,6 +21,7 @@ interface OrgData {

const useOrgSettings = (orgId: string | null) => {
const { data: organizations } = useAccountOrganizations();
const queryClient = useQueryClient();
const [orgData, setOrgData] = useState<OrgData | null>(null);
const [name, setName] = useState("");
const [image, setImage] = useState("");
Expand Down Expand Up @@ -154,13 +156,15 @@ const useOrgSettings = (orgId: string | null) => {
if (response.ok) {
const data = await response.json();
setOrgData(data.data);
// Invalidate org list cache so sidebar shows updated image/name immediately
await queryClient.invalidateQueries({ queryKey: ["accountOrganizations"] });
return true;
}
return false;
} finally {
setIsSaving(false);
}
}, [orgId, name, image, instruction, knowledges]);
}, [orgId, name, image, instruction, knowledges, queryClient]);

return {
orgData,
Expand Down
Loading