diff --git a/src/customisations/helpers/UIComponents.ts b/src/customisations/helpers/UIComponents.ts index 11b8a409695..e6cb65caac4 100644 --- a/src/customisations/helpers/UIComponents.ts +++ b/src/customisations/helpers/UIComponents.ts @@ -14,9 +14,23 @@ See the License for the specific language governing permissions and limitations under the License. */ +import { + ShouldShowUIComponentOps, + UIComponentLifecycle, +} from "@matrix-org/react-sdk-module-api/lib/lifecycles/UIComponentLifecycle"; + import { UIComponent } from "../../settings/UIFeature"; import { ComponentVisibilityCustomisations } from "../ComponentVisibility"; +import { ModuleRunner } from "../../modules/ModuleRunner"; export function shouldShowComponent(component: UIComponent): boolean { - return ComponentVisibilityCustomisations.shouldShowComponent?.(component) ?? true; + let approved: boolean | undefined; + if (ComponentVisibilityCustomisations.shouldShowComponent) { + approved = ComponentVisibilityCustomisations.shouldShowComponent(component); + } else { + const opts: ShouldShowUIComponentOps = { shouldShowComponent: undefined }; + ModuleRunner.instance.invoke(UIComponentLifecycle.ShouldShowComponent, opts, component); + approved = opts.shouldShowComponent; + } + return approved ?? true; } diff --git a/src/modules/ProxiedModuleApi.ts b/src/modules/ProxiedModuleApi.ts index 0c2b75e71f7..d9bd88b1793 100644 --- a/src/modules/ProxiedModuleApi.ts +++ b/src/modules/ProxiedModuleApi.ts @@ -216,4 +216,8 @@ export class ProxiedModuleApi implements ModuleApi { if (!maybeObj || !(typeof maybeObj === "object")) return undefined; return maybeObj[key]; } + + public getUserId(): string | undefined { + return MatrixClientPeg.get()?.getUserId() ?? undefined; + } }