Fix copilot suggestions

This commit is contained in:
Reece 2025-11-10 16:08:47 +00:00
parent 673c99d25c
commit fee1706463
5 changed files with 18 additions and 15 deletions

View File

@ -225,7 +225,7 @@ const DraggableItem = <T extends DragDropItem>({ item, index, itemRefs, boxSelec
});
// Notify parent when hover state changes
React.useEffect(() => {
useEffect(() => {
if (isOver) {
onUpdateDropTarget(item.id);
} else {

View File

@ -1,5 +1,5 @@
import { FileId } from '@app/types/file';
import { PDFDocument, PDFPage } from '@app/types/pageEditor';
import { PDFDocument, PDFPage, PageBreakSettings, PageSize, PageOrientation } from '@app/types/pageEditor';
// V1-style DOM-first command system (replaces the old React state commands)
export abstract class DOMCommand {
@ -420,13 +420,7 @@ export class SplitAllCommand extends DOMCommand {
}
}
export type PageSize = 'A4' | 'Letter' | 'Legal' | 'A3' | 'A5';
export type PageOrientation = 'portrait' | 'landscape';
export interface PageBreakSettings {
size: PageSize;
orientation: PageOrientation;
}
// PageBreakSettings, PageSize, and PageOrientation are now imported from pageEditor.ts
export class PageBreakCommand extends DOMCommand {
private insertedPages: PDFPage[] = [];

View File

@ -1,4 +1,4 @@
/**
/**
* Reusable ToolChain component with smart truncation and tooltip expansion
* Used across FileListItem, FileDetails, and FileThumbnail for consistent display
*/

View File

@ -1,4 +1,4 @@
import React, { createContext, useContext, useState, useCallback, ReactNode, useMemo } from 'react';
import React, { createContext, useContext, useState, useCallback, ReactNode, useMemo, useRef, useEffect } from 'react';
import { FileId } from '@app/types/file';
import { useFileActions, useFileState } from '@app/contexts/FileContext';
import { PDFPage } from '@app/types/pageEditor';
@ -149,16 +149,16 @@ export function PageEditorProvider({ children }: PageEditorProviderProps) {
const { state } = useFileState();
// Keep a ref to always read latest state in stable callbacks
const stateRef = React.useRef(state);
React.useEffect(() => {
const stateRef = useRef(state);
useEffect(() => {
stateRef.current = state;
}, [state]);
// Track the previous FileContext order to detect actual changes
const prevFileContextIdsRef = React.useRef<FileId[]>([]);
const prevFileContextIdsRef = useRef<FileId[]>([]);
// Initialize fileOrder from FileContext when files change (add/remove only)
React.useEffect(() => {
useEffect(() => {
const currentFileIds = state.files.ids;
const prevFileIds = prevFileContextIdsRef.current;

View File

@ -1,5 +1,13 @@
import { FileId } from '@app/types/file';
export type PageSize = 'A4' | 'Letter' | 'Legal' | 'A3' | 'A5';
export type PageOrientation = 'portrait' | 'landscape';
export interface PageBreakSettings {
size: PageSize;
orientation: PageOrientation;
}
export interface PDFPage {
id: string;
pageNumber: number;
@ -11,6 +19,7 @@ export interface PDFPage {
isBlankPage?: boolean;
isPlaceholder?: boolean;
originalFileId?: FileId;
pageBreakSettings?: PageBreakSettings;
}
export interface PDFDocument {