refactor: change null to undefined

This commit is contained in:
2026-02-04 12:50:38 +05:00
parent 2797fea079
commit dfa6c40743
21 changed files with 89 additions and 112 deletions
+2 -1
View File
@@ -87,7 +87,7 @@ export class ImageService {
}
// Find image item
let imageItem: DataTransferItem | null = null;
let imageItem: DataTransferItem | undefined = undefined;
for (let i = 0; i < items.length; i++) {
if (items[i].type.indexOf("image") !== -1) {
imageItem = items[i];
@@ -184,6 +184,7 @@ export class ImageService {
private fileToBase64(file: File): Promise<string> {
return new Promise((resolve, reject) => {
const reader = new FileReader();
// TODO: look for a better way to handle errors non strings
reader.onload = () => resolve(reader.result as string);
reader.onerror = () => reject(new ImageError("Ошибка чтения файла"));
reader.readAsDataURL(file);
+1 -1
View File
@@ -42,7 +42,7 @@ export interface ImageCropResult {
export interface UIState {
isLoading: boolean;
error: string | null;
error: string | undefined;
currentStep: "upload" | "crop" | "text" | "preview";
showCropModal: boolean;
showTextManager: boolean;
+3 -4
View File
@@ -1,4 +1,3 @@
import type { Panel } from "../types/panel";
import { ImageError } from "../types/errors";
import { handleError, logError } from "./errorHandler";
@@ -72,13 +71,13 @@ export class PanelStorage {
/**
* Загружает панель по ID
*/
getPanelById(id: string): Panel | null {
getPanelById(id: string): Panel | undefined {
try {
const panels = this.getAllPanels();
return panels.find((p) => p.id === id) || null;
return panels.find((p) => p.id === id) || undefined;
} catch (error) {
logError(error, "Failed to get panel by id");
return null;
return undefined;
}
}