diff --git a/js/src/common/Store.ts b/js/src/common/Store.ts index 970a17679..9b1dd2de3 100644 --- a/js/src/common/Store.ts +++ b/js/src/common/Store.ts @@ -1,6 +1,6 @@ import app from '../common/app'; import { FlarumRequestOptions } from './Application'; -import fireDebugWarning from './helpers/fireDebugWarning'; +import { fireDeprecationWarning } from './helpers/fireDebugWarning'; import Model, { ModelData, SavedModelData } from './Model'; export interface MetaInformation { @@ -123,11 +123,7 @@ export default class Store { if (!this.models[data.type]) { if (!allowUnregistered) { setTimeout(() => - fireDebugWarning( - `[Flarum 2.0 Deprecation] Cannot push object of type \`${data.type}\`, as that type has not yet been registered in the store. This will throw an error in Flarum 2.0 and later. - -For more information, see https://github.com/flarum/core/pull/3206.` - ) + fireDeprecationWarning(`Pushing object of type \`${data.type}\` not allowed, as type not yet registered in the store.`, '3206') ); } diff --git a/js/src/common/helpers/fireDebugWarning.ts b/js/src/common/helpers/fireDebugWarning.ts index 159dfca1a..e29f6a0ec 100644 --- a/js/src/common/helpers/fireDebugWarning.ts +++ b/js/src/common/helpers/fireDebugWarning.ts @@ -16,3 +16,21 @@ export default function fireDebugWarning(...args: Parameters handler.apply(this, args)); }, @@ -56,7 +55,7 @@ export default { * @param {function} handler The function to handle the event. */ on(event, handler) { - fireDebugWarning(deprecatedNotice); + fireDeprecationWarning(deprecatedNotice, deprecationIssueId); this.getHandlers(event).push(handler); }, @@ -69,7 +68,7 @@ export default { * @param {function} handler The function to handle the event. */ one(event, handler) { - fireDebugWarning(deprecatedNotice); + fireDeprecationWarning(deprecatedNotice, deprecationIssueId); const wrapper = function () { handler.apply(this, arguments); @@ -87,7 +86,7 @@ export default { * @param {function} handler The function that handles the event. */ off(event, handler) { - fireDebugWarning(deprecatedNotice); + fireDeprecationWarning(deprecatedNotice, deprecationIssueId); const handlers = this.getHandlers(event); const index = handlers.indexOf(handler); diff --git a/js/src/forum/components/Search.tsx b/js/src/forum/components/Search.tsx index 65b833c41..645fa9241 100644 --- a/js/src/forum/components/Search.tsx +++ b/js/src/forum/components/Search.tsx @@ -9,8 +9,8 @@ import icon from '../../common/helpers/icon'; import SearchState from '../states/SearchState'; import DiscussionsSearchSource from './DiscussionsSearchSource'; import UsersSearchSource from './UsersSearchSource'; +import { fireDeprecationWarning } from '../../common/helpers/fireDebugWarning'; import type Mithril from 'mithril'; -import Model from '../../common/Model'; /** * The `SearchSource` interface defines a section of search results in the @@ -53,14 +53,33 @@ export interface SearchAttrs extends ComponentAttrs { * * - state: SearchState instance. */ -export default class Search extends Component { +export default class Search extends Component { /** * The minimum query length before sources are searched. */ protected static MIN_SEARCH_LEN = 3; + /** + * The instance of `SearchState` for this component. + */ protected searchState!: SearchState; + /** + * The instance of `SearchState` for this component. + * + * @deprecated Replace with`this.searchState` instead. + */ + // TODO: [Flarum 2.0] Remove this. + // @ts-expect-error This is a get accessor, while superclass defines this as a property. This is needed to prevent breaking changes, however. + protected get state() { + fireDeprecationWarning('`state` property of the Search component is deprecated', '3212'); + return this.searchState; + } + protected set state(state: SearchState) { + fireDeprecationWarning('`state` property of the Search component is deprecated', '3212'); + this.searchState = state; + } + /** * Whether or not the search input has focus. */