DEV: Remove `isLegacyEmber` (#17181)
This commit is contained in:
parent
41028a84ef
commit
7fd38f4933
|
@ -1,5 +1,5 @@
|
|||
import { debounce, next, run } from "@ember/runloop";
|
||||
import { isLegacyEmber, isTesting } from "discourse-common/config/environment";
|
||||
import { debounce, next } from "@ember/runloop";
|
||||
import { isTesting } from "discourse-common/config/environment";
|
||||
|
||||
/**
|
||||
Debounce a Javascript function. This means if it's called many times in a time limit it
|
||||
|
@ -7,13 +7,11 @@ import { isLegacyEmber, isTesting } from "discourse-common/config/environment";
|
|||
Original function will be called with the context and arguments from the last call made.
|
||||
**/
|
||||
|
||||
let testingFunc = isLegacyEmber() ? run : next;
|
||||
|
||||
export default function () {
|
||||
if (isTesting()) {
|
||||
// Don't include the time argument (in ms)
|
||||
let args = [].slice.call(arguments, 0, -1);
|
||||
return testingFunc.apply(void 0, args);
|
||||
return next.apply(void 0, args);
|
||||
} else {
|
||||
return debounce(...arguments);
|
||||
}
|
||||
|
|
|
@ -1,54 +1,50 @@
|
|||
import { setDefaultOwner } from "discourse-common/lib/get-owner";
|
||||
import { isLegacyEmber } from "discourse-common/config/environment";
|
||||
import User from "discourse/models/user";
|
||||
import Site from "discourse/models/site";
|
||||
import deprecated from "discourse-common/lib/deprecated";
|
||||
|
||||
export default {
|
||||
name: "inject-objects",
|
||||
after: isLegacyEmber() ? null : "export-application-global",
|
||||
after: "export-application-global",
|
||||
initialize(container, app) {
|
||||
// This is required for Ember CLI tests to work
|
||||
setDefaultOwner(app.__container__);
|
||||
|
||||
// Backwards compatibility for Discourse.SiteSettings and Discourse.User
|
||||
if (!isLegacyEmber()) {
|
||||
Object.defineProperty(app, "SiteSettings", {
|
||||
get() {
|
||||
deprecated(
|
||||
`use injected siteSettings instead of Discourse.SiteSettings`,
|
||||
{
|
||||
since: "2.8",
|
||||
dropFrom: "2.9",
|
||||
}
|
||||
);
|
||||
return container.lookup("site-settings:main");
|
||||
},
|
||||
});
|
||||
Object.defineProperty(app, "User", {
|
||||
get() {
|
||||
deprecated(
|
||||
`import discourse/models/user instead of using Discourse.User`,
|
||||
{
|
||||
since: "2.8",
|
||||
dropFrom: "2.9",
|
||||
}
|
||||
);
|
||||
return User;
|
||||
},
|
||||
});
|
||||
Object.defineProperty(app, "Site", {
|
||||
get() {
|
||||
deprecated(
|
||||
`import discourse/models/site instead of using Discourse.Site`,
|
||||
{
|
||||
since: "2.8",
|
||||
dropFrom: "2.9",
|
||||
}
|
||||
);
|
||||
return Site;
|
||||
},
|
||||
});
|
||||
}
|
||||
Object.defineProperty(app, "SiteSettings", {
|
||||
get() {
|
||||
deprecated(
|
||||
`use injected siteSettings instead of Discourse.SiteSettings`,
|
||||
{
|
||||
since: "2.8",
|
||||
dropFrom: "2.9",
|
||||
}
|
||||
);
|
||||
return container.lookup("site-settings:main");
|
||||
},
|
||||
});
|
||||
Object.defineProperty(app, "User", {
|
||||
get() {
|
||||
deprecated(
|
||||
`import discourse/models/user instead of using Discourse.User`,
|
||||
{
|
||||
since: "2.8",
|
||||
dropFrom: "2.9",
|
||||
}
|
||||
);
|
||||
return User;
|
||||
},
|
||||
});
|
||||
Object.defineProperty(app, "Site", {
|
||||
get() {
|
||||
deprecated(
|
||||
`import discourse/models/site instead of using Discourse.Site`,
|
||||
{
|
||||
since: "2.8",
|
||||
dropFrom: "2.9",
|
||||
}
|
||||
);
|
||||
return Site;
|
||||
},
|
||||
});
|
||||
},
|
||||
};
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
import { isLegacyEmber } from "discourse-common/config/environment";
|
||||
import { begin, end } from "@ember/runloop";
|
||||
import tippy from "tippy.js";
|
||||
import { iconHTML } from "discourse-common/lib/icon-library";
|
||||
|
||||
|
@ -39,14 +37,6 @@ export function showPopover(event, options = {}) {
|
|||
? event.target._tippy
|
||||
: setup(event.target, options);
|
||||
|
||||
// hangs on legacy ember
|
||||
if (!isLegacyEmber) {
|
||||
begin();
|
||||
instance.popper.addEventListener("transitionend", end, {
|
||||
once: true,
|
||||
});
|
||||
}
|
||||
|
||||
if (instance.state.isShown) {
|
||||
instance.hide();
|
||||
} else {
|
||||
|
@ -72,8 +62,7 @@ export default function setup(target, options) {
|
|||
options
|
||||
);
|
||||
|
||||
// legacy support
|
||||
delete tippyOptions.textContent;
|
||||
// legacy support delete tippyOptions.textContent;
|
||||
delete tippyOptions.htmlContent;
|
||||
|
||||
return tippy(target, tippyOptions);
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
import Application from "@ember/application";
|
||||
import { isLegacyEmber } from "discourse-common/config/environment";
|
||||
import { registerRouter, teardownRouter } from "discourse/mapping-router";
|
||||
|
||||
let originalBuildInstance;
|
||||
|
||||
export default {
|
||||
name: "map-routes",
|
||||
after: "inject-discourse-objects",
|
||||
|
@ -12,17 +8,6 @@ export default {
|
|||
let routerClass = registerRouter(app);
|
||||
container.registry.register("router:main", routerClass);
|
||||
this.routerClass = routerClass;
|
||||
|
||||
if (isLegacyEmber()) {
|
||||
// HACK to fix: https://github.com/emberjs/ember.js/issues/10310
|
||||
originalBuildInstance =
|
||||
originalBuildInstance || Application.prototype.buildInstance;
|
||||
|
||||
Application.prototype.buildInstance = function () {
|
||||
this.buildRegistry();
|
||||
return originalBuildInstance.apply(this);
|
||||
};
|
||||
}
|
||||
},
|
||||
|
||||
teardown() {
|
||||
|
|
|
@ -12,7 +12,6 @@ import {
|
|||
} from "@ember/runloop";
|
||||
import Session from "discourse/models/session";
|
||||
import { Promise } from "rsvp";
|
||||
import { isLegacyEmber, isTesting } from "discourse-common/config/environment";
|
||||
import User from "discourse/models/user";
|
||||
import userPresent, {
|
||||
onPresenceChange,
|
||||
|
@ -20,6 +19,7 @@ import userPresent, {
|
|||
} from "discourse/lib/user-presence";
|
||||
import { bind } from "discourse-common/utils/decorators";
|
||||
import Evented from "@ember/object/evented";
|
||||
import { isTesting } from "discourse-common/config/environment";
|
||||
|
||||
const PRESENCE_INTERVAL_S = 30;
|
||||
const PRESENCE_DEBOUNCE_MS = isTesting() ? 0 : 500;
|
||||
|
@ -549,13 +549,6 @@ export default class PresenceService extends Service {
|
|||
}
|
||||
});
|
||||
} catch (e) {
|
||||
if (e.jqXHR?.status === 403 && isTesting() && isLegacyEmber()) {
|
||||
// Legacy testing environment will remove the User.current() value before disposing of controllers/components.
|
||||
// Presence often involves making HTTP calls during disposal of components, so this can cause issues.
|
||||
// Modern Ember-CLI environment does not require this hack
|
||||
return;
|
||||
}
|
||||
|
||||
// Put the failed events back in the queue for next time
|
||||
this._queuedEvents.unshift(...queue);
|
||||
if (e.jqXHR?.status === 429) {
|
||||
|
|
|
@ -34,9 +34,9 @@ import { flushMap } from "discourse/services/store";
|
|||
import { registerObjects } from "discourse/pre-initializers/inject-discourse-objects";
|
||||
import sinon from "sinon";
|
||||
import { run } from "@ember/runloop";
|
||||
import { isLegacyEmber } from "discourse-common/config/environment";
|
||||
import { disableCloaking } from "discourse/widgets/post-stream";
|
||||
import { clearState as clearPresenceState } from "discourse/tests/helpers/presence-pretender";
|
||||
import { addModuleExcludeMatcher } from "ember-cli-test-loader/test-support/index";
|
||||
|
||||
const Plugin = $.fn.modal;
|
||||
const Modal = Plugin.Constructor;
|
||||
|
@ -298,19 +298,11 @@ function setupTestsCommon(application, container, config) {
|
|||
|
||||
createHelperContext({
|
||||
get siteSettings() {
|
||||
if (isLegacyEmber() && container.isDestroyed) {
|
||||
return settings;
|
||||
} else {
|
||||
return container.lookup("site-settings:main");
|
||||
}
|
||||
return container.lookup("site-settings:main");
|
||||
},
|
||||
capabilities: {},
|
||||
get site() {
|
||||
if (isLegacyEmber() && container.isDestroyed) {
|
||||
return Site.current();
|
||||
} else {
|
||||
return container.lookup("site:main") || Site.current();
|
||||
}
|
||||
return container.lookup("site:main") || Site.current();
|
||||
},
|
||||
registry: app.__registry__,
|
||||
});
|
||||
|
@ -389,19 +381,7 @@ function setupTestsCommon(application, container, config) {
|
|||
return true;
|
||||
};
|
||||
|
||||
if (isLegacyEmber()) {
|
||||
Object.keys(requirejs.entries).forEach(function (entry) {
|
||||
if (shouldLoadModule(entry)) {
|
||||
require(entry, null, null, true);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// Ember CLI
|
||||
const emberCliTestLoader = require("ember-cli-test-loader/test-support/index");
|
||||
emberCliTestLoader.addModuleExcludeMatcher(
|
||||
(name) => !shouldLoadModule(name)
|
||||
);
|
||||
}
|
||||
addModuleExcludeMatcher((name) => !shouldLoadModule(name));
|
||||
|
||||
// forces 0 as duration for all jquery animations
|
||||
// eslint-disable-next-line no-undef
|
||||
|
|
Loading…
Reference in New Issue