This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/initializers/asset-version.js.es6
Sam fd9056973a FEATURE: increase interval to 24 hours for "please refresh site"
Used to be 2 hours, which is a bit tight, especially for people who leave
computer running overnight.

Keep in mind we always refresh on route change, so clicking on a topic will
trigger a refresh
2016-09-19 10:12:27 +10:00

28 lines
860 B
JavaScript

// Subscribe to "asset-version" change events via the Message Bus
export default {
name: "asset-version",
after: "message-bus",
initialize(container) {
let timeoutIsSet = false;
const messageBus = container.lookup('message-bus:main');
if (!messageBus) { return; }
messageBus.subscribe("/global/asset-version", function (version) {
Discourse.set("assetVersion", version);
if (!timeoutIsSet && Discourse.get("requiresRefresh")) {
// Since we can do this transparently for people browsing the forum
// hold back the message 24 hours.
setTimeout(function () {
bootbox.confirm(I18n.lookup("assets_changed_confirm"), function (result) {
if (result) { document.location.reload(); }
});
}, 1000 * 60 * 24 * 60);
timeoutIsSet = true;
}
});
}
};