Fix ResizeMethod usage
This commit is contained in:
parent
533c9fed64
commit
2a40bc87cc
5 changed files with 11 additions and 26 deletions
|
@ -16,7 +16,7 @@
|
|||
|
||||
import {MatrixClientPeg} from "../MatrixClientPeg";
|
||||
import {IMediaEventContent, IPreparedMedia, prepEventContentAsMedia} from "./models/IMediaEventContent";
|
||||
import {ResizeMode} from "./models/ResizeMode";
|
||||
import {ResizeMethod} from "../Avatar";
|
||||
|
||||
// Populate this class with the details of your customisations when copying it.
|
||||
|
||||
|
@ -87,7 +87,7 @@ export class Media {
|
|||
* @param {"scale"|"crop"} mode The desired thumbnailing mode. Defaults to scale.
|
||||
* @returns {string} The HTTP URL which points to the thumbnail.
|
||||
*/
|
||||
public getThumbnailHttp(width: number, height: number, mode: ResizeMode = "scale"): string | null | undefined {
|
||||
public getThumbnailHttp(width: number, height: number, mode: ResizeMethod = "scale"): string | null | undefined {
|
||||
if (!this.hasThumbnail) return null;
|
||||
return MatrixClientPeg.get().mxcUrlToHttp(this.thumbnailMxc, width, height, mode);
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ export class Media {
|
|||
* @param {"scale"|"crop"} mode The desired thumbnailing mode. Defaults to scale.
|
||||
* @returns {string} The HTTP URL which points to the thumbnail.
|
||||
*/
|
||||
public getThumbnailOfSourceHttp(width: number, height: number, mode: ResizeMode = "scale"): string {
|
||||
public getThumbnailOfSourceHttp(width: number, height: number, mode: ResizeMethod = "scale"): string {
|
||||
return MatrixClientPeg.get().mxcUrlToHttp(this.srcMxc, width, height, mode);
|
||||
}
|
||||
|
||||
|
@ -132,7 +132,7 @@ export class Media {
|
|||
* @param {"scale"|"crop"} mode The desired thumbnailing mode. Defaults to scale.
|
||||
* @returns {Promise<Response>} Resolves to the server's response for chaining.
|
||||
*/
|
||||
public downloadThumbnail(width: number, height: number, mode: ResizeMode = "scale"): Promise<Response> {
|
||||
public downloadThumbnail(width: number, height: number, mode: ResizeMethod = "scale"): Promise<Response> {
|
||||
if (!this.hasThumbnail) throw new Error("Cannot download non-existent thumbnail");
|
||||
return fetch(this.getThumbnailHttp(width, height, mode));
|
||||
}
|
||||
|
@ -144,7 +144,7 @@ export class Media {
|
|||
* @param {"scale"|"crop"} mode The desired thumbnailing mode. Defaults to scale.
|
||||
* @returns {Promise<Response>} Resolves to the server's response for chaining.
|
||||
*/
|
||||
public downloadThumbnailOfSource(width: number, height: number, mode: ResizeMode = "scale"): Promise<Response> {
|
||||
public downloadThumbnailOfSource(width: number, height: number, mode: ResizeMethod = "scale"): Promise<Response> {
|
||||
return fetch(this.getThumbnailOfSourceHttp(width, height, mode));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
/*
|
||||
* Copyright 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export type ResizeMode = "scale" | "crop";
|
Loading…
Add table
Add a link
Reference in a new issue