-
Notifications
You must be signed in to change notification settings - Fork 269
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6b092c9
commit bd7eb52
Showing
7 changed files
with
170 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
import { useNavigate } from "@solidjs/router"; | ||
import { check } from "@tauri-apps/plugin-updater"; | ||
import { | ||
createResource, | ||
createSignal, | ||
Match, | ||
onMount, | ||
Show, | ||
Switch, | ||
} from "solid-js"; | ||
import * as dialog from "@tauri-apps/plugin-dialog"; | ||
import { relaunch } from "@tauri-apps/plugin-process"; | ||
import { Button } from "@cap/ui-solid"; | ||
|
||
export default function () { | ||
const navigate = useNavigate(); | ||
|
||
const [update] = createResource(async () => { | ||
const update = await check(); | ||
if (!update) return; | ||
|
||
return update; | ||
}); | ||
|
||
return ( | ||
<div class="flex flex-col justify-center flex-1 items-center gap-[3rem] p-[1rem] text-[0.875rem] font-[400] h-full"> | ||
<Show when={update()} fallback="No update available" keyed> | ||
{(update) => { | ||
type UpdateStatus = | ||
| { type: "downloading"; progress: number; contentLength?: number } | ||
| { type: "done" }; | ||
|
||
const [updateStatus, updateStatusActions] = | ||
createResource<UpdateStatus>( | ||
() => | ||
new Promise<UpdateStatus>((resolve) => { | ||
update | ||
.downloadAndInstall((e) => { | ||
if (e.event === "Started") { | ||
resolve({ | ||
type: "downloading", | ||
progress: 0, | ||
contentLength: e.data.contentLength, | ||
}); | ||
} else if (e.event === "Progress") { | ||
const status = updateStatus(); | ||
if ( | ||
!status || | ||
status.type !== "downloading" || | ||
status.contentLength === undefined | ||
) | ||
return; | ||
updateStatusActions.mutate({ | ||
...status, | ||
progress: e.data.chunkLength + status.progress, | ||
}); | ||
} | ||
}) | ||
.then(async () => { | ||
updateStatusActions.mutate({ type: "done" }); | ||
}) | ||
.catch(() => navigate("/")); | ||
}) | ||
); | ||
|
||
return ( | ||
<div> | ||
<Switch fallback={<IconCapLogo class="animate-spin size-4" />}> | ||
<Match when={updateStatus()?.type === "done"}> | ||
Update has been installed. Restart Cap to finish updating. | ||
<div class="flex flex-row gap-4"> | ||
<Button variant="secondary" onClick={() => navigate("/")}> | ||
Restart Later | ||
</Button> | ||
<Button onClick={() => relaunch()}>Restart Now</Button> | ||
</div> | ||
</Match> | ||
<Match | ||
when={(() => { | ||
const s = updateStatus(); | ||
if ( | ||
s && | ||
s.type === "downloading" && | ||
s.contentLength !== undefined | ||
) | ||
return s; | ||
})()} | ||
> | ||
{(status) => ( | ||
<> | ||
<h1>Installing Update</h1> | ||
|
||
<div class="w-full bg-gray-200 rounded-full h-2.5"> | ||
<div | ||
class="bg-blue-300 h-2.5 rounded-full" | ||
style={{ | ||
width: `${Math.min( | ||
((status()?.progress ?? 0) / | ||
(status()?.contentLength ?? 0)) * | ||
100, | ||
100 | ||
)}%`, | ||
}} | ||
/> | ||
</div> | ||
</> | ||
)} | ||
</Match> | ||
</Switch> | ||
</div> | ||
); | ||
}} | ||
</Show> | ||
</div> | ||
); | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
bd7eb52
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
cap-web – ./
cap-web-mc-ilroy.vercel.app
cap-web-git-main-mc-ilroy.vercel.app
cap-web-nu.vercel.app
www.cap.so
cap.so