Skip to content

Commit

Permalink
fix: Add failsafe to prevent workspace list from flashing between pro…
Browse files Browse the repository at this point in the history
…jects
  • Loading branch information
PRTTMPRPHT authored and pascalbreuninger committed Nov 20, 2024
1 parent d703f83 commit 7bf0537
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion desktop/src-tauri/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ async fn signal_handler(
AxumState(server): AxumState<ServerState>,
Json(payload): Json<SendSignalMessage>,
) -> impl IntoResponse {
info!("received request to send signa {} to process {}", payload.signal, payload.process_id.to_string());
info!("received request to send signal {} to process {}", payload.signal, payload.process_id.to_string());
#[cfg(not(windows))]
{
use nix::sys::signal::{self, kill, Signal};
Expand Down
13 changes: 12 additions & 1 deletion desktop/src/contexts/DevPodContext/Pro/ProProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,13 @@ export function ProProvider({ host, children }: { host: string; children: ReactN
}
setIsLoadingWorkspaces(true)

return client.watchWorkspaces(currentProject.metadata.name, (workspaces) => {
let canceled = false

const toCancel = client.watchWorkspaces(currentProject.metadata.name, (workspaces) => {
if (canceled) {
return
}

// sort by last activity (newest > oldest)
const sorted = workspaces.slice().sort((a, b) => {
const lastActivityA = a.metadata?.annotations?.[Annotations.SleepModeLastActivity]
Expand All @@ -70,6 +76,11 @@ export function ProProvider({ host, children }: { host: string; children: ReactN
setIsLoadingWorkspaces(false)
}, 1_000)
})

return () => {
canceled = true
toCancel()
}
}, [client, store, currentProject])

const handleProjectChanged = (newProject: ManagementV1Project) => {
Expand Down

0 comments on commit 7bf0537

Please sign in to comment.