Skip to content

Commit 14a050c

Browse files
committed
fixed build errors
1 parent 8643da2 commit 14a050c

File tree

12 files changed

+100
-51
lines changed

12 files changed

+100
-51
lines changed

src/main/index.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ function createWindow(): void {
4444
}
4545
}
4646

47-
app.whenReady().then((): void => {
47+
app.whenReady().then(() => {
4848
electronApp.setAppUserModelId("com.electron");
4949

5050
app.on("browser-window-created", (_, window) => {
@@ -55,18 +55,18 @@ app.whenReady().then((): void => {
5555
handleWindowEvents();
5656
createWindow();
5757

58-
app.on("activate", (): void => {
58+
app.on("activate", () => {
5959
if (BrowserWindow.getAllWindows().length === 0) createWindow();
6060
});
6161
});
6262

63-
app.on("window-all-closed", (): void => {
63+
app.on("window-all-closed", () => {
6464
if (process.platform !== "darwin") {
6565
app.quit();
6666
}
6767
});
6868

69-
function handleNoteEvents(): void {
69+
function handleNoteEvents() {
7070
ipcMain.handle("getNotes", (_, ...args: Parameters<TGetNotes>) => getNotes(...args));
7171
ipcMain.handle("readNoteData", (_, ...args: Parameters<TReadNoteData>) => readNoteData(...args));
7272
ipcMain.handle("saveNote", (_, ...args: Parameters<TSaveNote>) => saveNote(...args));
@@ -76,7 +76,7 @@ function handleNoteEvents(): void {
7676
ipcMain.handle("openInShell", (_, path) => shell.openPath(path + "\\"));
7777
}
7878

79-
function handleWindowEvents(): void {
79+
function handleWindowEvents() {
8080
ipcMain.handle("closeWindow", () => app.quit());
8181
ipcMain.handle("minimizeWindow", () => mainWindow?.minimize());
8282
ipcMain.handle("maximizeWindow", () => {

src/main/lib/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
import { appDirectoryName, fileEncoding, startingNoteData } from "@shared/constants";
2+
import { FileData, FileOrFolderData, NoteInfo } from "@shared/types";
13
import { dialog } from "electron";
24
import { ensureDir, readFile, readdir, remove, stat, writeFile } from "fs-extra";
35
import { homedir } from "os";
4-
import { appDirectoryName, fileEncoding, startingNoteData } from "../../shared/constants";
5-
import { FileData, FileOrFolderData, TNoteInfo } from "../../shared/types";
66

77
type FileOrFolder =
88
| string
@@ -48,7 +48,7 @@ async function readAllFilesAndFolders(path: string, extension?: string): Promise
4848
}
4949
}
5050

51-
async function getNoteInfo(filePath: string): Promise<TNoteInfo> {
51+
async function getNoteInfo(filePath: string): Promise<NoteInfo> {
5252
const fileStats = await stat(filePath);
5353

5454
const filePathParts = filePath.split("\\");

src/preload/index.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { TGetNotes, TReadNoteData, TSaveNote } from "@shared/types";
2-
import { IWindowContextAPI } from "../shared/types";
2+
import { WindowContextAPI } from "../shared/types";
33

44
declare global {
55
interface Window {
6-
context: IWindowContextAPI;
6+
context: WindowContextAPI;
77
}
88
}

src/renderer/src/App.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { mainComponents } from "@shared/constants";
21
import { useRef } from "react";
32
import { Toaster } from "react-hot-toast";
43
import Editor from "./components/Editor";
@@ -14,8 +13,6 @@ export default function App() {
1413
const { filesAndFolders } = useNotes();
1514
const { location } = useLocation();
1615

17-
const MainComp = mainComponents[location];
18-
1916
return (
2017
<RootLayout>
2118
<Toaster
@@ -28,7 +25,7 @@ export default function App() {
2825
position: "bottom-left"
2926
}}
3027
/>
31-
{MainComp ? <MainComp /> : <>NO FOUND</>}
28+
{location === "main" ? <Editor /> : <Settings />}
3229
{filesAndFolders.length > 0 ? (
3330
<Sidebar
3431
onSelect={() => {

src/renderer/src/assets/index.css

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
@tailwind components;
44
@tailwind utilities;
55

6-
.glass {
7-
}
8-
96
@layer base {
107
:root {
118
--background: 240 10% 3.9%;
@@ -40,10 +37,9 @@
4037
#root {
4138
@apply h-screen;
4239
background-color: transparent !important;
43-
opacity: 0.99;
40+
/* opacity: 0.99; */
41+
border-radius: 10px;
4442
overflow: hidden;
45-
backdrop-filter: blur(11px);
46-
-webkit-backdrop-filter: blur(11px);
4743
}
4844

4945
::-webkit-scrollbar {

src/renderer/src/components/Settings.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const links = [
2323
{
2424
icon: Book,
2525
title: "Learn more about the project",
26-
href: "https://strahinja.vercel.app/projects/notemanager",
26+
href: "https://strahinja.vercel.app/project/notemanager",
2727
hidden: true
2828
}
2929
];
@@ -32,7 +32,7 @@ export default function Settings({}: Props) {
3232
const { setLocation } = useLocation();
3333
return (
3434
<main className="flex-1 relative bg-zinc-900/40 p-4 md:p-6 flex flex-col items-center justify-center rounded-none">
35-
<X className="absolute top-2 right-2 cursor-pointer" onClick={() => setLocation("editor")} />
35+
<X className="absolute top-2 right-2 cursor-pointer" onClick={() => setLocation("main")} />
3636
<div className="flex flex-col items-center justify-center h-screen space-y-10">
3737
<div className="space-y-2 flex border-b items-center pb-2 justify-center flex-col">
3838
<h1 className="text-3xl font-bold">Note Manager</h1>
@@ -52,7 +52,7 @@ export default function Settings({}: Props) {
5252
<link.icon className="text-muted-foreground" />
5353
<div className="flex flex-col">
5454
<h2 className="text-xl">{link.title}</h2>
55-
{link.hidden ? null : <p className="text-zinc-600 text-sm">{link.href}</p>}
55+
{!link.hidden ? <p className="text-zinc-600">{link.href}</p> : null}
5656
</div>
5757
</div>
5858
<ArrowRightIcon className="h-6 w-6 text-gray-500 dark:text-gray-400 hover:translate-x-2 transform transition-all duration-200 ease-in-out" />

src/renderer/src/hooks/useLocation.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
import { TRoute } from "@shared/types";
1+
import { PossibleLocations } from "@shared/types";
22
import { create } from "zustand";
33

4-
export const useLocation = create<{
5-
location: TRoute;
6-
setLocation(newLocation: TRoute): void;
7-
}>((set) => ({
8-
location: "editor",
4+
type TLocation = {
5+
location: PossibleLocations;
6+
setLocation(newLocation: PossibleLocations): void;
7+
};
8+
9+
export const useLocation = create<TLocation>((set) => ({
10+
location: "main",
911
setLocation(newLocation) {
1012
set({
1113
location: newLocation

src/shared/constants.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,7 @@
1-
import Settings from "@renderer/components/Settings";
2-
import Editor from "../renderer/src/components/Editor";
3-
import { TRoute } from "./types";
4-
51
export const appDirectoryName = "notemark_data";
62
export const fileEncoding = "utf8";
73
export const startingNoteData = `## Welcome to NoteManager!
84
- You can edit this note now!
95
- You can click on the title in the header to change it's name!`;
106
export const myRepoLink = `https://github.com/strahinja2112/`;
117
export const projectRepoLink = myRepoLink + "note-manager/";
12-
export const mainComponents: Record<TRoute, (params: any) => JSX.Element> = {
13-
editor: Editor,
14-
settings: Settings
15-
};

src/shared/types.ts

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
import { deleteNote, getNotes, readNoteData, renameNote, saveNote } from "src/main/lib";
22

3-
export type TNoteInfo = {
3+
export type NoteInfo = {
44
title: string;
55
lastEditTime: number;
66
};
77

8-
export type TRoute = "editor" | "settings";
8+
export type PossibleLocations = "main" | "settings";
99

10-
export interface IWindowContextAPI {
10+
export type TGetNotes = typeof getNotes;
11+
export type TReadNoteData = typeof readNoteData;
12+
export type TSaveNote = typeof saveNote;
13+
export type TRenameNote = typeof renameNote;
14+
export type TDeleteNote = typeof deleteNote;
15+
16+
export type WindowContextAPI = {
1117
locale: string;
1218
windowActions: {
1319
close(): void;
@@ -16,20 +22,20 @@ export interface IWindowContextAPI {
1622
};
1723
getRootDir: () => Promise<string>;
1824
openInShell: (path: string) => void;
19-
getNotes: typeof getNotes;
20-
readNoteData: typeof readNoteData;
21-
saveNote: typeof saveNote;
22-
renameNote: typeof renameNote;
23-
deleteNote: typeof deleteNote;
24-
}
25-
26-
export type FileData = TNoteInfo & {
25+
getNotes: TGetNotes;
26+
readNoteData: TReadNoteData;
27+
saveNote: TSaveNote;
28+
renameNote: TRenameNote;
29+
deleteNote: TDeleteNote;
30+
};
31+
32+
export type FileData = NoteInfo & {
2733
type: "file";
2834
fullPath: string;
2935
content?: string;
3036
};
3137

32-
export type FolderData = TNoteInfo & {
38+
export type FolderData = NoteInfo & {
3339
type: "folder";
3440
title: string;
3541
fullPath: string;

test.json

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
[
2+
{
3+
"type": "file",
4+
"title": "Note2",
5+
"lastEditTime": 1706050090392.7107
6+
},
7+
{
8+
"type": "file",
9+
"title": "Test2",
10+
"lastEditTime": 1706195432988.4136
11+
},
12+
{
13+
"type": "folder",
14+
"title": "folder",
15+
"data": [
16+
{
17+
"type": "folder",
18+
"title": "another_folder",
19+
"data": [
20+
{
21+
"type": "file",
22+
"title": "ope",
23+
"lastEditTime": 1706196478539.8796
24+
}
25+
]
26+
},
27+
{
28+
"type": "file",
29+
"title": "open",
30+
"lastEditTime": 1706196478539.8796
31+
}
32+
]
33+
},
34+
{
35+
"type": "folder",
36+
"title": "folder - Copy",
37+
"data": [
38+
{
39+
"type": "folder",
40+
"title": "another_folder",
41+
"data": [
42+
{
43+
"type": "file",
44+
"title": "ope",
45+
"lastEditTime": 1706196478539.8796
46+
}
47+
]
48+
},
49+
{
50+
"type": "file",
51+
"title": "open",
52+
"lastEditTime": 1706196478539.8796
53+
}
54+
]
55+
}
56+
]

0 commit comments

Comments
 (0)