correct type issues

This commit is contained in:
marlon-erler
2026-09-09 00:04:27 +02:00
parent 4631730f02
commit 839e887d85
24 changed files with 511 additions and 437 deletions
+5 -5
View File
@@ -34,8 +34,8 @@ export default class ChatModel {
// data
readonly id: string;
info: ChatInfo;
color: Colors;
info: ChatInfo; /* load function called in constructor */
color: Colors = Colors.Standard;
get unwrappedPrimaryChannel(): string {
return this.info.namespace + this.info.primaryChannel;
@@ -196,7 +196,7 @@ export default class ChatModel {
fileContent?: FileContent<string>,
): Promise<boolean> => {
const nameAndChannel = this.getNameAndChannel();
if (nameAndChannel == false) return;
if (nameAndChannel == false) return false;
const [senderName, combinedChannel] = nameAndChannel;
const chatMessage: ChatMessage = await ChatModel.createChatMessage(
@@ -231,11 +231,11 @@ export default class ChatModel {
readonly sendReaction = async (
messageId: string,
content: ReactionSymbols,
isDeleting?: boolean,
isDeleting: boolean = false,
): Promise<void> => {
const nameAndChannel = this.getNameAndChannel();
if (nameAndChannel == false) return;
const [senderName, combinedChannel] = nameAndChannel;
const [senderName] = nameAndChannel;
const reaction = ChatModel.createMessageReaction(
messageId,
+4 -1
View File
@@ -37,6 +37,7 @@ export default class FileTransferModel {
};
readonly prepareToSend = (): void => {
if (!this.transferData) return;
this.direction = TransferDirections.Send;
this.connectionModel.addChannel(this.transferData.channel);
};
@@ -156,7 +157,7 @@ export default class FileTransferModel {
};
readonly prepareFileForSending = (filePath: string[]): string => {
const fileContent: string | undefined =
const fileContent: string | null =
this.storageModel.read(filePath);
if (fileContent == null) return "";
@@ -168,6 +169,8 @@ export default class FileTransferModel {
};
readonly sendFile = async (stringifiedFileData: string): Promise<void> => {
if (!this.transferData) return;
const encryptedFileData: string = await encryptString(
stringifiedFileData,
this.transferData.key,
+5 -5
View File
@@ -6,10 +6,10 @@ export default class SettingsModel {
readonly storageModel: StorageModel;
// data
username: string;
firstDayOfWeek: string;
language: string;
theme: string;
username: string = "";
firstDayOfWeek: string = "";
language: string = "";
theme: string = "";
// storage
private readonly storeSetting = (
@@ -46,7 +46,7 @@ export default class SettingsModel {
// load
private readonly readSetting = (
pathName: keyof typeof filePaths.settingsModel,
): string => {
): string|null=> {
const path = StorageModel.getPath(
StorageModelSubPaths.SettingsModel,
filePaths.settingsModel[pathName],
Binary file not shown.
+17 -13
View File
@@ -313,20 +313,22 @@ export function implementPinchZoom(canvas: HTMLElement) {
const MIN = 0.25;
const MAX = 5;
const element = (): HTMLElement => canvas.querySelector(".zoom");
const element = (): HTMLElement|null=> canvas.querySelector(".zoom");
const distance = (e: TouchEvent) =>
Math.hypot(
e.touches[0].pageX - e.touches[1].pageX,
e.touches[0].pageY - e.touches[1].pageY,
);
Math.hypot(
e.touches[0].pageX - e.touches[1].pageX,
e.touches[0].pageY - e.touches[1].pageY,
);
const point = (e: TouchEvent, direction: "x" | "y", i: number) =>
e.touches[i][direction == "x" ? "clientX" : "clientY"];
e.touches[i][direction == "x" ? "clientX" : "clientY"];
const midpoint = (e: TouchEvent, direction: "x" | "y") =>
(point(e, direction, 0) + point(e, direction, 1)) / 2;
(point(e, direction, 0) + point(e, direction, 1)) / 2;
function apply(factor: number, _offset?: [number, number]) {
if (factor < MIN) return apply(MIN, _offset);
if (factor > MAX) return apply(5, _offset);
const el = element();
if (!el) return;
if (factor < MIN) return apply(MIN, _offset);
if (factor > MAX) return apply(5, _offset);
let x: number, y: number;
if (_offset) [x, y] = _offset;
@@ -334,7 +336,7 @@ export function implementPinchZoom(canvas: HTMLElement) {
x = currentX
y = currentY
}
element().style.transform = `scale(${factor.toString()}) translate(${x}px, ${y}px)`;
el.style.transform = `scale(${factor.toString()}) translate(${x}px, ${y}px)`;
currentX = x;
currentY = y;
currentZoom = factor;
@@ -356,15 +358,17 @@ export function implementPinchZoom(canvas: HTMLElement) {
}
apply(currentZoom - event.deltaY * 0.01);
});
canvas.addEventListener("scroll", (event: MouseEvent) => {
canvas.addEventListener("scroll", (event: Event) => {
event.preventDefault();
});
canvas.addEventListener("touchstart", (event: TouchEvent) => {
(document.activeElement as HTMLElement).blur();
if (lastElement != undefined && lastElement != element()) reset();
lastElement = element();
const el = element();
if (!el) return;
if (lastElement != undefined && lastElement != el) reset();
lastElement = el;
initialZoom = currentZoom;
initialX = currentX;