Add FOSDEM module changes.
This commit is contained in:
@@ -13,6 +13,7 @@ import DMRoomMap from "./utils/DMRoomMap";
|
|||||||
import { mediaFromMxc } from "./customisations/Media";
|
import { mediaFromMxc } from "./customisations/Media";
|
||||||
import { isLocalRoom } from "./utils/localRoom/isLocalRoom";
|
import { isLocalRoom } from "./utils/localRoom/isLocalRoom";
|
||||||
import { getFirstGrapheme } from "./utils/strings";
|
import { getFirstGrapheme } from "./utils/strings";
|
||||||
|
import { ModuleRunner } from "./modules/ModuleRunner";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hardcoded from the Compound colors.
|
* Hardcoded from the Compound colors.
|
||||||
@@ -98,6 +99,12 @@ const colorToDataURLCache = new Map<string, string>();
|
|||||||
|
|
||||||
export function defaultAvatarUrlForString(s: string): string {
|
export function defaultAvatarUrlForString(s: string): string {
|
||||||
if (!s) return ""; // XXX: should never happen but empirically does by evidence of a rageshake
|
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
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
||||||
const colorIndex = useIdColorHash(s);
|
const colorIndex = useIdColorHash(s);
|
||||||
// overwritten color value in custom themes
|
// overwritten color value in custom themes
|
||||||
@@ -134,6 +141,11 @@ export function getInitialLetter(name: string): string | undefined {
|
|||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const avatar = ModuleRunner.instance.extensions.conference.getAvatarInitialLetter(name);
|
||||||
|
if (avatar !== null) {
|
||||||
|
return avatar;
|
||||||
|
}
|
||||||
|
|
||||||
const initial = name[0];
|
const initial = name[0];
|
||||||
if ((initial === "@" || initial === "#" || initial === "+") && name[1]) {
|
if ((initial === "@" || initial === "#" || initial === "+") && name[1]) {
|
||||||
name = name.substring(1);
|
name = name.substring(1);
|
||||||
|
|||||||
@@ -132,6 +132,7 @@ import { SessionLockStolenView } from "./auth/SessionLockStolenView";
|
|||||||
import { ConfirmSessionLockTheftView } from "./auth/ConfirmSessionLockTheftView";
|
import { ConfirmSessionLockTheftView } from "./auth/ConfirmSessionLockTheftView";
|
||||||
import { LoginSplashView } from "./auth/LoginSplashView";
|
import { LoginSplashView } from "./auth/LoginSplashView";
|
||||||
import { cleanUpDraftsIfRequired } from "../../DraftCleaner";
|
import { cleanUpDraftsIfRequired } from "../../DraftCleaner";
|
||||||
|
import { ClientLifecycle } from "@matrix-org/react-sdk-module-api/lib/lifecycles/ClientLifecycle";
|
||||||
|
|
||||||
// legacy export
|
// legacy export
|
||||||
export { default as Views } from "../../Views";
|
export { default as Views } from "../../Views";
|
||||||
@@ -1553,6 +1554,8 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
|
|||||||
|
|
||||||
this.firstSyncComplete = true;
|
this.firstSyncComplete = true;
|
||||||
this.firstSyncPromise.resolve();
|
this.firstSyncPromise.resolve();
|
||||||
|
console.log('TEST!!!');
|
||||||
|
ModuleRunner.instance.invoke(ClientLifecycle.FirstSync);
|
||||||
|
|
||||||
if (Notifier.shouldShowPrompt() && !MatrixClientPeg.userRegisteredWithinLastHours(24)) {
|
if (Notifier.shouldShowPrompt() && !MatrixClientPeg.userRegisteredWithinLastHours(24)) {
|
||||||
showNotificationsToast(false);
|
showNotificationsToast(false);
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ import { ViewHomePagePayload } from "../../dispatcher/payloads/ViewHomePagePaylo
|
|||||||
import { SDKContext } from "../../contexts/SDKContext";
|
import { SDKContext } from "../../contexts/SDKContext";
|
||||||
import { shouldShowFeedback } from "../../utils/Feedback";
|
import { shouldShowFeedback } from "../../utils/Feedback";
|
||||||
import DarkLightModeSvg from "../../../res/img/element-icons/roomlist/dark-light-mode.svg";
|
import DarkLightModeSvg from "../../../res/img/element-icons/roomlist/dark-light-mode.svg";
|
||||||
|
import { ModuleRunner } from "../../modules/ModuleRunner";
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
isPanelCollapsed: boolean;
|
isPanelCollapsed: boolean;
|
||||||
@@ -410,13 +411,17 @@ export default class UserMenu extends React.Component<IProps, IState> {
|
|||||||
|
|
||||||
const userId = MatrixClientPeg.safeGet().getSafeUserId();
|
const userId = MatrixClientPeg.safeGet().getSafeUserId();
|
||||||
const displayName = OwnProfileStore.instance.displayName || userId;
|
const displayName = OwnProfileStore.instance.displayName || userId;
|
||||||
const avatarUrl = OwnProfileStore.instance.getHttpAvatarUrl(avatarSize);
|
let avatarUrl = OwnProfileStore.instance.getHttpAvatarUrl(avatarSize);
|
||||||
|
|
||||||
let name: JSX.Element | undefined;
|
let name: JSX.Element | undefined;
|
||||||
if (!this.props.isPanelCollapsed) {
|
if (!this.props.isPanelCollapsed) {
|
||||||
name = <div className="mx_UserMenu_name">{displayName}</div>;
|
name = <div className="mx_UserMenu_name">{displayName}</div>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!avatarUrl) {
|
||||||
|
avatarUrl = ModuleRunner.instance.extensions.conference.defaultAvatarUrlForString(userId);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="mx_UserMenu">
|
<div className="mx_UserMenu">
|
||||||
<ContextMenuButton
|
<ContextMenuButton
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import {
|
|||||||
import TextInputDialog from "../dialogs/TextInputDialog";
|
import TextInputDialog from "../dialogs/TextInputDialog";
|
||||||
import AccessibleButton from "../elements/AccessibleButton";
|
import AccessibleButton from "../elements/AccessibleButton";
|
||||||
import withValidation from "../elements/Validation";
|
import withValidation from "../elements/Validation";
|
||||||
|
import { ModuleRunner } from "../../../modules/ModuleRunner";
|
||||||
|
|
||||||
const SETTING_NAME = "room_directory_servers";
|
const SETTING_NAME = "room_directory_servers";
|
||||||
|
|
||||||
@@ -122,13 +123,17 @@ function useServers(): ServerList {
|
|||||||
removeAll(removableServers, homeServer);
|
removeAll(removableServers, homeServer);
|
||||||
removeAll(removableServers, ...configServers);
|
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 {
|
return {
|
||||||
allServers: [
|
allServers: ModuleRunner.instance.extensions.conference.filterServerList(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(),
|
|
||||||
],
|
|
||||||
homeServer,
|
homeServer,
|
||||||
userDefinedServers: Array.from(removableServers).sort(),
|
userDefinedServers: Array.from(removableServers).sort(),
|
||||||
setUserDefinedServers,
|
setUserDefinedServers,
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import SdkConfig from "../../../SdkConfig";
|
|||||||
import Modal from "../../../Modal";
|
import Modal from "../../../Modal";
|
||||||
import ServerPickerDialog from "../dialogs/ServerPickerDialog";
|
import ServerPickerDialog from "../dialogs/ServerPickerDialog";
|
||||||
import InfoDialog from "../dialogs/InfoDialog";
|
import InfoDialog from "../dialogs/InfoDialog";
|
||||||
|
import { ModuleRunner } from "../../../modules/ModuleRunner";
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
title?: string;
|
title?: string;
|
||||||
@@ -77,7 +78,10 @@ const ServerPicker: React.FC<IProps> = ({ title, dialogTitle, serverConfig, onSe
|
|||||||
}
|
}
|
||||||
|
|
||||||
let desc;
|
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>;
|
desc = <span className="mx_ServerPicker_desc">{_t("auth|server_picker_description_matrix.org")}</span>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,10 @@ import {
|
|||||||
DefaultExperimentalExtensions,
|
DefaultExperimentalExtensions,
|
||||||
ProvideExperimentalExtensions,
|
ProvideExperimentalExtensions,
|
||||||
} from "@matrix-org/react-sdk-module-api/lib/lifecycles/ExperimentalExtensions";
|
} 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 { AppModule } from "./AppModule";
|
||||||
import { ModuleFactory } from "./ModuleFactory";
|
import { ModuleFactory } from "./ModuleFactory";
|
||||||
@@ -30,6 +34,7 @@ class ExtensionsManager {
|
|||||||
// Private backing fields for extensions
|
// Private backing fields for extensions
|
||||||
private cryptoSetupExtension: ProvideCryptoSetupExtensions;
|
private cryptoSetupExtension: ProvideCryptoSetupExtensions;
|
||||||
private experimentalExtension: ProvideExperimentalExtensions;
|
private experimentalExtension: ProvideExperimentalExtensions;
|
||||||
|
private conferenceExtension: ProvideConferenceExtensions;
|
||||||
|
|
||||||
/** `true` if `cryptoSetupExtension` is the default implementation; `false` if it is implemented by a module. */
|
/** `true` if `cryptoSetupExtension` is the default implementation; `false` if it is implemented by a module. */
|
||||||
private hasDefaultCryptoSetupExtension = true;
|
private hasDefaultCryptoSetupExtension = true;
|
||||||
@@ -37,6 +42,9 @@ class ExtensionsManager {
|
|||||||
/** `true` if `experimentalExtension` is the default implementation; `false` if it is implemented by a module. */
|
/** `true` if `experimentalExtension` is the default implementation; `false` if it is implemented by a module. */
|
||||||
private hasDefaultExperimentalExtension = true;
|
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.
|
* Create a new instance.
|
||||||
*/
|
*/
|
||||||
@@ -44,6 +52,7 @@ class ExtensionsManager {
|
|||||||
// Set up defaults
|
// Set up defaults
|
||||||
this.cryptoSetupExtension = new DefaultCryptoSetupExtensions();
|
this.cryptoSetupExtension = new DefaultCryptoSetupExtensions();
|
||||||
this.experimentalExtension = new DefaultExperimentalExtensions();
|
this.experimentalExtension = new DefaultExperimentalExtensions();
|
||||||
|
this.conferenceExtension = new DefaultConferenceExtensions();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -67,6 +76,15 @@ class ExtensionsManager {
|
|||||||
return this.experimentalExtension;
|
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.
|
* 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