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
@@ -220,9 +220,16 @@ class MenuDialogMiddleware(
220
220
val selectedTab = browserMenuState.selectedTab
221
221
val url = selectedTab.getUrl() ?:return@launch
222
222
223
-
val parentGuid = lastSavedFolderCache.getGuid() ?:BookmarkRoot.Mobile.id
223
+
// get the last saved folder id
224
+
val targetParentFolderId = lastSavedFolderCache.getGuid() ?:BookmarkRoot.Mobile.id
224
225
225
-
val parentNode = bookmarksStorage.getBookmark(parentGuid).getOrNull()
226
+
// get the corresponding bookmark and fallback to mobile root bookmark node
227
+
// this is necessary because it's possible that the last saved folder no longer exists (
228
+
// e.g. if the folder is removed through sync)
229
+
val parentNode = bookmarksStorage.getBookmark(targetParentFolderId).getOrNull()
Copy file name to clipboardExpand all lines: mobile/android/fenix/app/src/test/java/org/mozilla/fenix/components/menu/MenuDialogMiddlewareTest.kt
+36-4Lines changed: 36 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -276,7 +276,12 @@ class MenuDialogMiddlewareTest {
276
276
}
277
277
278
278
@Test
279
-
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`() = runTestOnMain {
279
+
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`() = runTestOnMain {
280
+
// given that the last saved folder actually exists
281
+
val lastSavedFolderId = bookmarksStorage.addFolder(BookmarkRoot.Mobile.id, "last-folder")
0 commit comments