Remove dead code (#9035)

This commit is contained in:
Šimon Brandner 2022-07-11 07:52:44 +02:00 committed by GitHub
parent d1928d2cb3
commit 19e514d83c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
28 changed files with 6 additions and 412 deletions

View file

@ -1,38 +0,0 @@
/*
Copyright 2016 - 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.
*/
import { ReceiptType } from "matrix-js-sdk/src/@types/read_receipts";
import { MatrixEvent } from "matrix-js-sdk/src/models/event";
/**
* Given MatrixEvent containing receipts, return the first
* read receipt from the given user ID, or null if no such
* receipt exists.
*
* @param {Object} receiptEvent A Matrix Event
* @param {string} userId A user ID
* @returns {Object} Read receipt
*/
export function findReadReceiptFromUserId(receiptEvent: MatrixEvent, userId: string): object | null {
const receiptKeys = Object.keys(receiptEvent.getContent());
for (let i = 0; i < receiptKeys.length; ++i) {
const rcpt = receiptEvent.getContent()[receiptKeys[i]];
if (rcpt[ReceiptType.Read]?.[userId]) return rcpt;
if (rcpt[ReceiptType.ReadPrivate]?.[userId]) return rcpt;
}
return null;
}

View file

@ -1,36 +0,0 @@
/*
Copyright 2021 New Vector Ltd
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.
*/
/**
* Fetch an image using the best available method based on browser compatibility
* @param url the URL of the image to fetch
* @returns a canvas drawable object
*/
export async function getDrawable(url: string): Promise<CanvasImageSource> {
if ('createImageBitmap' in window) {
const response = await fetch(url);
const blob = await response.blob();
return createImageBitmap(blob);
} else {
return new Promise<HTMLImageElement>((resolve, reject) => {
const img = document.createElement("img");
img.crossOrigin = "anonymous";
img.onload = () => resolve(img);
img.onerror = (e) => reject(e);
img.src = url;
});
}
}

View file

@ -14,11 +14,7 @@
* limitations under the License.
*/
import { arrayDiff, arrayUnion, arrayIntersection } from "./arrays";
export function iterableUnion<T>(a: Iterable<T>, b: Iterable<T>): Iterable<T> {
return arrayUnion(Array.from(a), Array.from(b));
}
import { arrayDiff, arrayIntersection } from "./arrays";
export function iterableIntersection<T>(a: Iterable<T>, b: Iterable<T>): Iterable<T> {
return arrayIntersection(Array.from(a), Array.from(b));

View file

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import { arrayDiff, arrayUnion, arrayIntersection } from "./arrays";
import { arrayDiff, arrayIntersection } from "./arrays";
/**
* Determines the keys added, changed, and removed between two Maps.
@ -33,18 +33,6 @@ export function mapDiff<K, V>(a: Map<K, V>, b: Map<K, V>): { changed: K[], added
return { changed: changes, added: keyDiff.added, removed: keyDiff.removed };
}
/**
* Gets all the key changes (added, removed, or value difference) between two Maps.
* Triple equals is used to compare values, not in-depth tree checking.
* @param a The first Map. Must be defined.
* @param b The second Map. Must be defined.
* @returns The keys which have been added, removed, or changed between the two Maps.
*/
export function mapKeyChanges<K, V>(a: Map<K, V>, b: Map<K, V>): K[] {
const diff = mapDiff(a, b);
return arrayUnion(diff.removed, diff.added, diff.changed);
}
/**
* A Map<K, V> with added utility.
*/

View file

@ -14,14 +14,6 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
/* Simple utils for formatting style values
*/
// converts a pixel value to rem.
export function toRem(pixelValue: number): string {
return pixelValue / 10 + "rem";
}
export function toPx(pixelValue: number): string {
return pixelValue + "px";
}