You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: mobile/android/fenix/app/src/main/java/org/mozilla/fenix/components/menu/middleware/MenuDialogMiddleware.kt
+9-2Lines changed: 9 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -216,9 +216,16 @@ class MenuDialogMiddleware(
216
216
val selectedTab = browserMenuState.selectedTab
217
217
val url = selectedTab.getUrl() ?:return@launch
218
218
219
-
val parentGuid = lastSavedFolderCache.getGuid() ?:BookmarkRoot.Mobile.id
219
+
// get the last saved folder id
220
+
val targetParentFolderId = lastSavedFolderCache.getGuid() ?:BookmarkRoot.Mobile.id
220
221
221
-
val parentNode = bookmarksStorage.getBookmark(parentGuid).getOrNull()
222
+
// get the corresponding bookmark and fallback to mobile root bookmark node
223
+
// this is necessary because it's possible that the last saved folder no longer exists (
224
+
// e.g. if the folder is removed through sync)
225
+
val parentNode = bookmarksStorage.getBookmark(targetParentFolderId).getOrNull()
@@ -271,7 +272,11 @@ class MenuDialogMiddlewareTest {
271
272
}
272
273
273
274
@Test
274
-
fun`GIVEN last save folder cache has a value WHEN add bookmark action is dispatched for a selected tab THEN bookmark is added with the caches value as its parent`() = runTest(testDispatcher) {
275
+
fun`GIVEN last save folder cache has a value WHEN add bookmark action is dispatched for a selected tab THEN bookmark is added with the cached value as its parent`() = runTest(testDispatcher) {
276
+
// given that the last saved folder actually exists
277
+
val lastSavedFolderId = bookmarksStorage.addFolder(BookmarkRoot.Mobile.id, "last-folder")
verify(addBookmarkUseCase).invoke(url = url, title = title, parentGuid =BookmarkRoot.Mobile.id)
343
+
}
344
+
309
345
@Test
310
346
fun`GIVEN the last added bookmark does not belong to a folder WHEN bookmark is added THEN bookmark is added to mobile root`() = runTest(testDispatcher) {
0 commit comments