Convert a bunch more js-sdk imports to absolute paths
Turns out a lot of the typescript warnings about improper warnings were correct. TypeScript appears to be pulling in two copies of the js-sdk when we do this, which can lead to type conflicts (or worse: the wrong code entirely). We fix this at the webpack level by explicitly importing from `src`, but some alternative build structures have broken tests because of this - jest ends up pulling in the "wrong" js-sdk, breaking things.
This commit is contained in:
parent
e4b7a307ba
commit
1d9d0cd7be
40 changed files with 77 additions and 70 deletions
|
@ -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';
|
||||
|
|
|
@ -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";
|
||||
/**
|
||||
|
|
|
@ -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';
|
||||
|
||||
|
|
|
@ -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}`);
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue