+ {_t(
+ "This usually only affects how the room is processed on the server. If you're " +
+ "having problems with your %(brand)s, please report a bug.",
+ {
+ brand,
+ },
+ {
+ "a": (sub) => {
+ return {sub};
+ },
+ },
+ )}
+
+ );
+ }
+
return (
-
- {_t(
- "This usually only affects how the room is processed on the server. If you're " +
- "having problems with your %(brand)s, please report a bug.",
- {
- brand,
- },
- {
- "a": (sub) => {
- return {sub};
- },
- },
- )}
-
+ {bugReports}
{_t(
"You'll upgrade this room from to .",
diff --git a/src/components/views/dialogs/TabbedIntegrationManagerDialog.js b/src/components/views/dialogs/TabbedIntegrationManagerDialog.js
index 07e29adcff..618b0b4347 100644
--- a/src/components/views/dialogs/TabbedIntegrationManagerDialog.js
+++ b/src/components/views/dialogs/TabbedIntegrationManagerDialog.js
@@ -17,7 +17,7 @@ limitations under the License.
import React from 'react';
import PropTypes from 'prop-types';
import {IntegrationManagers} from "../../../integrations/IntegrationManagers";
-import {Room} from "matrix-js-sdk";
+import {Room} from "matrix-js-sdk/src/models/room";
import * as sdk from '../../../index';
import {dialogTermsInteractionCallback, TermsNotSignedError} from "../../../Terms";
import classNames from 'classnames';
diff --git a/src/components/views/dialogs/TermsDialog.js b/src/components/views/dialogs/TermsDialog.js
index 72e6c3f3a0..e8625ec6cb 100644
--- a/src/components/views/dialogs/TermsDialog.js
+++ b/src/components/views/dialogs/TermsDialog.js
@@ -20,8 +20,8 @@ import PropTypes from 'prop-types';
import * as sdk from '../../../index';
import { _t, pickBestLanguage } from '../../../languageHandler';
-import Matrix from 'matrix-js-sdk';
import {replaceableComponent} from "../../../utils/replaceableComponent";
+import {SERVICE_TYPES} from "matrix-js-sdk/src/service-types";
class TermsCheckbox extends React.PureComponent {
static propTypes = {
@@ -85,22 +85,22 @@ export default class TermsDialog extends React.PureComponent {
_nameForServiceType(serviceType, host) {
switch (serviceType) {
- case Matrix.SERVICE_TYPES.IS:
+ case SERVICE_TYPES.IS:
return
{_t("Identity Server")}
({host})
;
- case Matrix.SERVICE_TYPES.IM:
+ case SERVICE_TYPES.IM:
return {_t("Integration Manager")}
({host})
;
}
}
_summaryForServiceType(serviceType) {
switch (serviceType) {
- case Matrix.SERVICE_TYPES.IS:
+ case SERVICE_TYPES.IS:
return
{_t("Find others by phone or email")}
{_t("Be found by phone or email")}
;
- case Matrix.SERVICE_TYPES.IM:
+ case SERVICE_TYPES.IM:
return
{_t("Use bots, bridges, widgets and sticker packs")}
;
diff --git a/src/components/views/dialogs/security/RestoreKeyBackupDialog.js b/src/components/views/dialogs/security/RestoreKeyBackupDialog.js
index ca28ca094c..1fafe03d95 100644
--- a/src/components/views/dialogs/security/RestoreKeyBackupDialog.js
+++ b/src/components/views/dialogs/security/RestoreKeyBackupDialog.js
@@ -19,7 +19,7 @@ import React from 'react';
import PropTypes from 'prop-types';
import * as sdk from '../../../../index';
import {MatrixClientPeg} from '../../../../MatrixClientPeg';
-import { MatrixClient } from 'matrix-js-sdk';
+import { MatrixClient } from 'matrix-js-sdk/src/client';
import { _t } from '../../../../languageHandler';
import { accessSecretStorage } from '../../../../SecurityManager';
diff --git a/src/components/views/elements/Pill.js b/src/components/views/elements/Pill.js
index e61d312305..a8e16813e6 100644
--- a/src/components/views/elements/Pill.js
+++ b/src/components/views/elements/Pill.js
@@ -17,7 +17,8 @@ import React from 'react';
import * as sdk from '../../../index';
import dis from '../../../dispatcher/dispatcher';
import classNames from 'classnames';
-import { Room, RoomMember } from 'matrix-js-sdk';
+import { Room } from 'matrix-js-sdk/src/models/room';
+import { RoomMember } from 'matrix-js-sdk/src/models/room-member';
import PropTypes from 'prop-types';
import {MatrixClientPeg} from '../../../MatrixClientPeg';
import FlairStore from "../../../stores/FlairStore";
diff --git a/src/components/views/elements/ReplyThread.js b/src/components/views/elements/ReplyThread.js
index 2e0cc50435..870803995d 100644
--- a/src/components/views/elements/ReplyThread.js
+++ b/src/components/views/elements/ReplyThread.js
@@ -21,7 +21,7 @@ import {_t} from '../../../languageHandler';
import PropTypes from 'prop-types';
import dis from '../../../dispatcher/dispatcher';
import {wantsDateSeparator} from '../../../DateUtils';
-import {MatrixEvent} from 'matrix-js-sdk';
+import {MatrixEvent} from 'matrix-js-sdk/src/models/event';
import {makeUserPermalink, RoomPermalinkCreator} from "../../../utils/permalinks/Permalinks";
import SettingsStore from "../../../settings/SettingsStore";
import {LayoutPropType} from "../../../settings/Layout";
diff --git a/src/components/views/messages/EditHistoryMessage.js b/src/components/views/messages/EditHistoryMessage.js
index a298f7eb68..e2eda1e12a 100644
--- a/src/components/views/messages/EditHistoryMessage.js
+++ b/src/components/views/messages/EditHistoryMessage.js
@@ -19,7 +19,7 @@ import PropTypes from 'prop-types';
import * as HtmlUtils from '../../../HtmlUtils';
import { editBodyDiffToHtml } from '../../../utils/MessageDiffUtils';
import {formatTime} from '../../../DateUtils';
-import {MatrixEvent} from 'matrix-js-sdk';
+import {MatrixEvent} from 'matrix-js-sdk/src/models/event';
import {pillifyLinks, unmountPills} from '../../../utils/pillify';
import { _t } from '../../../languageHandler';
import * as sdk from '../../../index';
diff --git a/src/components/views/messages/MessageActionBar.js b/src/components/views/messages/MessageActionBar.js
index c33debe3f5..5a6e7d87b7 100644
--- a/src/components/views/messages/MessageActionBar.js
+++ b/src/components/views/messages/MessageActionBar.js
@@ -18,7 +18,7 @@ limitations under the License.
import React, {useEffect} from 'react';
import PropTypes from 'prop-types';
-import { EventStatus } from 'matrix-js-sdk';
+import { EventStatus } from 'matrix-js-sdk/src/models/event';
import { _t } from '../../../languageHandler';
import * as sdk from '../../../index';
diff --git a/src/components/views/room_settings/RelatedGroupSettings.js b/src/components/views/room_settings/RelatedGroupSettings.js
index f82e238722..272ecd1228 100644
--- a/src/components/views/room_settings/RelatedGroupSettings.js
+++ b/src/components/views/room_settings/RelatedGroupSettings.js
@@ -16,7 +16,7 @@ limitations under the License.
import React from 'react';
import PropTypes from 'prop-types';
-import {MatrixEvent} from 'matrix-js-sdk';
+import {MatrixEvent} from 'matrix-js-sdk/src/models/event';
import * as sdk from '../../../index';
import { _t } from '../../../languageHandler';
import Modal from '../../../Modal';
diff --git a/src/components/views/rooms/EditMessageComposer.js b/src/components/views/rooms/EditMessageComposer.js
index 6ecb2bd549..be04a50798 100644
--- a/src/components/views/rooms/EditMessageComposer.js
+++ b/src/components/views/rooms/EditMessageComposer.js
@@ -27,7 +27,7 @@ import {parseEvent} from '../../../editor/deserialize';
import {PartCreator} from '../../../editor/parts';
import EditorStateTransfer from '../../../utils/EditorStateTransfer';
import classNames from 'classnames';
-import {EventStatus} from 'matrix-js-sdk';
+import {EventStatus} from 'matrix-js-sdk/src/models/event';
import BasicMessageComposer from "./BasicMessageComposer";
import {Key, isOnlyCtrlOrCmdKeyEvent} from "../../../Keyboard";
import MatrixClientContext from "../../../contexts/MatrixClientContext";
diff --git a/src/components/views/rooms/EventTile.js b/src/components/views/rooms/EventTile.js
index cbe3252c2b..644d64d322 100644
--- a/src/components/views/rooms/EventTile.js
+++ b/src/components/views/rooms/EventTile.js
@@ -28,7 +28,7 @@ import * as sdk from "../../../index";
import dis from '../../../dispatcher/dispatcher';
import SettingsStore from "../../../settings/SettingsStore";
import {Layout, LayoutPropType} from "../../../settings/Layout";
-import {EventStatus} from 'matrix-js-sdk';
+import {EventStatus} from 'matrix-js-sdk/src/models/event';
import {formatTime} from "../../../DateUtils";
import {MatrixClientPeg} from '../../../MatrixClientPeg';
import {ALL_RULE_TYPES} from "../../../mjolnir/BanList";
diff --git a/src/components/views/rooms/RoomTile.tsx b/src/components/views/rooms/RoomTile.tsx
index 07de70fe45..79db460275 100644
--- a/src/components/views/rooms/RoomTile.tsx
+++ b/src/components/views/rooms/RoomTile.tsx
@@ -333,6 +333,17 @@ export default class RoomTile extends React.PureComponent {
this.setState({generalMenuPosition: null}); // hide the menu
};
+ private onInviteClick = (ev: ButtonEvent) => {
+ ev.preventDefault();
+ ev.stopPropagation();
+
+ dis.dispatch({
+ action: 'view_invite',
+ roomId: this.props.room.roomId,
+ });
+ this.setState({generalMenuPosition: null}); // hide the menu
+ };
+
private async saveNotifState(ev: ButtonEvent, newState: Volume) {
ev.preventDefault();
ev.stopPropagation();
@@ -453,6 +464,8 @@ export default class RoomTile extends React.PureComponent {
const isLowPriority = roomTags.includes(DefaultTagID.LowPriority);
const lowPriorityLabel = _t("Low Priority");
+ const userId = MatrixClientPeg.get().getUserId();
+ const canInvite = this.props.room.canInvite(userId);
contextMenu = {
label={lowPriorityLabel}
iconClassName="mx_RoomTile_iconArrowDown"
/>
-
+ {canInvite ? (
+
+ ) : null}
;
}
interface IItemState {
@@ -299,7 +300,8 @@ export class SpaceItem extends React.PureComponent {
const isNarrow = this.props.isPanelCollapsed;
const collapsed = this.state.collapsed || forceCollapsed;
- const childSpaces = SpaceStore.instance.getChildSpaces(space.roomId);
+ const childSpaces = SpaceStore.instance.getChildSpaces(space.roomId)
+ .filter(s => !this.props.parents?.has(s.roomId));
const isActive = activeSpaces.includes(space);
const itemClasses = classNames({
"mx_SpaceItem": true,
@@ -312,11 +314,17 @@ export class SpaceItem extends React.PureComponent {
mx_SpaceButton_narrow: isNarrow,
});
const notificationState = SpaceStore.instance.getNotificationState(space.roomId);
- const childItems = childSpaces && !collapsed ? : null;
+
+ let childItems;
+ if (childSpaces && !collapsed) {
+ childItems = ;
+ }
+
let notifBadge;
if (notificationState) {
notifBadge =
@@ -383,12 +391,14 @@ interface ITreeLevelProps {
spaces: Room[];
activeSpaces: Room[];
isNested?: boolean;
+ parents: Set
;
}
const SpaceTreeLevel: React.FC = ({
spaces,
activeSpaces,
isNested,
+ parents,
}) => {
return
{spaces.map(s => {
@@ -397,6 +407,7 @@ const SpaceTreeLevel: React.FC = ({
activeSpaces={activeSpaces}
space={s}
isNested={isNested}
+ parents={parents}
/>);
})}
;
diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json
index 63449eb99f..63b19831bb 100644
--- a/src/i18n/strings/en_EN.json
+++ b/src/i18n/strings/en_EN.json
@@ -1601,6 +1601,7 @@
"Favourited": "Favourited",
"Favourite": "Favourite",
"Low Priority": "Low Priority",
+ "Invite People": "Invite People",
"Leave Room": "Leave Room",
"Room options": "Room options",
"%(count)s unread messages including mentions.|other": "%(count)s unread messages including mentions.",
@@ -2150,10 +2151,10 @@
"Add comment": "Add comment",
"Comment": "Comment",
"There are two ways you can provide feedback and help us improve %(brand)s.": "There are two ways you can provide feedback and help us improve %(brand)s.",
+ "PRO TIP: If you start a bug, please submit debug logs to help us track down the problem.": "PRO TIP: If you start a bug, please submit debug logs to help us track down the problem.",
"Feedback": "Feedback",
"Report a bug": "Report a bug",
"Please view existing bugs on Github first. No match? Start a new one.": "Please view existing bugs on Github first. No match? Start a new one.",
- "PRO TIP: If you start a bug, please submit debug logs to help us track down the problem.": "PRO TIP: If you start a bug, please submit debug logs to help us track down the problem.",
"Send feedback": "Send feedback",
"Confirm abort of host creation": "Confirm abort of host creation",
"Are you sure you wish to abort creation of the host? The process cannot be continued.": "Are you sure you wish to abort creation of the host? The process cannot be continued.",
@@ -2201,6 +2202,7 @@
"Go": "Go",
"Invite to %(spaceName)s": "Invite to %(spaceName)s",
"Unnamed Space": "Unnamed Space",
+ "Invite to %(roomName)s": "Invite to %(roomName)s",
"Invite someone using their name, email address, username (like ) or share this space.": "Invite someone using their name, email address, username (like ) or share this space.",
"Invite someone using their name, username (like ) or share this space.": "Invite someone using their name, username (like ) or share this space.",
"Invite someone using their name, email address, username (like ) or share this room.": "Invite someone using their name, email address, username (like ) or share this room.",
@@ -2269,8 +2271,9 @@
"Automatically invite users": "Automatically invite users",
"Upgrade private room": "Upgrade private room",
"Upgrade public room": "Upgrade public room",
- "Upgrading a room is an advanced action and is usually recommended when a room is unstable due to bugs, missing features or security vulnerabilities.": "Upgrading a room is an advanced action and is usually recommended when a room is unstable due to bugs, missing features or security vulnerabilities.",
+ "This usually only affects how the room is processed on the server. If you're having problems with your %(brand)s, please report a bug.": "This usually only affects how the room is processed on the server. If you're having problems with your %(brand)s, please report a bug.",
"This usually only affects how the room is processed on the server. If you're having problems with your %(brand)s, please report a bug.": "This usually only affects how the room is processed on the server. If you're having problems with your %(brand)s, please report a bug.",
+ "Upgrading a room is an advanced action and is usually recommended when a room is unstable due to bugs, missing features or security vulnerabilities.": "Upgrading a room is an advanced action and is usually recommended when a room is unstable due to bugs, missing features or security vulnerabilities.",
"You'll upgrade this room from to .": "You'll upgrade this room from to .",
"Resend": "Resend",
"You're all caught up.": "You're all caught up.",
@@ -2550,6 +2553,8 @@
"Logout": "Logout",
"%(creator)s created this DM.": "%(creator)s created this DM.",
"%(creator)s created and configured the room.": "%(creator)s created and configured the room.",
+ "%(count)s messages deleted.|other": "%(count)s messages deleted.",
+ "%(count)s messages deleted.|one": "%(count)s message deleted.",
"Your Communities": "Your Communities",
"Did you know: you can use communities to filter your %(brand)s experience!": "Did you know: you can use communities to filter your %(brand)s experience!",
"To set up a filter, drag a community avatar over to the filter panel on the far left hand side of the screen. You can click on an avatar in the filter panel at any time to see only the rooms and people associated with that community.": "To set up a filter, drag a community avatar over to the filter panel on the far left hand side of the screen. You can click on an avatar in the filter panel at any time to see only the rooms and people associated with that community.",
diff --git a/src/index.js b/src/index.js
index 008e15ad90..e360c04f4f 100644
--- a/src/index.js
+++ b/src/index.js
@@ -28,3 +28,7 @@ export function resetSkin() {
export function getComponent(componentName) {
return Skinner.getComponent(componentName);
}
+
+// Import the js-sdk so the proper `request` object can be set. This does some
+// magic with the browser injection to make all subsequent imports work fine.
+import "matrix-js-sdk";
diff --git a/src/indexing/EventIndex.js b/src/indexing/EventIndex.js
index fa263a2a55..2dcdb9e3a3 100644
--- a/src/indexing/EventIndex.js
+++ b/src/indexing/EventIndex.js
@@ -16,7 +16,8 @@ limitations under the License.
import PlatformPeg from "../PlatformPeg";
import {MatrixClientPeg} from "../MatrixClientPeg";
-import {EventTimeline, RoomMember} from 'matrix-js-sdk';
+import {RoomMember} from 'matrix-js-sdk/src/models/room-member';
+import {EventTimeline} from 'matrix-js-sdk/src/models/event-timeline';
import {sleep} from "../utils/promise";
import SettingsStore from "../settings/SettingsStore";
import {EventEmitter} from "events";
diff --git a/src/rageshake/rageshake.js b/src/rageshake/rageshake.js
index 8eb77bb3ae..b886f369df 100644
--- a/src/rageshake/rageshake.js
+++ b/src/rageshake/rageshake.js
@@ -434,15 +434,37 @@ function selectQuery(store, keyRange, resultMapper) {
/**
* Configure rage shaking support for sending bug reports.
* Modifies globals.
+ * @param {boolean} setUpPersistence When true (default), the persistence will
+ * be set up immediately for the logs.
* @return {Promise} Resolves when set up.
*/
-export function init() {
+export function init(setUpPersistence = true) {
if (global.mx_rage_initPromise) {
return global.mx_rage_initPromise;
}
global.mx_rage_logger = new ConsoleLogger();
global.mx_rage_logger.monkeyPatch(window.console);
+ if (setUpPersistence) {
+ return tryInitStorage();
+ }
+
+ global.mx_rage_initPromise = Promise.resolve();
+ return global.mx_rage_initPromise;
+}
+
+/**
+ * Try to start up the rageshake storage for logs. If not possible (client unsupported)
+ * then this no-ops.
+ * @return {Promise} Resolves when complete.
+ */
+export function tryInitStorage() {
+ if (global.mx_rage_initStoragePromise) {
+ return global.mx_rage_initStoragePromise;
+ }
+
+ console.log("Configuring rageshake persistence...");
+
// just *accessing* indexedDB throws an exception in firefox with
// indexeddb disabled.
let indexedDB;
@@ -452,11 +474,11 @@ export function init() {
if (indexedDB) {
global.mx_rage_store = new IndexedDBLogStore(indexedDB, global.mx_rage_logger);
- global.mx_rage_initPromise = global.mx_rage_store.connect();
- return global.mx_rage_initPromise;
+ global.mx_rage_initStoragePromise = global.mx_rage_store.connect();
+ return global.mx_rage_initStoragePromise;
}
- global.mx_rage_initPromise = Promise.resolve();
- return global.mx_rage_initPromise;
+ global.mx_rage_initStoragePromise = Promise.resolve();
+ return global.mx_rage_initStoragePromise;
}
export function flush() {
diff --git a/src/stores/OwnProfileStore.ts b/src/stores/OwnProfileStore.ts
index 5e722877e2..bb45456f1e 100644
--- a/src/stores/OwnProfileStore.ts
+++ b/src/stores/OwnProfileStore.ts
@@ -29,13 +29,22 @@ interface IState {
avatarUrl?: string;
}
+const KEY_DISPLAY_NAME = "mx_profile_displayname";
+const KEY_AVATAR_URL = "mx_profile_avatar_url";
+
export class OwnProfileStore extends AsyncStoreWithClient {
private static internalInstance = new OwnProfileStore();
private monitoredUser: User;
private constructor() {
- super(defaultDispatcher, {});
+ // seed from localstorage because otherwise we won't get these values until a whole network
+ // round-trip after the client is ready, and we often load widgets in that time, and we'd
+ // and up passing them an incorrect display name
+ super(defaultDispatcher, {
+ displayName: window.localStorage.getItem(KEY_DISPLAY_NAME),
+ avatarUrl: window.localStorage.getItem(KEY_AVATAR_URL),
+ });
}
public static get instance(): OwnProfileStore {
@@ -115,6 +124,16 @@ export class OwnProfileStore extends AsyncStoreWithClient {
// We specifically do not use the User object we stored for profile info as it
// could easily be wrong (such as per-room instead of global profile).
const profileInfo = await this.matrixClient.getProfileInfo(this.matrixClient.getUserId());
+ if (profileInfo.displayname) {
+ window.localStorage.setItem(KEY_DISPLAY_NAME, profileInfo.displayname);
+ } else {
+ window.localStorage.removeItem(KEY_DISPLAY_NAME);
+ }
+ if (profileInfo.avatar_url) {
+ window.localStorage.setItem(KEY_AVATAR_URL, profileInfo.avatar_url);
+ } else {
+ window.localStorage.removeItem(KEY_AVATAR_URL);
+ }
await this.updateState({displayName: profileInfo.displayname, avatarUrl: profileInfo.avatar_url});
};
diff --git a/src/stores/room-list/RoomListStore.ts b/src/stores/room-list/RoomListStore.ts
index 3f415f946d..074c2e569d 100644
--- a/src/stores/room-list/RoomListStore.ts
+++ b/src/stores/room-list/RoomListStore.ts
@@ -655,6 +655,18 @@ export class RoomListStoreClass extends AsyncStoreWithClient {
if (!algorithmTags) return [DefaultTagID.Untagged];
return algorithmTags;
}
+
+ /**
+ * Manually update a room with a given cause. This should only be used if the
+ * room list store would otherwise be incapable of doing the update itself. Note
+ * that this may race with the room list's regular operation.
+ * @param {Room} room The room to update.
+ * @param {RoomUpdateCause} cause The cause to update for.
+ */
+ public async manualRoomUpdate(room: Room, cause: RoomUpdateCause) {
+ await this.handleRoomUpdate(room, cause);
+ this.updateFn.trigger();
+ }
}
export default class RoomListStore {
diff --git a/src/utils/AutoDiscoveryUtils.js b/src/utils/AutoDiscoveryUtils.js
index 18b6451d3e..614aa4cea8 100644
--- a/src/utils/AutoDiscoveryUtils.js
+++ b/src/utils/AutoDiscoveryUtils.js
@@ -16,7 +16,7 @@ limitations under the License.
*/
import React from 'react';
-import {AutoDiscovery} from "matrix-js-sdk";
+import {AutoDiscovery} from "matrix-js-sdk/src/autodiscovery";
import {_t, _td, newTranslatableError} from "../languageHandler";
import {makeType} from "./TypeUtils";
import SdkConfig from '../SdkConfig';
diff --git a/src/utils/EventUtils.js b/src/utils/EventUtils.js
index 6558a11ed4..be21896417 100644
--- a/src/utils/EventUtils.js
+++ b/src/utils/EventUtils.js
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
-import { EventStatus } from 'matrix-js-sdk';
+import { EventStatus } from 'matrix-js-sdk/src/models/event';
import {MatrixClientPeg} from '../MatrixClientPeg';
import shouldHideEvent from "../shouldHideEvent";
/**
diff --git a/src/utils/IdentityServerUtils.js b/src/utils/IdentityServerUtils.js
index 093d4eeabf..5ece308954 100644
--- a/src/utils/IdentityServerUtils.js
+++ b/src/utils/IdentityServerUtils.js
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
-import { SERVICE_TYPES } from 'matrix-js-sdk';
+import { SERVICE_TYPES } from 'matrix-js-sdk/src/service-types';
import SdkConfig from '../SdkConfig';
import {MatrixClientPeg} from '../MatrixClientPeg';
diff --git a/src/utils/StorageManager.js b/src/utils/StorageManager.js
index c90281bacf..23c27a2d1c 100644
--- a/src/utils/StorageManager.js
+++ b/src/utils/StorageManager.js
@@ -14,9 +14,10 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
-import Matrix from 'matrix-js-sdk';
import {LocalStorageCryptoStore} from 'matrix-js-sdk/src/crypto/store/localStorage-crypto-store';
import Analytics from '../Analytics';
+import {IndexedDBStore} from "matrix-js-sdk/src/store/indexeddb";
+import {IndexedDBCryptoStore} from "matrix-js-sdk/src/crypto/store/indexeddb-crypto-store";
const localStorage = window.localStorage;
@@ -132,7 +133,7 @@ export async function checkConsistency() {
async function checkSyncStore() {
let exists = false;
try {
- exists = await Matrix.IndexedDBStore.exists(
+ exists = await IndexedDBStore.exists(
indexedDB, SYNC_STORE_NAME,
);
log(`Sync store using IndexedDB contains data? ${exists}`);
@@ -148,7 +149,7 @@ async function checkSyncStore() {
async function checkCryptoStore() {
let exists = false;
try {
- exists = await Matrix.IndexedDBCryptoStore.exists(
+ exists = await IndexedDBCryptoStore.exists(
indexedDB, CRYPTO_STORE_NAME,
);
log(`Crypto store using IndexedDB contains data? ${exists}`);
diff --git a/src/utils/createMatrixClient.js b/src/utils/createMatrixClient.js
index c8ff35a584..f5e196d846 100644
--- a/src/utils/createMatrixClient.js
+++ b/src/utils/createMatrixClient.js
@@ -14,7 +14,10 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
-import * as Matrix from 'matrix-js-sdk';
+import {createClient} from "matrix-js-sdk/src/matrix";
+import {IndexedDBCryptoStore} from "matrix-js-sdk/src/crypto/store/indexeddb-crypto-store";
+import {WebStorageSessionStore} from "matrix-js-sdk/src/store/session/webstorage";
+import {IndexedDBStore} from "matrix-js-sdk/src/store/indexeddb";
const localStorage = window.localStorage;
@@ -44,7 +47,7 @@ export default function createMatrixClient(opts) {
};
if (indexedDB && localStorage) {
- storeOpts.store = new Matrix.IndexedDBStore({
+ storeOpts.store = new IndexedDBStore({
indexedDB: indexedDB,
dbName: "riot-web-sync",
localStorage: localStorage,
@@ -53,18 +56,18 @@ export default function createMatrixClient(opts) {
}
if (localStorage) {
- storeOpts.sessionStore = new Matrix.WebStorageSessionStore(localStorage);
+ storeOpts.sessionStore = new WebStorageSessionStore(localStorage);
}
if (indexedDB) {
- storeOpts.cryptoStore = new Matrix.IndexedDBCryptoStore(
+ storeOpts.cryptoStore = new IndexedDBCryptoStore(
indexedDB, "matrix-js-sdk:crypto",
);
}
opts = Object.assign(storeOpts, opts);
- return Matrix.createClient(opts);
+ return createClient(opts);
}
createMatrixClient.indexedDbWorkerScript = null;
diff --git a/src/utils/pages.js b/src/utils/pages.ts
similarity index 68%
rename from src/utils/pages.js
rename to src/utils/pages.ts
index d63ca3f2c7..bae76be29d 100644
--- a/src/utils/pages.js
+++ b/src/utils/pages.ts
@@ -1,5 +1,5 @@
/*
-Copyright 2019 New Vector Ltd
+Copyright 2019, 2021 The Matrix.org Foundation C.I.C.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,12 +14,12 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
-export function getHomePageUrl(appConfig) {
+import { ConfigOptions } from "../SdkConfig";
+
+export function getHomePageUrl(appConfig: ConfigOptions): string | null {
const pagesConfig = appConfig.embeddedPages;
- let pageUrl = null;
- if (pagesConfig) {
- pageUrl = pagesConfig.homeUrl;
- }
+ let pageUrl = pagesConfig?.homeUrl;
+
if (!pageUrl) {
// This is a deprecated config option for the home page
// (despite the name, given we also now have a welcome
@@ -29,3 +29,8 @@ export function getHomePageUrl(appConfig) {
return pageUrl;
}
+
+export function shouldUseLoginForWelcome(appConfig: ConfigOptions): boolean {
+ const pagesConfig = appConfig.embeddedPages;
+ return pagesConfig?.loginForWelcome === true;
+}