Skip to content

Commit

Permalink
fix: support refresh from menu item for artist and collection list
Browse files Browse the repository at this point in the history
good for desktop and accessibility

#1031
  • Loading branch information
lydavid committed Sep 11, 2024
1 parent f9062ca commit a3b401b
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import ly.david.musicsearch.shared.feature.collections.components.CollectionList
import ly.david.musicsearch.shared.feature.collections.create.CreateNewCollectionDialogContent
import ly.david.musicsearch.shared.feature.collections.create.NewCollection
import ly.david.musicsearch.ui.common.paging.ScreenWithPagingLoadingAndError
import ly.david.musicsearch.ui.common.topappbar.RefreshMenuItem
import ly.david.musicsearch.ui.common.topappbar.TopAppBarFilterState
import ly.david.musicsearch.ui.common.topappbar.TopAppBarWithFilter
import ly.david.musicsearch.ui.core.LocalStrings
Expand Down Expand Up @@ -148,6 +149,11 @@ internal fun CollectionListUi(
)
}
},
overflowDropdownMenuItems = {
RefreshMenuItem {
lazyPagingItems.refresh()
}
},
additionalBar = {
CollectionsFilterChipsBar(
sortOption = sortOption,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,39 @@ internal class ArtistPresenter(
}

ArtistUiEvent.ForceRefresh -> {
forceRefreshDetails = true
when (selectedTab) {
ArtistTab.DETAILS -> {
forceRefreshDetails = true
}

ArtistTab.RELEASE_GROUPS -> {
releaseGroupsByEntityUiState.lazyPagingItems.refresh()
}

ArtistTab.RELEASES -> {
releasesByEntityUiState.lazyPagingItems.refresh()
}

ArtistTab.RECORDINGS -> {
recordingsByEntityUiState.lazyPagingItems.refresh()
}

ArtistTab.WORKS -> {
worksByEntityUiState.lazyPagingItems.refresh()
}

ArtistTab.EVENTS -> {
eventsByEntityUiState.lazyPagingItems.refresh()
}

ArtistTab.RELATIONSHIPS -> {
relationsUiState.lazyPagingItems.refresh()
}

ArtistTab.STATS -> {
// No-op.
}
}
}

ArtistUiEvent.NavigateToCollaboratorsGraph -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import ly.david.musicsearch.ui.common.screen.showInBottomSheet
import ly.david.musicsearch.ui.common.topappbar.AddToCollectionMenuItem
import ly.david.musicsearch.ui.common.topappbar.CopyToClipboardMenuItem
import ly.david.musicsearch.ui.common.topappbar.OpenInBrowserMenuItem
import ly.david.musicsearch.ui.common.topappbar.RefreshMenuItem
import ly.david.musicsearch.ui.common.topappbar.TabsBar
import ly.david.musicsearch.ui.common.topappbar.ToggleMenuItem
import ly.david.musicsearch.ui.common.topappbar.TopAppBarWithFilter
Expand Down Expand Up @@ -87,6 +88,9 @@ internal fun ArtistUi(
ArtistTab.STATS,
),
overflowDropdownMenuItems = {
RefreshMenuItem {
eventSink(ArtistUiEvent.ForceRefresh)
}
OpenInBrowserMenuItem(
entity = entity,
entityId = entityId,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package ly.david.musicsearch.ui.common.topappbar

import androidx.compose.material3.DropdownMenuItem
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import ly.david.musicsearch.ui.core.LocalStrings

@Composable
fun OverflowMenuScope.RefreshMenuItem(
modifier: Modifier = Modifier,
onClick: () -> Unit,
) {
val strings = LocalStrings.current

DropdownMenuItem(
text = {
Text(strings.refresh)
},
onClick = {
onClick()
closeMenu()
},
modifier = modifier,
)
}

0 comments on commit a3b401b

Please sign in to comment.