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/1_init_message_bus.js
Sam a247389d4e FEATURE: automatically update site to latest version of assets
if a user neglects to move around the site it will prompt to do so 2 hours in
2014-01-15 12:08:35 +11:00

23 lines
770 B
JavaScript

/**
Initialize the message bus to receive messages.
**/
Discourse.addInitializer(function() {
Discourse.MessageBus.alwaysLongPoll = Discourse.Environment === "development";
Discourse.MessageBus.start();
Discourse.MessageBus.subscribe("/global/asset-version", function(version){
Discourse.set("assetVersion",version);
if(Discourse.get("requiresRefresh")) {
// since we can do this transparently for people browsing the forum
// hold back the message a couple of hours
setTimeout(function() {
bootbox.confirm(I18n.lookup("assets_changed_confirm"), function(){
document.location.reload();
});
}, 1000 * 60 * 120);
}
});
Discourse.KeyValueStore.init("discourse_", Discourse.MessageBus);
}, true);