mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Save update available date in session storage
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
parent
b60893c35a
commit
91edfc7206
@ -13,7 +13,7 @@ interface Dependencies {
|
||||
|
||||
export class AppUpdateWarning extends Singleton {
|
||||
@observable warningLevel: "high" | "medium" | "light" | "" = "";
|
||||
@observable private updateAvailableDate: Date | null = null;
|
||||
@observable private updateAvailableDate: Date | null = this.getDateFromSessionStorage();
|
||||
private interval: NodeJS.Timeout | null = null;
|
||||
|
||||
constructor(dependencies: Dependencies) {
|
||||
@ -27,9 +27,28 @@ export class AppUpdateWarning extends Singleton {
|
||||
});
|
||||
}
|
||||
|
||||
saveDateToSessionStorage() {
|
||||
if (this.updateAvailableDate) {
|
||||
window.sessionStorage.setItem("when-update-available", this.updateAvailableDate.toISOString());
|
||||
}
|
||||
}
|
||||
|
||||
getDateFromSessionStorage() {
|
||||
const value = window.sessionStorage.getItem("when-update-available");
|
||||
|
||||
if (!value) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const date = new Date(value);
|
||||
|
||||
return isNaN(date.getTime()) ? null : date;
|
||||
}
|
||||
|
||||
setUpdateAvailableDate() {
|
||||
if (!this.updateAvailableDate) {
|
||||
this.updateAvailableDate = new Date();
|
||||
this.saveDateToSessionStorage();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user