Skip to content
Merged
Changes from all 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
39 changes: 26 additions & 13 deletions src_assets/common/assets/web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ <h2>Version {{version}}</h2>
<div v-if="loading">
Loading Latest Release...
</div>
<div v-else-if="!hasNewNightly && !hasNewStable">
<div v-else-if="!nightlyBuildAvailable && !stableBuildAvailable">
<div class="alert alert-success">
You're running the latest version of Sunshine
</div>
</div>
<div v-if="hasNewNightly">
<div v-if="nightlyBuildAvailable">
<div class="alert alert-warning">
<div class="d-flex justify-content-between">
<div class="my-2">A new <b>Nightly</b> Version is Available!</div>
Expand All @@ -27,7 +27,7 @@ <h2>Version {{version}}</h2>
<pre>{{nightlyData.display_title}}</pre>
</div>
</div>
<div v-if="hasNewStable">
<div v-if="stableBuildAvailable">
<div class="alert alert-warning">
<div class="d-flex justify-content-between">
<div class="my-2">A new <b>Stable</b> Version is Available!</div>
Expand Down Expand Up @@ -89,16 +89,15 @@ <h2>Legal</h2>
try {
this.version = (await fetch("/api/config").then((r) => r.json())).version;
this.githubVersion = (await fetch("https://api.github.com/repos/LizardByte/Sunshine/releases/latest").then((r) => r.json()));
if (this.version.split("-g").length > 1) {
if (this.buildVersionIsNightly()) {
this.nightlyData = (await fetch("https://api.github.com/repos/LizardByte/Sunshine/actions/workflows/CI.yml/runs?branch=nightly&status=success&per_page=1").then((r) => r.json())).workflow_runs[0];
}
} catch(e){
}
this.loading = false;
},
computed: {
// Check for new stable version
hasNewStable() {
stableBuildAvailable() {
// If we can't get versions, return false
if (!this.githubVersion || !this.version) return false;
// If built with dirty git tree, return false
Expand All @@ -107,21 +106,35 @@ <h2>Legal</h2>
let v = this.githubVersion.name;
// If the version starts with a v, remove it
if (v.indexOf("v") === 0) v = v.substring(1);

// if nightly, we do an additional check to make sure its an actual upgrade.
if (this.buildVersionIsNightly()) {
const stableVersion = this.version.split('.').slice(0, 3).join('.');
return this.githubVersion.tag_name.substring(1) > stableVersion;
}

// return true if the version is different, otherwise false
return v !== this.version.split(".")[0];
},
// Check for new nightly version
hasNewNightly() {
// If we're not on a nightly build, just return false
// If length of version split is 3, we're on a stable build
if (!this.version || !this.nightlyData || this.version.split(".").length === 3) return false;
nightlyBuildAvailable() {
// Verify nightly data is available and the build version is not stable
// This is important to ensure the UI does not try to load undefined values.
if (!this.nightlyData || this.buildVersionIsStable()) return false;
// If built with dirty git tree, return false
if (this.version.indexOf("dirty") !== -1) return false;
if (this.version?.indexOf("dirty") !== -1) return false;
// Get the commit hash
let commit = this.version.split(".")[-1];
let commit = this.version?.split(".").pop();
// return true if the commit hash is different, otherwise false
return this.nightlyData.head_sha.indexOf(commit) !== 0;
}
},
methods: {
buildVersionIsStable() {
return this.version?.split(".").length === 3;
},
buildVersionIsNightly() {
return this.version?.split(".").length === 4
}
}
});
</script>