Skip to content
This repository has been archived by the owner on Feb 20, 2023. It is now read-only.

Commit

Permalink
Make variable names consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
eliserichards committed Mar 4, 2021
1 parent 2bfd07c commit 5b05a2d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
2 changes: 2 additions & 0 deletions app/src/androidTest/java/org/mozilla/fenix/ui/SmokeTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ class SmokeTest {

@Test
// Verifies the Bookmark button in a tab's 3 dot menu
@Ignore("To be re-implemented in https://github.com/mozilla-mobile/fenix/issues/17979")
fun mainMenuBookmarkButtonTest() {
val defaultWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)

Expand Down Expand Up @@ -979,6 +980,7 @@ class SmokeTest {

@Test
// Verifies that deleting a Bookmarks folder also removes the item from inside it.
@Ignore("To be re-implemented in https://github.com/mozilla-mobile/fenix/issues/17799")
fun deleteNonEmptyBookmarkFolderTest() {
val website = TestAssetHelper.getGenericAsset(mockWebServer, 1)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,11 @@ class DefaultToolbarMenu(
val isPinningSupported: Boolean
) : ToolbarMenu {

private var currentUrlIsBookmarked = false
private var isCurrentUrlBookmarked = false
private var isBookmarkedJob: Job? = null
private val topToolbarSelected = shouldReverseItems
private val selectedSession: TabSessionState? get() = store.state.selectedTab
private val isTopToolbarSelected = shouldReverseItems
private val selectedSession: TabSessionState?
get() = store.state.selectedTab

override val menuBuilder by lazy {
WebExtensionBrowserMenuBuilder(
Expand Down Expand Up @@ -156,13 +157,13 @@ class DefaultToolbarMenu(
// TwoStateButton.isInPrimaryState must be synchronous, and checking bookmark state is
// relatively slow. The best we can do here is periodically compute and cache a new "is
// bookmarked" state, and use that whenever the menu has been opened.
isInPrimaryState = { currentUrlIsBookmarked },
isInPrimaryState = { isCurrentUrlBookmarked },
secondaryImageResource = R.drawable.ic_bookmark_outline,
secondaryContentDescription = context.getString(R.string.browser_menu_bookmark),
secondaryImageTintResource = primaryTextColor(),
disableInSecondaryState = false
) {
if (!currentUrlIsBookmarked) currentUrlIsBookmarked = true
if (!isCurrentUrlBookmarked) isCurrentUrlBookmarked = true
onItemTapped.invoke(ToolbarMenu.Item.Bookmark)
}

Expand Down Expand Up @@ -473,18 +474,16 @@ class DefaultToolbarMenu(
onItemTapped.invoke(ToolbarMenu.Item.Settings)
}

val syncedTabsInTabsTray = context.components.settings.syncedTabsInTabsTray

val menuItems =
listOfNotNull(
if (topToolbarSelected) menuToolbar else null,
if (isTopToolbarSelected) menuToolbar else null,
newTabItem,
BrowserMenuDivider(),
bookmarksItem,
historyItem,
downloadsItem,
extensionsItem,
if (syncedTabsInTabsTray) null else syncedTabsItem,
syncedTabsItem,
BrowserMenuDivider(),
findInPageItem,
desktopSiteItem,
Expand All @@ -494,8 +493,8 @@ class DefaultToolbarMenu(
saveToCollectionItem,
BrowserMenuDivider(),
settingsItem,
if (topToolbarSelected) null else BrowserMenuDivider(),
if (topToolbarSelected) null else menuToolbar
if (isTopToolbarSelected) null else BrowserMenuDivider(),
if (isTopToolbarSelected) null else menuToolbar
)

menuItems
Expand All @@ -520,7 +519,7 @@ class DefaultToolbarMenu(
)
}
.collect {
currentUrlIsBookmarked = false
isCurrentUrlBookmarked = false
updateCurrentUrlIsBookmarked(it.content.url)
}
}
Expand All @@ -530,7 +529,7 @@ class DefaultToolbarMenu(
internal fun updateCurrentUrlIsBookmarked(newUrl: String) {
isBookmarkedJob?.cancel()
isBookmarkedJob = lifecycleOwner.lifecycleScope.launch {
currentUrlIsBookmarked = bookmarksStorage
isCurrentUrlBookmarked = bookmarksStorage
.getBookmarksWithUrl(newUrl)
.any { it.url == newUrl }
}
Expand Down

0 comments on commit 5b05a2d

Please sign in to comment.