Fix ResizeMethod usage
							parent
							
								
									533c9fed64
								
							
						
					
					
						commit
						2a40bc87cc
					
				|  | @ -25,6 +25,7 @@ import AccessibleButton from '../elements/AccessibleButton'; | |||
| import MatrixClientContext from "../../../contexts/MatrixClientContext"; | ||||
| import {useEventEmitter} from "../../../hooks/useEventEmitter"; | ||||
| import {toPx} from "../../../utils/units"; | ||||
| import {ResizeMethod} from "../../../Avatar"; | ||||
| 
 | ||||
| interface IProps { | ||||
|     name: string; // The name (first initial used as default)
 | ||||
|  | @ -35,7 +36,7 @@ interface IProps { | |||
|     width?: number; | ||||
|     height?: number; | ||||
|     // XXX: resizeMethod not actually used.
 | ||||
|     resizeMethod?: string; | ||||
|     resizeMethod?: ResizeMethod; | ||||
|     defaultToInitialLetter?: boolean; // true to add default url
 | ||||
|     onClick?: React.MouseEventHandler; | ||||
|     inputRef?: React.RefObject<HTMLImageElement & HTMLSpanElement>; | ||||
|  |  | |||
|  | @ -18,7 +18,7 @@ import React from 'react'; | |||
| import BaseAvatar from './BaseAvatar'; | ||||
| import {replaceableComponent} from "../../../utils/replaceableComponent"; | ||||
| import {mediaFromMxc} from "../../../customisations/Media"; | ||||
| import {ResizeMode} from "../../../customisations/models/ResizeMode"; | ||||
| import {ResizeMethod} from "../../../Avatar"; | ||||
| 
 | ||||
| export interface IProps { | ||||
|         groupId?: string; | ||||
|  | @ -26,7 +26,7 @@ export interface IProps { | |||
|         groupAvatarUrl?: string; | ||||
|         width?: number; | ||||
|         height?: number; | ||||
|         resizeMethod?: ResizeMode; | ||||
|         resizeMethod?: ResizeMethod; | ||||
|         onClick?: React.MouseEventHandler; | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -23,13 +23,14 @@ import {Action} from "../../../dispatcher/actions"; | |||
| import {MatrixClientPeg} from "../../../MatrixClientPeg"; | ||||
| import BaseAvatar from "./BaseAvatar"; | ||||
| import {replaceableComponent} from "../../../utils/replaceableComponent"; | ||||
| import {ResizeMethod} from "../../../Avatar"; | ||||
| 
 | ||||
| interface IProps extends Omit<React.ComponentProps<typeof BaseAvatar>, "name" | "idName" | "url"> { | ||||
|     member: RoomMember; | ||||
|     fallbackUserId?: string; | ||||
|     width: number; | ||||
|     height: number; | ||||
|     resizeMethod?: string; | ||||
|     resizeMethod?: ResizeMethod; | ||||
|     // The onClick to give the avatar
 | ||||
|     onClick?: React.MouseEventHandler; | ||||
|     // Whether the onClick of the avatar should be overriden to dispatch `Action.ViewUser`
 | ||||
|  |  | |||
|  | @ -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…
	
		Reference in New Issue
	
	 Travis Ralston
						Travis Ralston