Skip to content

Commit bdf7d5f

Browse files
committed
Fix error on invalid link
1 parent f71a28e commit bdf7d5f

File tree

2 files changed

+26
-12
lines changed

2 files changed

+26
-12
lines changed

src/components/App.tsx

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,16 +113,23 @@ const App = () => {
113113
}
114114
}
115115

116-
getNotePathname(noteStorageId, noteIdWithPrefix).then((pathname) => {
117-
if (pathname) {
118-
replace(getNoteFullItemId(noteStorageId, pathname, noteId))
119-
} else {
116+
getNotePathname(noteStorageId, noteIdWithPrefix)
117+
.then((pathname) => {
118+
if (pathname) {
119+
replace(getNoteFullItemId(noteStorageId, pathname, noteId))
120+
} else {
121+
pushMessage({
122+
title: 'Note link invalid!',
123+
description: 'The note link you are trying to open is invalid.',
124+
})
125+
}
126+
})
127+
.catch(() => {
120128
pushMessage({
121129
title: 'Note link invalid!',
122130
description: 'The note link you are trying to open is invalid.',
123131
})
124-
}
125-
})
132+
})
126133
}
127134
}
128135
addIpcListener('note:navigate', noteLinkNavigateEventHandler)

src/components/atoms/MarkdownPreviewer.tsx

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -178,16 +178,23 @@ const MarkdownPreviewer = ({
178178
}
179179
}
180180

181-
getNotePathname(noteStorageId, noteIdWithPrefix).then((pathname) => {
182-
if (pathname) {
183-
replace(getNoteFullItemId(noteStorageId, pathname, noteId))
184-
} else {
181+
getNotePathname(noteStorageId, noteIdWithPrefix)
182+
.then((pathname) => {
183+
if (pathname) {
184+
replace(getNoteFullItemId(noteStorageId, pathname, noteId))
185+
} else {
186+
pushMessage({
187+
title: 'Note link invalid!',
188+
description: 'The note link you are trying to open is invalid.',
189+
})
190+
}
191+
})
192+
.catch(() => {
185193
pushMessage({
186194
title: 'Note link invalid!',
187195
description: 'The note link you are trying to open is invalid.',
188196
})
189-
}
190-
})
197+
})
191198
}
192199
},
193200
[activeStorageId, pushMessage, storageMap, getNotePathname, replace]

0 commit comments

Comments
 (0)