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
@@ -223,9 +223,16 @@ class MenuDialogMiddleware(
223
223
val selectedTab = browserMenuState.selectedTab
224
224
val url = selectedTab.getUrl() ?:return@launch
225
225
226
-
val parentGuid = lastSavedFolderCache.getGuid() ?:BookmarkRoot.Mobile.id
226
+
// get the last saved folder id
227
+
val targetParentFolderId = lastSavedFolderCache.getGuid() ?:BookmarkRoot.Mobile.id
227
228
228
-
val parentNode = bookmarksStorage.getBookmark(parentGuid).getOrNull()
229
+
// get the corresponding bookmark and fallback to mobile root bookmark node
230
+
// this is necessary because it's possible that the last saved folder no longer exists (
231
+
// e.g. if the folder is removed through sync)
232
+
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
+35-4Lines changed: 35 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -282,7 +282,11 @@ class MenuDialogMiddlewareTest {
282
282
}
283
283
284
284
@Test
285
-
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) {
285
+
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) {
286
+
// given that the last saved folder actually exists
287
+
val lastSavedFolderId = bookmarksStorage.addFolder(BookmarkRoot.Mobile.id, "last-folder")
verify(addBookmarkUseCase).invoke(url = url, title = title, parentGuid =BookmarkRoot.Mobile.id)
349
+
}
350
+
320
351
@Test
321
352
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