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