DEV: Modernize chat getOwner usage (#23671)
See 8958b4f76a
for motivation
This commit is contained in:
parent
52722c7086
commit
a673004777
|
@ -26,7 +26,7 @@ import ChatMessagesLoader from "discourse/plugins/chat/discourse/lib/chat-messag
|
|||
import { cached, tracked } from "@glimmer/tracking";
|
||||
import discourseDebounce from "discourse-common/lib/debounce";
|
||||
import DiscourseURL from "discourse/lib/url";
|
||||
import { getOwner } from "discourse-common/lib/get-owner";
|
||||
import { getOwner } from "@ember/application";
|
||||
import {
|
||||
FUTURE,
|
||||
PAST,
|
||||
|
|
|
@ -6,7 +6,7 @@ import { cancel, next } from "@ember/runloop";
|
|||
import { cloneJSON } from "discourse-common/lib/object";
|
||||
import { chatComposerButtons } from "discourse/plugins/chat/discourse/lib/chat-composer-buttons";
|
||||
import TextareaInteractor from "discourse/plugins/chat/discourse/lib/textarea-interactor";
|
||||
import { getOwner } from "discourse-common/lib/get-owner";
|
||||
import { getOwner } from "@ember/application";
|
||||
import userSearch from "discourse/lib/user-search";
|
||||
import { findRawTemplate } from "discourse-common/lib/raw-templates";
|
||||
import { emojiSearch, isSkinTonableEmoji } from "pretty-text/emoji";
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import Component from "@glimmer/component";
|
||||
import ChatMessageInteractor from "discourse/plugins/chat/discourse/lib/chat-message-interactor";
|
||||
import { getOwner } from "discourse-common/lib/get-owner";
|
||||
import { getOwner } from "@ember/application";
|
||||
import { tracked } from "@glimmer/tracking";
|
||||
import discourseLater from "discourse-common/lib/later";
|
||||
import { action } from "@ember/object";
|
||||
|
|
|
@ -6,7 +6,7 @@ import { cancel, schedule } from "@ember/runloop";
|
|||
import { inject as service } from "@ember/service";
|
||||
import discourseLater from "discourse-common/lib/later";
|
||||
import isZoomed from "discourse/plugins/chat/discourse/lib/zoom-check";
|
||||
import { getOwner } from "discourse-common/lib/get-owner";
|
||||
import { getOwner } from "@ember/application";
|
||||
import ChatMessageInteractor from "discourse/plugins/chat/discourse/lib/chat-message-interactor";
|
||||
import discourseDebounce from "discourse-common/lib/debounce";
|
||||
import { bind } from "discourse-common/utils/decorators";
|
||||
|
|
|
@ -10,7 +10,7 @@ import { inject as service } from "@ember/service";
|
|||
import { cancel, next } from "@ember/runloop";
|
||||
import { resetIdle } from "discourse/lib/desktop-notifications";
|
||||
import ChatMessagesLoader from "discourse/plugins/chat/discourse/lib/chat-messages-loader";
|
||||
import { getOwner } from "discourse-common/lib/get-owner";
|
||||
import { getOwner } from "@ember/application";
|
||||
import {
|
||||
FUTURE,
|
||||
PAST,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import Component from "@glimmer/component";
|
||||
import { action } from "@ember/object";
|
||||
import { clipboardCopyAsync } from "discourse/lib/utilities";
|
||||
import { getOwner } from "discourse-common/lib/get-owner";
|
||||
import { getOwner } from "@ember/application";
|
||||
import { isTesting } from "discourse-common/config/environment";
|
||||
import { popupAjaxError } from "discourse/lib/ajax-error";
|
||||
import { inject as service } from "@ember/service";
|
||||
|
|
|
@ -2,7 +2,7 @@ import Component from "@glimmer/component";
|
|||
import fabricators from "discourse/plugins/chat/discourse/lib/fabricators";
|
||||
import { action } from "@ember/object";
|
||||
import ChatMessagesManager from "discourse/plugins/chat/discourse/lib/chat-messages-manager";
|
||||
import { getOwner } from "discourse-common/lib/get-owner";
|
||||
import { getOwner } from "@ember/application";
|
||||
import { inject as service } from "@ember/service";
|
||||
|
||||
export default class ChatStyleguideChatMessage extends Component {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { withPluginApi } from "discourse/lib/plugin-api";
|
||||
import I18n from "I18n";
|
||||
import { bind } from "discourse-common/utils/decorators";
|
||||
import { getOwner } from "discourse-common/lib/get-owner";
|
||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
||||
import { MENTION_KEYWORDS } from "discourse/plugins/chat/discourse/components/chat-message";
|
||||
import { clearChatComposerButtons } from "discourse/plugins/chat/discourse/lib/chat-composer-buttons";
|
||||
import ChannelHashtagType from "discourse/plugins/chat/discourse/lib/hashtag-types/channel";
|
||||
|
@ -121,7 +121,9 @@ export default {
|
|||
// we want to decorate the chat quote dates regardless
|
||||
// of whether the current user has chat enabled
|
||||
api.decorateCookedElement((elem) => {
|
||||
const currentUser = getOwner(this).lookup("service:current-user");
|
||||
const currentUser = getOwnerWithFallback(this).lookup(
|
||||
"service:current-user"
|
||||
);
|
||||
const currentUserTimezone = currentUser?.user_option?.timezone;
|
||||
const chatTranscriptElements =
|
||||
elem.querySelectorAll(".chat-transcript");
|
||||
|
|
|
@ -5,7 +5,7 @@ import { tracked } from "@glimmer/tracking";
|
|||
import slugifyChannel from "discourse/plugins/chat/discourse/lib/slugify-channel";
|
||||
import ChatThreadsManager from "discourse/plugins/chat/discourse/lib/chat-threads-manager";
|
||||
import ChatMessagesManager from "discourse/plugins/chat/discourse/lib/chat-messages-manager";
|
||||
import { getOwner } from "discourse-common/lib/get-owner";
|
||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
||||
import guid from "pretty-text/guid";
|
||||
import ChatDirectMessage from "discourse/plugins/chat/discourse/models/chat-direct-message";
|
||||
import ChatChannelArchive from "discourse/plugins/chat/discourse/models/chat-channel-archive";
|
||||
|
@ -70,8 +70,8 @@ export default class ChatChannel {
|
|||
@tracked tracking;
|
||||
@tracked threadingEnabled = false;
|
||||
|
||||
threadsManager = new ChatThreadsManager(getOwner(this));
|
||||
messagesManager = new ChatMessagesManager(getOwner(this));
|
||||
threadsManager = new ChatThreadsManager(getOwnerWithFallback(this));
|
||||
messagesManager = new ChatMessagesManager(getOwnerWithFallback(this));
|
||||
|
||||
@tracked _currentUserMembership;
|
||||
@tracked _lastMessage;
|
||||
|
@ -101,7 +101,7 @@ export default class ChatChannel {
|
|||
this.archive = ChatChannelArchive.create(args);
|
||||
}
|
||||
|
||||
this.tracking = new ChatTrackingState(getOwner(this));
|
||||
this.tracking = new ChatTrackingState(getOwnerWithFallback(this));
|
||||
this.lastMessage = args.last_message;
|
||||
this.meta = args.meta;
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ import Bookmark from "discourse/models/bookmark";
|
|||
import I18n from "I18n";
|
||||
import { generateCookFunction, parseMentions } from "discourse/lib/text";
|
||||
import transformAutolinks from "discourse/plugins/chat/discourse/lib/transform-auto-links";
|
||||
import { getOwner } from "discourse-common/lib/get-owner";
|
||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
||||
import discourseLater from "discourse-common/lib/later";
|
||||
|
||||
export default class ChatMessage {
|
||||
|
@ -329,7 +329,7 @@ export default class ChatMessage {
|
|||
}
|
||||
|
||||
get #markdownOptions() {
|
||||
const site = getOwner(this).lookup("service:site");
|
||||
const site = getOwnerWithFallback(this).lookup("service:site");
|
||||
return {
|
||||
featuresOverride:
|
||||
site.markdown_additional_options?.chat?.limited_pretty_text_features,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { getOwner } from "discourse-common/lib/get-owner";
|
||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
||||
import ChatMessagesManager from "discourse/plugins/chat/discourse/lib/chat-messages-manager";
|
||||
import { escapeExpression } from "discourse/lib/utilities";
|
||||
import { tracked } from "@glimmer/tracking";
|
||||
|
@ -33,7 +33,7 @@ export default class ChatThread {
|
|||
@tracked currentUserMembership = null;
|
||||
@tracked preview = null;
|
||||
|
||||
messagesManager = new ChatMessagesManager(getOwner(this));
|
||||
messagesManager = new ChatMessagesManager(getOwnerWithFallback(this));
|
||||
|
||||
constructor(channel, args = {}) {
|
||||
this.id = args.id;
|
||||
|
@ -55,7 +55,7 @@ export default class ChatThread {
|
|||
);
|
||||
}
|
||||
|
||||
this.tracking = new ChatTrackingState(getOwner(this));
|
||||
this.tracking = new ChatTrackingState(getOwnerWithFallback(this));
|
||||
this.preview = ChatThreadPreview.create(args.preview);
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ import Service, { inject as service } from "@ember/service";
|
|||
import discourseDebounce from "discourse-common/lib/debounce";
|
||||
import { cancel } from "@ember/runloop";
|
||||
import ChatTrackingState from "discourse/plugins/chat/discourse/models/chat-tracking-state";
|
||||
import { getOwner } from "discourse-common/lib/get-owner";
|
||||
import { getOwner } from "@ember/application";
|
||||
|
||||
/**
|
||||
* This service is used to provide a global interface to tracking individual
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
import { module, test } from "qunit";
|
||||
import { getOwner } from "discourse-common/lib/get-owner";
|
||||
import { getOwner } from "@ember/application";
|
||||
import { setupTest } from "ember-qunit";
|
||||
|
||||
module("Discourse Chat | Unit | chat-emoji-reaction-store", function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
this.siteSettings = getOwner(this).lookup("service:site-settings");
|
||||
this.chatEmojiReactionStore = getOwner(this).lookup(
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
import { module, test } from "qunit";
|
||||
import { getOwner } from "discourse-common/lib/get-owner";
|
||||
import { getOwner } from "@ember/application";
|
||||
import { ORIGINS } from "discourse/plugins/chat/discourse/services/chat-channel-info-route-origin-manager";
|
||||
import { setupTest } from "ember-qunit";
|
||||
|
||||
module(
|
||||
"Discourse Chat | Unit | Service | chat-channel-info-route-origin-manager",
|
||||
function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
this.manager = getOwner(this).lookup(
|
||||
"service:chat-channel-info-route-origin-manager"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { module, test } from "qunit";
|
||||
import { setupTest } from "ember-qunit";
|
||||
import { getOwner } from "discourse-common/lib/get-owner";
|
||||
import { getOwner } from "@ember/application";
|
||||
import fabricators from "discourse/plugins/chat/discourse/lib/fabricators";
|
||||
|
||||
module(
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
import { module, test } from "qunit";
|
||||
import { getOwner } from "discourse-common/lib/get-owner";
|
||||
import { getOwner } from "@ember/application";
|
||||
import { setupTest } from "ember-qunit";
|
||||
|
||||
module("Discourse Chat | Unit | Service | chat-drawer-size", function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
this.subject = getOwner(this).lookup("service:chat-drawer-size");
|
||||
});
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
import { module, test } from "qunit";
|
||||
import { getOwner } from "discourse-common/lib/get-owner";
|
||||
import { getOwner } from "@ember/application";
|
||||
import pretender from "discourse/tests/helpers/create-pretender";
|
||||
import { settled } from "@ember/test-helpers";
|
||||
import { setupTest } from "ember-qunit";
|
||||
|
||||
function emojisReponse() {
|
||||
return { favorites: [{ name: "sad" }] };
|
||||
|
@ -10,6 +11,8 @@ function emojisReponse() {
|
|||
module(
|
||||
"Discourse Chat | Unit | Service | chat-emoji-picker-manager",
|
||||
function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
pretender.get("/chat/emojis.json", () => {
|
||||
return [200, {}, emojisReponse()];
|
||||
|
|
|
@ -2,7 +2,7 @@ import { module, test } from "qunit";
|
|||
import { setupTest } from "ember-qunit";
|
||||
import Site from "discourse/models/site";
|
||||
import sinon from "sinon";
|
||||
import { getOwner } from "discourse-common/lib/get-owner";
|
||||
import { getOwner } from "@ember/application";
|
||||
import {
|
||||
addChatDrawerStateCallback,
|
||||
resetChatDrawerStateCallbacks,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { setupTest } from "ember-qunit";
|
||||
import { module, test } from "qunit";
|
||||
import { getOwner } from "discourse-common/lib/get-owner";
|
||||
import { getOwner } from "@ember/application";
|
||||
import { withPluginApi } from "discourse/lib/plugin-api";
|
||||
import User from "discourse/models/user";
|
||||
import ChatMessageInteractor, {
|
||||
|
|
Loading…
Reference in New Issue