Skip to content

Commit

Permalink
Use a single property in Local Storage instead of many
Browse files Browse the repository at this point in the history
  • Loading branch information
CertainPerformance committed May 1, 2020
1 parent 5a04d3e commit 0164d31
Show file tree
Hide file tree
Showing 3 changed files with 203 additions and 179 deletions.
12 changes: 7 additions & 5 deletions src/.modules/autoupdater.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,23 +53,25 @@ function updateCheck(notifier) {
// - called at the end of the main script if function exists
function CheckForNewVersion(popup) {
var today = (new Date().setHours(0, 0, 0, 0));
var LastUpdateCheckDay = GetStorage("LastUpdateCheckDay");
if (LastUpdateCheckDay == null) { //first time visitor
var LastUpdateCheckDay = settings.lastUpdateCheckDay;
if (LastUpdateCheckDay === 0) { //first time visitor
ShowMessage(popup, "Please read this!", 'Thanks for installing this script. \
Please note that you can EDIT the texts inline by double-clicking them. \
For other options, please see the README at <a href="https://github.com/Benjol/SE-AutoReviewComments" target="_blank">here</a>.',
function() {});
} else if (LastUpdateCheckDay != today) {
updateCheck(function(newver, oldver, install_url) {
if (newver != GetStorage("LastVersionAcknowledged")) {
if (newver !== settings.lastVersionAcknowledged) {
ShowMessage(popup, "New Version!", 'A new version (' + newver + ') of the <a href="http://stackapps.com/q/2116">AutoReviewComments</a> userscript is now available, see the <a href="https://github.com/Benjol/SE-AutoReviewComments/releases">release notes</a> for details or <a href="' + install_url + '">click here</a> to install now.',
function() {
SetStorage("LastVersionAcknowledged", newver);
settings.lastVersionAcknowledged = newver;
saveSettings();
});
}
});
}
SetStorage("LastUpdateCheckDay", today);
settings.lastUpdateCheckDay = today;
saveSettings();
}

/* How does this work?
Expand Down
8 changes: 4 additions & 4 deletions src/.templates/option.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<li>
<input id="comment-$ID$" type="radio" name="commentreview" />
<label for="comment-$ID$">
<span id="name-$ID$" class="action-name">$NAME$</span>
<span id="desc-$ID$" class="action-desc">$DESCRIPTION$</span>
<label>
<input type="radio" name="commentreview">
<span class="action-name">$NAME$</span>
<span class="action-desc">$DESCRIPTION$</span>
<button class="quick-insert" title="Insert now"></button>
</label>
</li>
Loading

0 comments on commit 0164d31

Please sign in to comment.