Skip to content

Commit

Permalink
Update dependencies and refactor modal type in utils.ts
Browse files Browse the repository at this point in the history
- Added `antd` version 5.23.0 to package.json and package-lock.json.
- Updated modal type from `ModalType` to `HookAPI` in `utils.ts` for improved type safety and consistency.
- Updated various dependencies in package-lock.json to their latest versions, enhancing overall application stability and performance.

These changes aim to streamline the development process and ensure compatibility with the latest features of the `antd` library.
  • Loading branch information
harumiWeb committed Jan 7, 2025
1 parent 08be74c commit 9ca0de1
Show file tree
Hide file tree
Showing 18 changed files with 157 additions and 299 deletions.
8 changes: 3 additions & 5 deletions app/components/ConvertButton/ConvertButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,13 @@ import { Modal } from "antd";
import { convert } from "@/app/lib/utils";

export default function ConvertButton() {
const [filePaths, setFilePaths] = useAtom(filePathsAtom);
const [filePaths] = useAtom(filePathsAtom);
const [fileInfos] = useAtom(fileInfosAtom);
const [extensionType] = useAtom(extensionTypeAtom);
const [quality] = useAtom(qualityAtom);
const [isProcessing, setIsProcessing] = useAtom(isProcessingAtom);
const [processedFilePaths, setProcessedFilePaths] = useAtom(
processedFilePathsAtom
);
const [tabSelected, setTabSelected] = useAtom(tabSelectedAtom);
const [, setProcessedFilePaths] = useAtom(processedFilePathsAtom);
const [, setTabSelected] = useAtom(tabSelectedAtom);

const [modal, contextHolder] = Modal.useModal();

Expand Down
4 changes: 2 additions & 2 deletions app/components/Dropzone/Dropzone.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import { filePathsAtom, tabSelectedAtom } from "../../lib/atom";
import { Modal } from "antd";

export default function Dropzone() {
const [filePaths, setFilePaths] = useAtom(filePathsAtom);
const [tabSelected, setTabSelected] = useAtom(tabSelectedAtom);
const [, setFilePaths] = useAtom(filePathsAtom);
const [, setTabSelected] = useAtom(tabSelectedAtom);
const [modal, modalContextHolder] = Modal.useModal();

useEffect(() => {
Expand Down
4 changes: 2 additions & 2 deletions app/components/InputTab/InputNavMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { useAtom } from "jotai";
import { filePathsAtom, fileInfosAtom } from "../../lib/atom";

export default function InputNubMenu() {
const [filePaths, setFilePaths] = useAtom(filePathsAtom);
const [fileInfos, setFileInfos] = useAtom(fileInfosAtom);
const [, setFilePaths] = useAtom(filePathsAtom);
const [, setFileInfos] = useAtom(fileInfosAtom);

const removeAll = () => {
setFilePaths([]);
Expand Down
4 changes: 2 additions & 2 deletions app/components/InputTab/InputTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import InputNubMenu from "./InputNavMenu";
import Null from "./Null";

export default function InputTab() {
const [tabSelected, setTabSelected] = useAtom(tabSelectedAtom);
const [filePaths, setFilePaths] = useAtom(filePathsAtom);
const [tabSelected] = useAtom(tabSelectedAtom);
const [filePaths] = useAtom(filePathsAtom);

return (
<div
Expand Down
2 changes: 1 addition & 1 deletion app/components/OutputTab/Null.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default function Null() {
<span className="text-base font-bold text-gray-700 text-center">
No result
<br />
Select images from "INPUT" tab <br />
Select images from &quot;INPUT&quot; tab <br />
and convert them to see the result here.
</span>
<div className="w-full h-full overflow-hidden absolute top-0 left-0">
Expand Down
4 changes: 2 additions & 2 deletions app/components/OutputTab/OutputNavMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ export default function OutputNavMenu() {
processedFilePathsSortedAtom
);
const [checkboxSelected, setCheckboxSelected] = useAtom(checkboxSelectedAtom);
const [processedFilePaths, setProcessedFilePaths] = useAtom(
const [, setProcessedFilePaths] = useAtom(
processedFilePathsAtom
);
const [isSaving, setIsSaving] = useAtom(isSavingAtom);
const [, setIsSaving] = useAtom(isSavingAtom);
const [modal, modalContextHolder] = Modal.useModal();


Expand Down
2 changes: 1 addition & 1 deletion app/components/OutputTab/OutputTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import ProcessedFiles from "../ProcessedFiles/ProcessedFiles";
import OutputNavMenu from "./OutputNavMenu";

export default function OutputTab() {
const [tabSelected, setTabSelected] = useAtom(tabSelectedAtom);
const [tabSelected] = useAtom(tabSelectedAtom);
return (
<div
className={`flex flex-col w-full h-full relative ${
Expand Down
2 changes: 1 addition & 1 deletion app/components/ProcessedFiles/ProcessedFiles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default function ProcessedFiles() {
const [processedFilePathsSorted, setProcessedFilePathsSorted] = useAtom(
processedFilePathsSortedAtom
);
const [checkboxSelected, setCheckboxSelected] = useAtom(checkboxSelectedAtom);
const [, setCheckboxSelected] = useAtom(checkboxSelectedAtom);

useEffect(() => {
const fetchProcessedInfos = async () => {
Expand Down
2 changes: 1 addition & 1 deletion app/components/SelectFiles/File.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { readFile } from "@tauri-apps/plugin-fs";

export default function File({ fileInfo, index }: FileProps) {
const [filePaths, setFilePaths] = useAtom(filePathsAtom);
const [fileInfos, setFileInfos] = useAtom(fileInfosAtom);
const [, setFileInfos] = useAtom(fileInfosAtom);
const [imageSrc, setImageSrc] = useState<string | null>(null);

useEffect(() => {
Expand Down
3 changes: 1 addition & 2 deletions app/components/SelectFiles/SelectFiles.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use client";

import { useAtom } from "jotai";
import { filePathsAtom, fileInfosAtom, isProcessingAtom } from "@/app/lib/atom";
import { filePathsAtom, fileInfosAtom } from "@/app/lib/atom";
import { FileInfo } from "@/app/index.d";
import { useEffect } from "react";
import File from "./File";
Expand All @@ -11,7 +11,6 @@ import { readFileAsync } from "../FileDialog/utils";
export default function SelectFiles() {
const [filePaths] = useAtom(filePathsAtom);
const [fileInfos, setFileInfos] = useAtom(fileInfosAtom);
const [_, setIsProcessing] = useAtom(isProcessingAtom);

useEffect(() => {
const fetchData = async () => {
Expand Down
2 changes: 1 addition & 1 deletion app/components/SelectFiles/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export async function getProcessedFileInfo(processedFilePaths: string[], fileInf
.filter((info) => info !== undefined) as ProcessedFileInfo[];

// mime_typeを変換後のものに変更
sortedProcessedInfos.forEach((processedInfo, index) => {
sortedProcessedInfos.forEach((processedInfo) => {
const extension: string = processedInfo.file_name_with_extension.split(".").pop()?.toLowerCase() || "";
processedInfo.mime_type = `image/${extension}`;
});
Expand Down
44 changes: 22 additions & 22 deletions app/components/WindowMenu/ContextMenu/FileMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,22 +51,22 @@ const items: MenuProps["items"] = [

export default function FileMenu() {
const [filePaths, setFilePaths] = useAtom(filePathsAtom);
const [isFocused, setIsFocused] = useAtom(isFocusedAtom);
const [isFocused, ] = useAtom(isFocusedAtom);
const fileButtonRef = useRef<HTMLButtonElement | null>(null);
const [fileInfos, setFileInfos] = useAtom(fileInfosAtom);
const [tabSelected, setTabSelected] = useAtom(tabSelectedAtom);
const [processedFilePathsSorted, setProcessedFilePathsSorted] = useAtom(
processedFilePathsSortedAtom
);
const [checkboxSelected, setCheckboxSelected] = useAtom(checkboxSelectedAtom);
const [processedFilePaths, setProcessedFilePaths] = useAtom(
const [, setProcessedFilePaths] = useAtom(
processedFilePathsAtom
);
const [isSaving, setIsSaving] = useAtom(isSavingAtom);
const [quality, setQuality] = useAtom(qualityAtom);
const [extensionType, setExtensionType] = useAtom(extensionTypeAtom);
const [, setIsSaving] = useAtom(isSavingAtom);
const [quality, ] = useAtom(qualityAtom);
const [extensionType, ] = useAtom(extensionTypeAtom);
const [isProcessing, setIsProcessing] = useAtom(isProcessingAtom);
const [modal, modalContextHolder] = Modal.useModal();
const [modal, ] = Modal.useModal();

function removeResult() {
setProcessedFilePathsSorted([]);
Expand Down Expand Up @@ -191,13 +191,13 @@ function FileOpen(): React.ReactNode {

function FileRemoveAll(): React.ReactNode {
const [filePaths, setFilePaths] = useAtom(filePathsAtom);
const [tabSelected, setTabSelected] = useAtom(tabSelectedAtom);
const [fileInfos, setFileInfos] = useAtom(fileInfosAtom);
const [tabSelected, ] = useAtom(tabSelectedAtom);
const [, setFileInfos] = useAtom(fileInfosAtom);
const [processedFilePathsSorted, setProcessedFilePathsSorted] = useAtom(
processedFilePathsSortedAtom
);
const [checkboxSelected, setCheckboxSelected] = useAtom(checkboxSelectedAtom);
const [processedFilePaths, setProcessedFilePaths] = useAtom(
const [, setCheckboxSelected] = useAtom(checkboxSelectedAtom);
const [, setProcessedFilePaths] = useAtom(
processedFilePathsAtom
);

Expand Down Expand Up @@ -252,10 +252,10 @@ function FileRemoveAll(): React.ReactNode {

function FileSaveAll(): React.ReactNode {
const [isSaving, setIsSaving] = useState(false);
const [processedFilePathsSorted, setProcessedFilePathsSorted] = useAtom(
const [processedFilePathsSorted, ] = useAtom(
processedFilePathsSortedAtom
);
const [modal, modalContextHolder] = Modal.useModal();
const [modal, ] = Modal.useModal();
return (
<button
className={`flex items-center justify-between leading-5 w-full ${
Expand All @@ -282,11 +282,11 @@ function FileSaveAll(): React.ReactNode {

function FileSaveSelected(): React.ReactNode {
const [isSaving, setIsSaving] = useState(false);
const [processedFilePathsSorted, setProcessedFilePathsSorted] = useAtom(
const [processedFilePathsSorted, ] = useAtom(
processedFilePathsSortedAtom
);
const [checkboxSelected, setCheckboxSelected] = useAtom(checkboxSelectedAtom);
const [modal, modalContextHolder] = Modal.useModal();
const [checkboxSelected, ] = useAtom(checkboxSelectedAtom);
const [modal, ] = Modal.useModal();
return (
<button
className={`flex items-center justify-between leading-5 w-full ${
Expand Down Expand Up @@ -325,15 +325,15 @@ function FileSaveSelected(): React.ReactNode {

function FileConvert(): React.ReactNode {
const [isProcessing, setIsProcessing] = useAtom(isProcessingAtom);
const [processedFilePaths, setProcessedFilePaths] = useAtom(
const [, setProcessedFilePaths] = useAtom(
processedFilePathsAtom
);
const [modal, modalContextHolder] = Modal.useModal();
const [filePaths, setFilePaths] = useAtom(filePathsAtom);
const [fileInfos, setFileInfos] = useAtom(fileInfosAtom);
const [quality, setQuality] = useAtom(qualityAtom);
const [extensionType, setExtensionType] = useAtom(extensionTypeAtom);
const [tabSelected, setTabSelected] = useAtom(tabSelectedAtom);
const [modal, ] = Modal.useModal();
const [filePaths, ] = useAtom(filePathsAtom);
const [fileInfos, ] = useAtom(fileInfosAtom);
const [quality, ] = useAtom(qualityAtom);
const [extensionType, ] = useAtom(extensionTypeAtom);
const [, setTabSelected] = useAtom(tabSelectedAtom);
return (
<button
className={`flex items-center justify-between leading-5 w-full ${
Expand Down
37 changes: 20 additions & 17 deletions app/components/WindowMenu/ContextMenu/HelpMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const items: MenuProps["items"] = [
];

export default function HelpMenu() {
const [isFocused, setIsFocused] = useAtom(isFocusedAtom);
const [isFocused] = useAtom(isFocusedAtom);
const helpButtonRef = useRef<HTMLButtonElement | null>(null);
useEffect(() => {
const handleKeyDownSelectShortcut = async (event: KeyboardEvent) => {
Expand Down Expand Up @@ -73,22 +73,25 @@ function Help(): React.ReactNode {
<span className="pt-2 block" />
Copyright (c) 2025 Moriya Harumi
<span className="pt-2 block" />
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:<span className="pt-2 block" />
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.<span className="pt-2 block" />
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation files
(the &quot;Software&quot;), to deal in the Software without
restriction, including without limitation the rights to use, copy,
modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
<span className="pt-2 block" />
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
<span className="pt-2 block" />
THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY
KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
</p>
</section>
</Modal>
Expand Down
8 changes: 4 additions & 4 deletions app/components/WindowMenu/ContextMenu/SelectMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ const items: MenuProps["items"] = [
];

export default function SelectMenu() {
const [isFocused, setIsFocused] = useAtom(isFocusedAtom);
const [isFocused, ] = useAtom(isFocusedAtom);
const [checkboxSelected, setCheckboxSelected] = useAtom(checkboxSelectedAtom);
const [processedFilePathsSorted, setProcessedFilePathsSorted] = useAtom(processedFilePathsSortedAtom);
const [processedFilePathsSorted, ] = useAtom(processedFilePathsSortedAtom);
const selectButtonRef = useRef<HTMLButtonElement | null>(null);
useEffect(() => {
const handleKeyDownSelectShortcut = async (event: KeyboardEvent) => {
Expand Down Expand Up @@ -56,8 +56,8 @@ export default function SelectMenu() {
}

function SelectAll(): React.ReactNode {
const [checkboxSelected, setCheckboxSelected] = useAtom(checkboxSelectedAtom);
const [processedFilePathsSorted, setProcessedFilePathsSorted] = useAtom(processedFilePathsSortedAtom);
const [, setCheckboxSelected] = useAtom(checkboxSelectedAtom);
const [processedFilePathsSorted, ] = useAtom(processedFilePathsSortedAtom);
return (
<button
title="Select all files."
Expand Down
2 changes: 1 addition & 1 deletion app/components/WindowMenu/WindowMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import HelpMenu from "./ContextMenu/HelpMenu";
export default function WindowMenu() {
const [appWindow, setAppWindow] = useState<TauriWindow | null>(null);

const [isFocused, setIsFocused] = useAtom(isFocusedAtom);
const [, setIsFocused] = useAtom(isFocusedAtom);

useEffect(() => {
const handleFocus = () => {
Expand Down
8 changes: 4 additions & 4 deletions app/lib/utils.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { invoke } from "@tauri-apps/api/core";
import { open } from "@tauri-apps/plugin-dialog";
import type { ModalType } from "antd/es/modal/index.d";
import type { CheckboxSelected, FileInfo } from "@/app/index.d";
import { readFileAsync } from "../components/FileDialog/utils";
import type { HookAPI } from "antd/es/modal/useModal";

export async function openDialog(
setFilePaths: (paths: string[]) => void,
Expand All @@ -28,7 +28,7 @@ export async function openDialog(
export async function saveAll(
setIsSaving: (isSaving: boolean) => void,
processedFilePathsSorted: string[],
modal: ModalType
modal: HookAPI
) {
setIsSaving(true);
const outputDir = await open({
Expand Down Expand Up @@ -57,7 +57,7 @@ export async function saveSelected(
setIsSaving: (isSaving: boolean) => void,
processedFilePathsSorted: string[],
checkboxSelected: CheckboxSelected[],
modal: ModalType
modal: HookAPI
) {
setIsSaving(true);
const outputDir = await open({
Expand Down Expand Up @@ -89,7 +89,7 @@ export async function saveSelected(
export async function convert(
setIsProcessing: (isProcessing: boolean) => void,
filePaths: string[],
modal: ModalType,
modal: HookAPI,
quality: number,
extensionType: string,
fileInfos: FileInfo[],
Expand Down
Loading

0 comments on commit 9ca0de1

Please sign in to comment.