FIX: Always return the latest API version requested

This commit is contained in:
Robin Ward 2016-12-27 11:57:46 -05:00
parent 98eac4924c
commit 3786d3679c
2 changed files with 6 additions and 1 deletions

View File

@ -137,7 +137,7 @@ const Discourse = Ember.Application.extend({
Discourse.instanceInitializer({ Discourse.instanceInitializer({
name: "_discourse_plugin_" + (++initCount), name: "_discourse_plugin_" + (++initCount),
after: 'inject-objects', after: 'inject-objects',
initialize: function() { initialize() {
withPluginApi(cb.version, cb.code); withPluginApi(cb.version, cb.code);
} }
}); });

View File

@ -361,6 +361,11 @@ function getPluginApi(version) {
if (!_pluginv01) { if (!_pluginv01) {
_pluginv01 = new PluginApi(version, Discourse.__container__); _pluginv01 = new PluginApi(version, Discourse.__container__);
} }
// We are recycling the compatible object, but let's update to the higher version
if (_pluginv01.version < version) {
_pluginv01.version = version;
}
return _pluginv01; return _pluginv01;
} else { } else {
console.warn(`Plugin API v${version} is not supported`); console.warn(`Plugin API v${version} is not supported`);