From 4842f83aae157e5b5dad092c9bc58c4e270a907b Mon Sep 17 00:00:00 2001 From: Laurent Cozic Date: Wed, 20 Nov 2019 18:14:11 +0000 Subject: [PATCH] All: Fixes #2088: Handle rare case when notebook has a parent that no longer exists, which causes a crash when sorting --- ReactNativeClient/lib/models/Folder.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ReactNativeClient/lib/models/Folder.js b/ReactNativeClient/lib/models/Folder.js index 32090b44b..eb692427c 100644 --- a/ReactNativeClient/lib/models/Folder.js +++ b/ReactNativeClient/lib/models/Folder.js @@ -148,7 +148,11 @@ class Folder extends BaseItem { for (let i = 0; i < folders.length; i++) { if (folders[i].id === folder.parent_id) return folders[i]; } - throw new Error('Could not find parent'); + + // In some rare cases, some folders may not have a parent, for example + // if it has not been downloaded via sync yet. + // https://github.com/laurent22/joplin/issues/2088 + return null; }; const applyChildTimeToParent = folderId => {