mirror of
https://github.com/element-hq/element-web.git
synced 2025-12-05 01:10:40 +00:00
Compare commits
1 Commits
t3chguy/mo
...
hs/fosdem2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d733f65cf3 |
@@ -13,6 +13,7 @@ import DMRoomMap from "./utils/DMRoomMap";
|
||||
import { mediaFromMxc } from "./customisations/Media";
|
||||
import { isLocalRoom } from "./utils/localRoom/isLocalRoom";
|
||||
import { getFirstGrapheme } from "./utils/strings";
|
||||
import { ModuleRunner } from "./modules/ModuleRunner";
|
||||
|
||||
/**
|
||||
* Hardcoded from the Compound colors.
|
||||
@@ -98,6 +99,12 @@ const colorToDataURLCache = new Map<string, string>();
|
||||
|
||||
export function defaultAvatarUrlForString(s: string): string {
|
||||
if (!s) return ""; // XXX: should never happen but empirically does by evidence of a rageshake
|
||||
|
||||
const avatar = ModuleRunner.instance.extensions.conference.defaultAvatarUrlForString(s);
|
||||
if (avatar !== null) {
|
||||
return avatar;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line react-hooks/rules-of-hooks
|
||||
const colorIndex = useIdColorHash(s);
|
||||
// overwritten color value in custom themes
|
||||
@@ -134,6 +141,11 @@ export function getInitialLetter(name: string): string | undefined {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const avatar = ModuleRunner.instance.extensions.conference.getAvatarInitialLetter(name);
|
||||
if (avatar !== null) {
|
||||
return avatar;
|
||||
}
|
||||
|
||||
const initial = name[0];
|
||||
if ((initial === "@" || initial === "#" || initial === "+") && name[1]) {
|
||||
name = name.substring(1);
|
||||
|
||||
@@ -132,6 +132,7 @@ import { SessionLockStolenView } from "./auth/SessionLockStolenView";
|
||||
import { ConfirmSessionLockTheftView } from "./auth/ConfirmSessionLockTheftView";
|
||||
import { LoginSplashView } from "./auth/LoginSplashView";
|
||||
import { cleanUpDraftsIfRequired } from "../../DraftCleaner";
|
||||
import { ClientLifecycle } from "@matrix-org/react-sdk-module-api/lib/lifecycles/ClientLifecycle";
|
||||
|
||||
// legacy export
|
||||
export { default as Views } from "../../Views";
|
||||
@@ -1553,6 +1554,8 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
|
||||
|
||||
this.firstSyncComplete = true;
|
||||
this.firstSyncPromise.resolve();
|
||||
console.log('TEST!!!');
|
||||
ModuleRunner.instance.invoke(ClientLifecycle.FirstSync);
|
||||
|
||||
if (Notifier.shouldShowPrompt() && !MatrixClientPeg.userRegisteredWithinLastHours(24)) {
|
||||
showNotificationsToast(false);
|
||||
|
||||
@@ -43,6 +43,7 @@ import { ViewHomePagePayload } from "../../dispatcher/payloads/ViewHomePagePaylo
|
||||
import { SDKContext } from "../../contexts/SDKContext";
|
||||
import { shouldShowFeedback } from "../../utils/Feedback";
|
||||
import DarkLightModeSvg from "../../../res/img/element-icons/roomlist/dark-light-mode.svg";
|
||||
import { ModuleRunner } from "../../modules/ModuleRunner";
|
||||
|
||||
interface IProps {
|
||||
isPanelCollapsed: boolean;
|
||||
@@ -410,13 +411,17 @@ export default class UserMenu extends React.Component<IProps, IState> {
|
||||
|
||||
const userId = MatrixClientPeg.safeGet().getSafeUserId();
|
||||
const displayName = OwnProfileStore.instance.displayName || userId;
|
||||
const avatarUrl = OwnProfileStore.instance.getHttpAvatarUrl(avatarSize);
|
||||
let avatarUrl = OwnProfileStore.instance.getHttpAvatarUrl(avatarSize);
|
||||
|
||||
let name: JSX.Element | undefined;
|
||||
if (!this.props.isPanelCollapsed) {
|
||||
name = <div className="mx_UserMenu_name">{displayName}</div>;
|
||||
}
|
||||
|
||||
if (!avatarUrl) {
|
||||
avatarUrl = ModuleRunner.instance.extensions.conference.defaultAvatarUrlForString(userId);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="mx_UserMenu">
|
||||
<ContextMenuButton
|
||||
|
||||
@@ -26,6 +26,7 @@ import {
|
||||
import TextInputDialog from "../dialogs/TextInputDialog";
|
||||
import AccessibleButton from "../elements/AccessibleButton";
|
||||
import withValidation from "../elements/Validation";
|
||||
import { ModuleRunner } from "../../../modules/ModuleRunner";
|
||||
|
||||
const SETTING_NAME = "room_directory_servers";
|
||||
|
||||
@@ -122,13 +123,17 @@ function useServers(): ServerList {
|
||||
removeAll(removableServers, homeServer);
|
||||
removeAll(removableServers, ...configServers);
|
||||
|
||||
const allServers = [
|
||||
// we always show our connected HS, this takes precedence over it being configured or user-defined
|
||||
homeServer,
|
||||
...Array.from(configServers).sort(),
|
||||
...Array.from(removableServers).sort(),
|
||||
]
|
||||
|
||||
|
||||
|
||||
return {
|
||||
allServers: [
|
||||
// we always show our connected HS, this takes precedence over it being configured or user-defined
|
||||
homeServer,
|
||||
...Array.from(configServers).sort(),
|
||||
...Array.from(removableServers).sort(),
|
||||
],
|
||||
allServers: ModuleRunner.instance.extensions.conference.filterServerList(allServers),
|
||||
homeServer,
|
||||
userDefinedServers: Array.from(removableServers).sort(),
|
||||
setUserDefinedServers,
|
||||
|
||||
@@ -16,6 +16,7 @@ import SdkConfig from "../../../SdkConfig";
|
||||
import Modal from "../../../Modal";
|
||||
import ServerPickerDialog from "../dialogs/ServerPickerDialog";
|
||||
import InfoDialog from "../dialogs/InfoDialog";
|
||||
import { ModuleRunner } from "../../../modules/ModuleRunner";
|
||||
|
||||
interface IProps {
|
||||
title?: string;
|
||||
@@ -77,7 +78,10 @@ const ServerPicker: React.FC<IProps> = ({ title, dialogTitle, serverConfig, onSe
|
||||
}
|
||||
|
||||
let desc;
|
||||
if (serverConfig.hsName === "matrix.org") {
|
||||
const moduleDesc = ModuleRunner.instance.extensions.conference.serverLoginNotice(serverConfig.hsName);
|
||||
if (moduleDesc) {
|
||||
desc = <span className="mx_ServerPicker_desc">{moduleDesc}</span>;
|
||||
} else if (serverConfig.hsName === "matrix.org") {
|
||||
desc = <span className="mx_ServerPicker_desc">{_t("auth|server_picker_description_matrix.org")}</span>;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,10 @@ import {
|
||||
DefaultExperimentalExtensions,
|
||||
ProvideExperimentalExtensions,
|
||||
} from "@matrix-org/react-sdk-module-api/lib/lifecycles/ExperimentalExtensions";
|
||||
import {
|
||||
DefaultConferenceExtensions,
|
||||
ProvideConferenceExtensions,
|
||||
} from "@matrix-org/react-sdk-module-api/lib/lifecycles/ConferenceExtensions";
|
||||
|
||||
import { AppModule } from "./AppModule";
|
||||
import { ModuleFactory } from "./ModuleFactory";
|
||||
@@ -30,6 +34,7 @@ class ExtensionsManager {
|
||||
// Private backing fields for extensions
|
||||
private cryptoSetupExtension: ProvideCryptoSetupExtensions;
|
||||
private experimentalExtension: ProvideExperimentalExtensions;
|
||||
private conferenceExtension: ProvideConferenceExtensions;
|
||||
|
||||
/** `true` if `cryptoSetupExtension` is the default implementation; `false` if it is implemented by a module. */
|
||||
private hasDefaultCryptoSetupExtension = true;
|
||||
@@ -37,6 +42,9 @@ class ExtensionsManager {
|
||||
/** `true` if `experimentalExtension` is the default implementation; `false` if it is implemented by a module. */
|
||||
private hasDefaultExperimentalExtension = true;
|
||||
|
||||
/** `true` if `conferenceExtension` is the default implementation; `false` if it is implemented by a module. */
|
||||
private hasDefaultConferenceExtension = true;
|
||||
|
||||
/**
|
||||
* Create a new instance.
|
||||
*/
|
||||
@@ -44,6 +52,7 @@ class ExtensionsManager {
|
||||
// Set up defaults
|
||||
this.cryptoSetupExtension = new DefaultCryptoSetupExtensions();
|
||||
this.experimentalExtension = new DefaultExperimentalExtensions();
|
||||
this.conferenceExtension = new DefaultConferenceExtensions();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -67,6 +76,15 @@ class ExtensionsManager {
|
||||
return this.experimentalExtension;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides extensions useful to conferences.
|
||||
*
|
||||
* @returns The registered extension. If no module provides this extension, a default implementation is returned.
|
||||
*/
|
||||
public get conference(): ProvideConferenceExtensions {
|
||||
return this.conferenceExtension;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add any extensions provided by the module.
|
||||
*
|
||||
@@ -100,6 +118,18 @@ class ExtensionsManager {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/* Add the experimental extension if any */
|
||||
if (runtimeModule.extensions?.conference) {
|
||||
if (this.hasDefaultConferenceExtension) {
|
||||
this.conferenceExtension = runtimeModule.extensions.conference;
|
||||
this.hasDefaultConferenceExtension = false;
|
||||
} else {
|
||||
throw new Error(
|
||||
`adding conference extension implementation from module ${runtimeModule.moduleName} but an implementation was already provided.`,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user