DEV: Use disableImplicitInjections more extensively (#23579)

This commit is contained in:
Jarek Radosz 2023-09-25 19:30:07 +02:00 committed by GitHub
parent 0fb2812414
commit 5484030162
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 47 additions and 10 deletions

View File

@ -39,6 +39,7 @@ import { iconHTML } from "discourse-common/lib/icon-library";
import prepareFormTemplateData from "discourse/lib/form-template-validation";
import DiscardDraftModal from "discourse/components/modal/discard-draft";
import PostEnqueuedModal from "discourse/components/modal/post-enqueued";
import { disableImplicitInjections } from "discourse/lib/implicit-injections";
async function loadDraft(store, opts = {}) {
let { draft, draftKey, draftSequence } = opts;
@ -99,14 +100,19 @@ export function addComposerSaveErrorCallback(callback) {
_composerSaveErrorCallbacks.push(callback);
}
@disableImplicitInjections
export default class ComposerService extends Service {
@service router;
@service dialog;
@service site;
@service store;
@service appEvents;
@service capabilities;
@service currentUser;
@service dialog;
@service keyValueStore;
@service messageBus;
@service modal;
@service router;
@service site;
@service siteSettings;
@service store;
checkedMessages = false;
messageCount = null;

View File

@ -1,5 +1,6 @@
import Service from "@ember/service";
import KeyValueStore from "discourse/lib/key-value-store";
import { disableImplicitInjections } from "discourse/lib/implicit-injections";
const PROXIED_METHODS = Object.getOwnPropertyNames(
KeyValueStore.prototype
@ -10,6 +11,7 @@ const PROXIED_METHODS = Object.getOwnPropertyNames(
* Alternatively, consumers can use `discourse/lib/key-value-store` directly
* to create their own namespaced store.
* */
@disableImplicitInjections
export default class KeyValueStoreService extends Service {
_keyValueStore = new KeyValueStore("discourse_");

View File

@ -9,14 +9,16 @@ import {
getSiteThemeColor,
setSiteThemeColor,
} from "discourse/lib/lightbox/helpers";
import { bind } from "discourse-common/utils/decorators";
import { isDocumentRTL } from "discourse/lib/text-direction";
import { processHTML } from "discourse/lib/lightbox/process-html";
import { disableImplicitInjections } from "discourse/lib/implicit-injections";
@disableImplicitInjections
export default class LightboxService extends Service {
@service appEvents;
@service site;
@service siteSettings;
lightboxIsOpen = false;
lightboxClickElements = [];

View File

@ -1,8 +1,8 @@
import Service from "@ember/service";
import { getOwner } from "@ember/application";
import Service, { inject as service } from "@ember/service";
import { Promise } from "rsvp";
import { fileToImageData } from "discourse/lib/media-optimization-utils";
import { getAbsoluteURL, getURLWithCDN } from "discourse-common/lib/get-url";
import { disableImplicitInjections } from "discourse/lib/implicit-injections";
/**
* This worker follows a particular promise/callback flow to ensure
@ -20,8 +20,11 @@ import { getAbsoluteURL, getURLWithCDN } from "discourse-common/lib/get-url";
* will wait for the "installed" message to be handled before continuing
* with any image optimization work.
*/
@disableImplicitInjections
export default class MediaOptimizationWorkerService extends Service {
appEvents = getOwner(this).lookup("service:app-events");
@service appEvents;
@service siteSettings;
worker = null;
workerUrl = getAbsoluteURL("/javascripts/media-optimization-worker.js");
currentComposerUploadData = null;

View File

@ -1,5 +1,7 @@
import MessageBus from "message-bus-client";
import { disableImplicitInjections } from "discourse/lib/implicit-injections";
@disableImplicitInjections
export default class MessageBusService {
static isServiceFactory = true;

View File

@ -1,8 +1,10 @@
import Service, { inject as service } from "@ember/service";
import { tracked } from "@glimmer/tracking";
import { disableImplicitInjections } from "discourse/lib/implicit-injections";
const TOPIC_LIST_PREFERENCE_KEY = "more-topics-list-preference";
@disableImplicitInjections
export default class MoreTopicsPreferenceTracking extends Service {
@service keyValueStore;

View File

@ -1,5 +1,7 @@
import Service, { inject as service } from "@ember/service";
import { disableImplicitInjections } from "discourse/lib/implicit-injections";
@disableImplicitInjections
export default class NavigationMenu extends Service {
@service site;
@service siteSettings;

View File

@ -4,9 +4,11 @@ import { ajax } from "discourse/lib/ajax";
import { bind } from "discourse-common/utils/decorators";
import { cancel } from "@ember/runloop";
import { tracked } from "@glimmer/tracking";
import { disableImplicitInjections } from "discourse/lib/implicit-injections";
const CONNECTIVITY_ERROR_CLASS = "network-disconnected";
@disableImplicitInjections
export default class NetworkConnectivity extends Service {
@tracked connected = true;

View File

@ -2,6 +2,7 @@ import Service, { inject as service } from "@ember/service";
import { bind } from "discourse-common/utils/decorators";
import { schedule } from "@ember/runloop";
import { isTesting } from "discourse-common/config/environment";
import { disableImplicitInjections } from "discourse/lib/implicit-injections";
const MAX_SCROLL_LOCATIONS = 100;
@ -14,6 +15,7 @@ const MAX_SCROLL_LOCATIONS = 100;
* To opt-out of the behaviour, individual routes can add a scrollOnTransition
* boolean to their RouteInfo metadata using Ember's `buildRouteInfoMetadata` hook.
*/
@disableImplicitInjections
export default class RouteScrollManager extends Service {
@service router;

View File

@ -8,6 +8,7 @@ import {
setHighestReadCache,
} from "discourse/lib/topic-list-tracker";
import { run } from "@ember/runloop";
import { disableImplicitInjections } from "discourse/lib/implicit-injections";
// We use this class to track how long posts in a topic are on the screen.
const PAUSE_UNLESS_SCROLLED = 1000 * 60 * 3;
@ -17,8 +18,14 @@ const ANON_MAX_TOPIC_IDS = 5;
const AJAX_FAILURE_DELAYS = [5000, 10000, 20000, 40000];
const ALLOWED_AJAX_FAILURES = [405, 429, 500, 501, 502, 503, 504];
@disableImplicitInjections
export default class ScreenTrack extends Service {
@service appEvents;
@service currentUser;
@service keyValueStore;
@service session;
@service siteSettings;
@service topicTrackingState;
_consolidatedTimings = [];
_lastTick = null;

View File

@ -1,15 +1,16 @@
import Service from "@ember/service";
import { tracked } from "@glimmer/tracking";
import {
currentPanelKey,
customPanels as panels,
} from "discourse/lib/sidebar/custom-sections";
import { disableImplicitInjections } from "discourse/lib/implicit-injections";
const COMBINED_MODE = "combined";
const SEPARATED_MODE = "separated";
const MAIN_PANEL = "main";
@disableImplicitInjections
export default class SidebarState extends Service {
@tracked currentPanelKey = currentPanelKey;
@tracked panels = panels;

View File

@ -1,6 +1,8 @@
import PreloadStore from "discourse/lib/preload-store";
import { TrackedObject } from "@ember-compat/tracked-built-ins";
import { disableImplicitInjections } from "discourse/lib/implicit-injections";
@disableImplicitInjections
export default class SiteSettingsService {
static isServiceFactory = true;

View File

@ -1,9 +1,11 @@
import Service, { inject as service } from "@ember/service";
import { ajax } from "discourse/lib/ajax";
import DoNotDisturb from "discourse/lib/do-not-disturb";
import { disableImplicitInjections } from "discourse/lib/implicit-injections";
@disableImplicitInjections
export default class UserStatusService extends Service {
@service appEvents;
@service currentUser;
async set(status, pauseNotifications) {
await ajax({

View File

@ -7,9 +7,11 @@ import tippy from "tippy.js";
import isElementInViewport from "discourse/lib/is-element-in-viewport";
import discourseLater from "discourse-common/lib/later";
import { cancel } from "@ember/runloop";
import { disableImplicitInjections } from "discourse/lib/implicit-injections";
const TIPPY_DELAY = 500;
@disableImplicitInjections
export default class UserTips extends Service {
#instances = new Map();