Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Throw error if both browser-index and (node) index are loaded #2211

Merged
merged 2 commits into from
Mar 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/browser-index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ import queryString from "qs";

import * as matrixcs from "./matrix";

if (matrixcs.getRequest()) {
throw new Error("Multiple matrix-js-sdk entrypoints detected!");
}

matrixcs.request(function(opts, fn) {
// We manually fix the query string for browser-request because
// it doesn't correctly handle cases like ?via=one&via=two. Instead
Expand Down
13 changes: 3 additions & 10 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8712,18 +8712,11 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa

const queryParams: Record<string, string | string[]> = {
suggested_only: String(suggestedOnly),
max_depth: maxDepth?.toString(),
from: fromToken,
limit: limit?.toString(),
};

if (limit !== undefined) {
queryParams["limit"] = limit.toString();
}
if (maxDepth !== undefined) {
queryParams["max_depth"] = maxDepth.toString();
}
if (fromToken !== undefined) {
queryParams["from"] = fromToken;
}

return this.http.authedRequest<IRoomHierarchy>(undefined, Method.Get, path, queryParams, undefined, {
prefix: PREFIX_V1,
}).catch(e => {
Expand Down
4 changes: 4 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ import * as matrixcs from "./matrix";
import * as utils from "./utils";
import { logger } from './logger';

if (matrixcs.getRequest()) {
throw new Error("Multiple matrix-js-sdk entrypoints detected!");
}

matrixcs.request(request);

try {
Expand Down