Skip to content

Commit

Permalink
Show groups in feeds bottom sheet (#448)
Browse files Browse the repository at this point in the history
* Change `selectedFeeds` in `FeedsState` to `SelectedSources`

* Change `ObservableSelectedFeed` to `ObservableActiveSource`

* Rename bottom sheet item to `FeedBottomBarItem`

* Add queries to DB actions on collection of feed groups

* Use list instead of set for doing DB actions on multiple feeds

This is to avoid creating another set in memory after filtering by instance

* Add query to update feed group pinned at

* Add queries to delete sources in a transaction

* Change events to take `Source` instead of just `Feed`

* Show feed groups in feeds bottom sheet

* Add context action item for adding selected feeds to folder

* Add support for filtering posts by feed groups in posts queries

* Add support for refreshing selected feed group

* Fix feed group preview icons container size in feeds bottom bar

* Remove id from feed group when feed is deleted

* Add index for `pinnedAt` in `Feed` and `FeedGroup` table

* Add query to load observable number of feeds

* Add queries to load combine sources (feed & feed groups)

* Remove unused queries

* Load combined sources (feed & feed group) in feeds bottom sheet
  • Loading branch information
msasikanth authored Apr 17, 2024
1 parent 1517fc8 commit 05dab2a
Show file tree
Hide file tree
Showing 29 changed files with 1,167 additions and 374 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import kotlinx.datetime.Instant
data class FeedGroup(
override val id: String,
val name: String,
val feedIds: Set<String>,
val feedIcons: Set<String>,
val feedIds: List<String>,
val feedIcons: List<String>,
val createdAt: Instant,
val updatedAt: Instant,
override val pinnedAt: Instant?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,16 @@ val DeTwineStrings =
actionPin = "Anpinnen",
actionUnpin = "Loslösen",
actionDelete = "Löschen",
actionAddTo = "Hinzufügen zu",
actionMoveTo = "Ziehen nach",
createGroup = "Gruppe erstellen",
groupNameHint = "Name"
groupNameHint = "Name",
feedGroupNoFeeds = "Keine Feeds",
feedGroupFeeds = { numberOfFeeds ->
when (numberOfFeeds) {
1 -> "$numberOfFeeds feed"
else -> "$numberOfFeeds feeds"
}
},
actionGroupsTooltip = "Gruppen können nicht innerhalb anderer Gruppen sein.",
)
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,16 @@ val EnTwineStrings =
actionPin = "Pin",
actionUnpin = "Unpin",
actionDelete = "Delete",
actionAddTo = "Add to",
actionMoveTo = "Move to",
createGroup = "Create group",
groupNameHint = "Name"
groupNameHint = "Name",
feedGroupNoFeeds = "No feeds",
feedGroupFeeds = { numberOfFeeds ->
when (numberOfFeeds) {
1 -> "$numberOfFeeds feed"
else -> "$numberOfFeeds feeds"
}
},
actionGroupsTooltip = "Groups cannot be inside other groups.",
)
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,17 @@ val TrTwineStrings =
feedsBottomBarNewFeed = "Yeni besleme",
actionPin = "Sabitle",
actionUnpin = "Sabitlemeyi Kaldır",
actionAddTo = "a ekle",
actionMoveTo = "Taşınmak",
actionDelete = "Sil",
createGroup = "Grup oluştur",
groupNameHint = "İsim"
groupNameHint = "İsim",
feedGroupNoFeeds = "Besleme yok",
feedGroupFeeds = { numberOfFeeds ->
when (numberOfFeeds) {
1 -> "$numberOfFeeds feed"
else -> "$numberOfFeeds feeds"
}
},
actionGroupsTooltip = "Gruplar başka grupların içinde olamaz.",
)
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,13 @@ data class TwineStrings(
val actionPin: String,
val actionUnpin: String,
val actionDelete: String,
val actionAddTo: String,
val actionMoveTo: String,
val createGroup: String,
val groupNameHint: String,
val feedGroupNoFeeds: String,
val feedGroupFeeds: (Int) -> String,
val actionGroupsTooltip: String,
)

object Locales {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright 2024 Sasikanth Miriyampalli
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package dev.sasikanth.rss.reader.database

import me.tatarka.inject.annotations.Inject

@Inject
class TransactionRunner(private val database: ReaderDatabase) {

fun <T> invoke(block: () -> T): T {
return database.transactionWithResult { block() }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,6 @@ internal interface DataComponent : SqlDriverPlatformComponent, DataStorePlatform
fun providesFeedSearchFTSQueries(database: ReaderDatabase) = database.feedSearchFTSQueries

@Provides fun providesFeedGroupQueries(database: ReaderDatabase) = database.feedGroupQueries

@Provides fun providesSourceQueries(database: ReaderDatabase) = database.sourceQueries
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import com.arkivanov.essenty.instancekeeper.InstanceKeeper
import com.arkivanov.essenty.instancekeeper.getOrCreate
import com.arkivanov.essenty.lifecycle.doOnCreate
import dev.sasikanth.rss.reader.home.ui.PostsType
import dev.sasikanth.rss.reader.repository.ObservableSelectedFeed
import dev.sasikanth.rss.reader.repository.ObservableActiveSource
import dev.sasikanth.rss.reader.repository.RssRepository
import dev.sasikanth.rss.reader.repository.SettingsRepository
import dev.sasikanth.rss.reader.util.DispatchersProvider
Expand Down Expand Up @@ -58,7 +58,7 @@ class FeedPresenter(
dispatchersProvider: DispatchersProvider,
rssRepository: RssRepository,
settingsRepository: SettingsRepository,
private val observableSelectedFeed: ObservableSelectedFeed,
private val observableActiveSource: ObservableActiveSource,
@Assisted feedId: String,
@Assisted componentContext: ComponentContext,
@Assisted private val dismiss: () -> Unit
Expand All @@ -71,7 +71,7 @@ class FeedPresenter(
rssRepository = rssRepository,
settingsRepository = settingsRepository,
feedId = feedId,
observableSelectedFeed = observableSelectedFeed,
observableActiveSource = observableActiveSource,
)
}

Expand Down Expand Up @@ -99,7 +99,7 @@ class FeedPresenter(
private val rssRepository: RssRepository,
private val settingsRepository: SettingsRepository,
private val feedId: String,
private val observableSelectedFeed: ObservableSelectedFeed,
private val observableActiveSource: ObservableActiveSource,
) : InstanceKeeper.Instance {

private val coroutineScope = CoroutineScope(SupervisorJob() + dispatchersProvider.main)
Expand Down Expand Up @@ -159,7 +159,7 @@ class FeedPresenter(
private fun removeFeed() {
coroutineScope.launch {
rssRepository.removeFeed(feedId)
observableSelectedFeed.clearSelection()
observableActiveSource.clearSelection()
effects.emit(FeedEffect.DismissSheet)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package dev.sasikanth.rss.reader.feeds

import androidx.compose.ui.text.input.TextFieldValue
import dev.sasikanth.rss.reader.core.model.local.Feed
import dev.sasikanth.rss.reader.core.model.local.Source
import dev.sasikanth.rss.reader.repository.FeedsOrderBy

sealed interface FeedsEvent {
Expand All @@ -27,7 +28,7 @@ sealed interface FeedsEvent {

data class OnDeleteFeed(val feed: Feed) : FeedsEvent

data class OnToggleFeedSelection(val feed: Feed) : FeedsEvent
data class OnToggleFeedSelection(val source: Source) : FeedsEvent

data class OnFeedNameUpdated(val newFeedName: String, val feedId: String) : FeedsEvent

Expand All @@ -37,7 +38,7 @@ sealed interface FeedsEvent {

data object ClearSearchQuery : FeedsEvent

data class OnFeedClick(val feed: Feed) : FeedsEvent
data class OnFeedClick(val source: Source) : FeedsEvent

data class OnFeedSortOrderChanged(val feedsOrderBy: FeedsOrderBy) : FeedsEvent

Expand All @@ -47,13 +48,13 @@ sealed interface FeedsEvent {

data object OnHomeSelected : FeedsEvent

data object CancelFeedsSelection : FeedsEvent
data object CancelSourcesSelection : FeedsEvent

data object PinSelectedFeeds : FeedsEvent
data object PinSelectedSources : FeedsEvent

data object UnPinSelectedFeeds : FeedsEvent
data object UnPinSelectedSources : FeedsEvent

data object DeleteSelectedFeeds : FeedsEvent
data object DeleteSelectedSources : FeedsEvent

data class OnCreateGroup(val name: String) : FeedsEvent
}
Loading

0 comments on commit 05dab2a

Please sign in to comment.