Skip to content

Commit

Permalink
Add check for latest version
Browse files Browse the repository at this point in the history
Shows a message if the version of cheesecake is outdated
  • Loading branch information
cubetastic33 committed Sep 23, 2021
1 parent 27918b1 commit d67415d
Show file tree
Hide file tree
Showing 9 changed files with 366 additions and 335 deletions.
7 changes: 6 additions & 1 deletion src/static_include.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,16 @@ struct Assets;
pub fn static_file<'r>(file: PathBuf) -> Result<(ContentType, Cow<'static, [u8]>), Status> {
let filename = file.display().to_string();
let d = Assets::get(&filename).ok_or(Status::NotFound)?;
let ext = file
let mut ext = file
.as_path()
.extension()
.and_then(OsStr::to_str)
.ok_or(Status::InternalServerError)?;
// ContentType::from_extension normally returns None for map files, but they should be sent with
// the JSON mimetype
if ext == "map" {
ext = "json"
}
let content_type = ContentType::from_extension(ext).ok_or(Status::InternalServerError)?;
Ok((content_type, d.data))
}
129 changes: 67 additions & 62 deletions static/scripts/main.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion static/scripts/main.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions static/scripts/main.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
declare const version;
declare const initial_chats;
declare let chats;

// Check if cheesecake is up to date
$.getJSON("https://api.github.com/repos/cubetastic33/cheesecake/releases/latest", result => {
if (result["tag_name"] !== version) {
$("#outdated").show();
}
});

let $backup = $("#backup");

function show_toast(message, duration = 2000) {
Expand Down
Loading

0 comments on commit d67415d

Please sign in to comment.