You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-12-05 17:02:07 +03:00
Make ContentRepo a class for easier importing
Exporting it the way we were was causing problems for webpack way down the line, so we export it differently here to get around that. We also have to fix all the import references so we import the right thing.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import * as ContentRepo from "../../src/content-repo";
|
||||
import {ContentRepo} from "../../src/content-repo";
|
||||
|
||||
describe("ContentRepo", function() {
|
||||
const baseUrl = "https://my.home.server";
|
||||
|
||||
@@ -36,7 +36,7 @@ import {createNewMatrixCall} from "./webrtc/call";
|
||||
import * as utils from './utils';
|
||||
import {sleep} from './utils';
|
||||
import {MatrixError, PREFIX_MEDIA_R0, PREFIX_UNSTABLE} from "./http-api";
|
||||
import * as contentRepo from "./content-repo";
|
||||
import {ContentRepo} from "./content-repo";
|
||||
import * as ContentHelpers from "./content-helpers";
|
||||
import * as olmlib from "./crypto/olmlib";
|
||||
import {ReEmitter} from './ReEmitter';
|
||||
@@ -3132,7 +3132,7 @@ MatrixClient.prototype.setAvatarUrl = function(url, callback) {
|
||||
*/
|
||||
MatrixClient.prototype.mxcUrlToHttp =
|
||||
function(mxcUrl, width, height, resizeMethod, allowDirectLinks) {
|
||||
return contentRepo.getHttpUriForMxc(
|
||||
return ContentRepo.getHttpUriForMxc(
|
||||
this.baseUrl, mxcUrl, width, height, resizeMethod, allowDirectLinks,
|
||||
);
|
||||
};
|
||||
|
||||
@@ -20,7 +20,8 @@ limitations under the License.
|
||||
|
||||
import * as utils from "./utils";
|
||||
|
||||
/**
|
||||
export class ContentRepo {
|
||||
/**
|
||||
* Get the HTTP URL for an MXC URI.
|
||||
* @param {string} baseUrl The base homeserver url which has a content repo.
|
||||
* @param {string} mxc The mxc:// URI.
|
||||
@@ -34,7 +35,7 @@ import * as utils from "./utils";
|
||||
* for such URLs.
|
||||
* @return {string} The complete URL to the content.
|
||||
*/
|
||||
export function getHttpUriForMxc(baseUrl, mxc, width, height,
|
||||
static getHttpUriForMxc(baseUrl, mxc, width, height,
|
||||
resizeMethod, allowDirectLinks) {
|
||||
if (typeof mxc !== "string" || !mxc) {
|
||||
return '';
|
||||
@@ -74,9 +75,9 @@ export function getHttpUriForMxc(baseUrl, mxc, width, height,
|
||||
return baseUrl + prefix + serverAndMediaId +
|
||||
(utils.keys(params).length === 0 ? "" :
|
||||
("?" + utils.encodeParams(params))) + fragment;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Get an identicon URL from an arbitrary string.
|
||||
* @param {string} baseUrl The base homeserver url which has a content repo.
|
||||
* @param {string} identiconString The string to create an identicon for.
|
||||
@@ -85,7 +86,7 @@ export function getHttpUriForMxc(baseUrl, mxc, width, height,
|
||||
* @return {string} The complete URL to the identicon.
|
||||
* @deprecated This is no longer in the specification.
|
||||
*/
|
||||
export function getIdenticonUri(baseUrl, identiconString, width, height) {
|
||||
static getIdenticonUri(baseUrl, identiconString, width, height) {
|
||||
if (!identiconString) {
|
||||
return null;
|
||||
}
|
||||
@@ -106,4 +107,5 @@ export function getIdenticonUri(baseUrl, identiconString, width, height) {
|
||||
return baseUrl + path +
|
||||
(utils.keys(params).length === 0 ? "" :
|
||||
("?" + utils.encodeParams(params)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,8 +44,8 @@ export * from "./store/indexeddb";
|
||||
export * from "./store/session/webstorage";
|
||||
export * from "./crypto/store/memory-crypto-store";
|
||||
export * from "./crypto/store/indexeddb-crypto-store";
|
||||
export * from "./content-repo";
|
||||
export const ContentHelpers = import("./content-helpers");
|
||||
export const ContentRepo = import("./content-repo");
|
||||
export {
|
||||
createNewMatrixCall,
|
||||
setAudioOutput as setMatrixCallAudioOutput,
|
||||
|
||||
@@ -20,7 +20,7 @@ limitations under the License.
|
||||
*/
|
||||
|
||||
import {EventEmitter} from "events";
|
||||
import * as ContentRepo from "../content-repo";
|
||||
import {ContentRepo} from "../content-repo";
|
||||
import * as utils from "../utils";
|
||||
|
||||
/**
|
||||
|
||||
@@ -23,7 +23,7 @@ limitations under the License.
|
||||
import {EventEmitter} from "events";
|
||||
import {EventTimelineSet} from "./event-timeline-set";
|
||||
import {EventTimeline} from "./event-timeline";
|
||||
import * as ContentRepo from "../content-repo";
|
||||
import {ContentRepo} from "../content-repo";
|
||||
import * as utils from "../utils";
|
||||
import {EventStatus, MatrixEvent} from "./event";
|
||||
import {RoomMember} from "./room-member";
|
||||
|
||||
Reference in New Issue
Block a user