mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-12-28 10:59:46 +08:00
added a last seen version tracker
showing notification when new version is released
This commit is contained in:
parent
d1f7f95059
commit
fa7ad4581e
5 changed files with 42 additions and 4 deletions
|
|
@ -127,6 +127,7 @@ const refactoredSrc = [
|
|||
"./src/js/elements/sign-out-button.js",
|
||||
"./src/js/elements/about-page.js",
|
||||
"./src/js/elements/psa.js",
|
||||
"./src/js/elements/new-version-notification.js",
|
||||
|
||||
"./src/js/popups/custom-text-popup.js",
|
||||
"./src/js/popups/quote-search-popup.js",
|
||||
|
|
|
|||
30
src/js/elements/new-version-notification.js
Normal file
30
src/js/elements/new-version-notification.js
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
import * as Notifications from "./notifications";
|
||||
import * as VersionPopup from "./version-popup";
|
||||
|
||||
export async function show(version) {
|
||||
const memory = await getMemory();
|
||||
if (memory === "") {
|
||||
setMemory(version);
|
||||
return;
|
||||
}
|
||||
if (memory === version) return;
|
||||
Notifications.add(
|
||||
`Version ${version} has been released. Click to view the changelog.`,
|
||||
1,
|
||||
7,
|
||||
"Announcement",
|
||||
"code-branch",
|
||||
() => {
|
||||
VersionPopup.show();
|
||||
}
|
||||
);
|
||||
setMemory(version);
|
||||
}
|
||||
|
||||
function setMemory(v) {
|
||||
window.localStorage.setItem("lastSeenVersion", v);
|
||||
}
|
||||
|
||||
function getMemory() {
|
||||
return window.localStorage.getItem("lastSeenVersion") ?? "";
|
||||
}
|
||||
|
|
@ -384,8 +384,8 @@ export function median(arr) {
|
|||
}
|
||||
}
|
||||
|
||||
export function getReleasesFromGitHub() {
|
||||
$.getJSON(
|
||||
export async function getReleasesFromGitHub() {
|
||||
return $.getJSON(
|
||||
"https://api.github.com/repos/Miodec/monkeytype/releases",
|
||||
(data) => {
|
||||
$("#bottom .version .text").text(data[0].name);
|
||||
|
|
|
|||
|
|
@ -1,8 +1,12 @@
|
|||
$(document.body).on("click", ".version", () => {
|
||||
export function show() {
|
||||
$("#versionHistoryWrapper")
|
||||
.css("opacity", 0)
|
||||
.removeClass("hidden")
|
||||
.animate({ opacity: 1 }, 125);
|
||||
}
|
||||
|
||||
$(document.body).on("click", ".version", () => {
|
||||
show();
|
||||
});
|
||||
|
||||
$(document.body).on("click", "#versionHistoryWrapper", () => {
|
||||
|
|
|
|||
|
|
@ -7,11 +7,14 @@ import * as RouteController from "./route-controller";
|
|||
import * as UI from "./ui";
|
||||
import * as SignOutButton from "./sign-out-button";
|
||||
import * as MonkeyPower from "./monkey-power";
|
||||
import * as NewVersionNotification from "./new-version-notification";
|
||||
|
||||
ManualRestart.set();
|
||||
Misc.migrateFromCookies();
|
||||
UpdateConfig.loadFromLocalStorage();
|
||||
Misc.getReleasesFromGitHub();
|
||||
Misc.getReleasesFromGitHub().then((v) => {
|
||||
NewVersionNotification.show(v[0].name);
|
||||
});
|
||||
|
||||
RouteController.handleInitialPageClasses(window.location.pathname);
|
||||
$(document).ready(() => {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue