mirror of
https://github.com/coder/coder.git
synced 2025-07-09 11:45:56 +00:00
fix: auto-stop bumper works and refreshes (#5162)
* Publish updates to workspace deadline * Fix sync between machines
This commit is contained in:
@ -784,6 +784,7 @@ func (api *API) putExtendWorkspace(rw http.ResponseWriter, r *http.Request) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
api.Logger.Info(ctx, "extending workspace", slog.Error(err))
|
api.Logger.Info(ctx, "extending workspace", slog.Error(err))
|
||||||
}
|
}
|
||||||
|
api.publishWorkspaceUpdate(ctx, workspace.ID)
|
||||||
httpapi.Write(ctx, rw, code, resp)
|
httpapi.Write(ctx, rw, code, resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { useActor, useSelector } from "@xstate/react"
|
import { useActor, useSelector } from "@xstate/react"
|
||||||
import { FeatureNames } from "api/types"
|
import { FeatureNames } from "api/types"
|
||||||
import dayjs from "dayjs"
|
import dayjs from "dayjs"
|
||||||
import { useContext } from "react"
|
import { useContext, useEffect } from "react"
|
||||||
import { Helmet } from "react-helmet-async"
|
import { Helmet } from "react-helmet-async"
|
||||||
import { useTranslation } from "react-i18next"
|
import { useTranslation } from "react-i18next"
|
||||||
import { useNavigate } from "react-router-dom"
|
import { useNavigate } from "react-router-dom"
|
||||||
@ -66,6 +66,11 @@ export const WorkspaceReadyPage = ({
|
|||||||
const favicon = getFaviconByStatus(workspace.latest_build)
|
const favicon = getFaviconByStatus(workspace.latest_build)
|
||||||
const navigate = useNavigate()
|
const navigate = useNavigate()
|
||||||
|
|
||||||
|
// keep banner machine in sync with workspace
|
||||||
|
useEffect(() => {
|
||||||
|
bannerSend({ type: "REFRESH_WORKSPACE", workspace })
|
||||||
|
}, [bannerSend, workspace])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Helmet>
|
<Helmet>
|
||||||
|
@ -473,9 +473,6 @@ export const workspaceMachine = createMachine(
|
|||||||
template: (context: WorkspaceContext) => context.template,
|
template: (context: WorkspaceContext) => context.template,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
on: {
|
|
||||||
REFRESH_WORKSPACE: { actions: "sendWorkspaceToSchedule" },
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -594,13 +591,6 @@ export const workspaceMachine = createMachine(
|
|||||||
)
|
)
|
||||||
displayError(message)
|
displayError(message)
|
||||||
},
|
},
|
||||||
sendWorkspaceToSchedule: send(
|
|
||||||
(context) => ({
|
|
||||||
type: "REFRESH_WORKSPACE",
|
|
||||||
workspace: context.workspace,
|
|
||||||
}),
|
|
||||||
{ to: "scheduleBannerMachine" },
|
|
||||||
),
|
|
||||||
// Optimistically update. So when the user clicks on stop, we can show
|
// Optimistically update. So when the user clicks on stop, we can show
|
||||||
// the "pending" state right away without having to wait 0.5s ~ 2s to
|
// the "pending" state right away without having to wait 0.5s ~ 2s to
|
||||||
// display the visual feedback to the user.
|
// display the visual feedback to the user.
|
||||||
|
Reference in New Issue
Block a user