Skip to content
Draft
Changes from 5 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
20 changes: 19 additions & 1 deletion src/lib/components/breadcrumbs.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
let isLoadingProjects = false;
let loadedProjects: Models.ProjectList = { total: 0, projects: [] };
let wasOnProjectPage = false;
export let organizations: Organization[] = [];
export let currentProject: Models.Project | null = null;
Expand Down Expand Up @@ -241,10 +242,27 @@
$: organizationId = currentProject?.teamId;
// Invalidate cache when navigating from non-project page back to project page
// This handles cases like project deletion where user is redirected to org page
$: {
const isOnProjectPage = !!currentProject;
const hasNavigatedBackToProjects =
isOnProjectPage && !wasOnProjectPage && loadedProjects.projects.length > 0;
if (hasNavigatedBackToProjects) {
// Clear cache to force reload after being away from project pages
loadedProjects = { total: 0, projects: [] };
}
wasOnProjectPage = isOnProjectPage;
}
$: shouldReloadProjects = isLoadingProjects
? false
: currentProject && loadedProjects.projects.length
? loadedProjects.projects[0].teamId != currentProject.teamId
? // All projects in cache belong to same org, so check first project's teamId
loadedProjects.projects[0].teamId != currentProject.teamId ||
!loadedProjects.projects.some((p) => p.$id === currentProject.$id)
: !loadedProjects.projects.length;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot this seems quite complicated. to detect if a project was deleted or created, can we just use the allProjectsCount?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simplified in 2c721bf. Now using page.data.allProjectsCount to detect project creation/deletion by comparing it with the cached total. Removed the complex navigation tracking logic entirely.

$: if (shouldReloadProjects) {
Expand Down