From 2dd587707cfc7577200fdd4549b5668a244e5528 Mon Sep 17 00:00:00 2001 From: Tomas Timinskas Date: Thu, 9 Dec 2021 12:51:01 -0300 Subject: [PATCH] - PodcastRepository renamed to FeedRepository - All feed methods and queries moved to FeedRepository --- settings.gradle | 2 +- .../concept_repository_chat/ChatRepository.kt | 14 -------- .../.gitignore | 0 .../build.gradle | 0 .../concept_repository_feed/FeedRepository.kt | 32 +++++++++++++++++++ .../PodcastRepository.kt | 13 -------- .../features/feature-repository/build.gradle | 2 +- .../feature_repository/SphinxRepository.kt | 5 ++- .../java/chat/sphinx/di/RepositoryModule.kt | 6 ++-- .../join-tribe/join-tribe/build.gradle | 1 + .../join_tribe/ui/JoinTribeViewModel.kt | 4 ++- .../newsletter-detail/build.gradle | 1 + .../ui/NewsletterDetailViewModel.kt | 6 ++-- .../podcast-player/build.gradle | 2 +- .../ui/PodcastPlayerViewModel.kt | 13 ++++---- .../video-screen/video-screen/build.gradle | 1 + .../ui/VideoFeedScreenViewModel.kt | 6 ++-- .../detail/VideoFeedDetailScreenViewModel.kt | 5 ++- .../ui/watch/VideoFeedWatchScreenViewModel.kt | 5 ++- .../chat-common/chat-common/build.gradle | 2 +- .../chat_tribe/ui/TribeFeedViewModel.kt | 9 +++--- .../screens/dashboard/dashboard/build.gradle | 2 +- .../sphinx/dashboard/ui/feed/FeedViewModel.kt | 10 +++--- 23 files changed, 79 insertions(+), 62 deletions(-) rename sphinx/application/data/concepts/repositories/{concept-repository-podcast => concept-repository-feed}/.gitignore (100%) rename sphinx/application/data/concepts/repositories/{concept-repository-podcast => concept-repository-feed}/build.gradle (100%) create mode 100644 sphinx/application/data/concepts/repositories/concept-repository-feed/src/main/java/chat/sphinx/concept_repository_feed/FeedRepository.kt delete mode 100644 sphinx/application/data/concepts/repositories/concept-repository-podcast/src/main/java/chat/sphinx/concept_repository_podcast/PodcastRepository.kt diff --git a/settings.gradle b/settings.gradle index 9cb8366081..62f92f33fa 100644 --- a/settings.gradle +++ b/settings.gradle @@ -52,7 +52,7 @@ include ':sphinx:application:data:concepts:repositories:concept-repository-light include ':sphinx:application:data:concepts:repositories:concept-repository-media' include ':sphinx:application:data:concepts:repositories:concept-repository-message' include ':sphinx:application:data:concepts:repositories:concept-repository-subscription' -include ':sphinx:application:data:concepts:repositories:concept-repository-podcast' +include ':sphinx:application:data:concepts:repositories:concept-repository-feed' include ':sphinx:application:data:features:feature-repository' include ':sphinx:application:data:features:feature-repository-android' diff --git a/sphinx/application/data/concepts/repositories/concept-repository-chat/src/main/java/chat/sphinx/concept_repository_chat/ChatRepository.kt b/sphinx/application/data/concepts/repositories/concept-repository-chat/src/main/java/chat/sphinx/concept_repository_chat/ChatRepository.kt index 36303e8a63..2696767f94 100644 --- a/sphinx/application/data/concepts/repositories/concept-repository-chat/src/main/java/chat/sphinx/concept_repository_chat/ChatRepository.kt +++ b/sphinx/application/data/concepts/repositories/concept-repository-chat/src/main/java/chat/sphinx/concept_repository_chat/ChatRepository.kt @@ -63,20 +63,6 @@ interface ChatRepository { tribeDto: TribeDto, ): Flow> - suspend fun updateFeedContent( - chatId: ChatId, - host: ChatHost, - feedUrl: FeedUrl, - chatUUID: ChatUUID?, - subscribed: Subscribed, - currentEpisodeId: FeedId? - ) - - fun getFeedByChatId(chatId: ChatId): Flow - fun getFeedById(feedId: FeedId): Flow - - suspend fun toggleFeedSubscribeState(feedId: FeedId, currentSubscribeState: Subscribed) - suspend fun updateTribeInfo(chat: Chat): TribeData? suspend fun createTribe(createTribe: CreateTribe): Response suspend fun updateTribe(chatId: ChatId, createTribe: CreateTribe): Response diff --git a/sphinx/application/data/concepts/repositories/concept-repository-podcast/.gitignore b/sphinx/application/data/concepts/repositories/concept-repository-feed/.gitignore similarity index 100% rename from sphinx/application/data/concepts/repositories/concept-repository-podcast/.gitignore rename to sphinx/application/data/concepts/repositories/concept-repository-feed/.gitignore diff --git a/sphinx/application/data/concepts/repositories/concept-repository-podcast/build.gradle b/sphinx/application/data/concepts/repositories/concept-repository-feed/build.gradle similarity index 100% rename from sphinx/application/data/concepts/repositories/concept-repository-podcast/build.gradle rename to sphinx/application/data/concepts/repositories/concept-repository-feed/build.gradle diff --git a/sphinx/application/data/concepts/repositories/concept-repository-feed/src/main/java/chat/sphinx/concept_repository_feed/FeedRepository.kt b/sphinx/application/data/concepts/repositories/concept-repository-feed/src/main/java/chat/sphinx/concept_repository_feed/FeedRepository.kt new file mode 100644 index 0000000000..7e7eec3e0e --- /dev/null +++ b/sphinx/application/data/concepts/repositories/concept-repository-feed/src/main/java/chat/sphinx/concept_repository_feed/FeedRepository.kt @@ -0,0 +1,32 @@ +package chat.sphinx.concept_repository_feed + +import chat.sphinx.wrapper_chat.ChatHost +import chat.sphinx.wrapper_common.chat.ChatUUID +import chat.sphinx.wrapper_common.dashboard.ChatId +import chat.sphinx.wrapper_common.feed.FeedId +import chat.sphinx.wrapper_common.feed.FeedUrl +import chat.sphinx.wrapper_common.feed.Subscribed +import chat.sphinx.wrapper_feed.Feed +import chat.sphinx.wrapper_podcast.Podcast +import chat.sphinx.wrapper_podcast.PodcastSearchResultRow +import kotlinx.coroutines.flow.Flow + +interface FeedRepository { + fun getPodcastByChatId(chatId: ChatId): Flow + fun getPodcastById(feedId: FeedId): Flow + fun searchPodcastBy(searchTerm: String): Flow> + + suspend fun updateFeedContent( + chatId: ChatId, + host: ChatHost, + feedUrl: FeedUrl, + chatUUID: ChatUUID?, + subscribed: Subscribed, + currentEpisodeId: FeedId? + ) + + fun getFeedByChatId(chatId: ChatId): Flow + fun getFeedById(feedId: FeedId): Flow + + suspend fun toggleFeedSubscribeState(feedId: FeedId, currentSubscribeState: Subscribed) +} \ No newline at end of file diff --git a/sphinx/application/data/concepts/repositories/concept-repository-podcast/src/main/java/chat/sphinx/concept_repository_podcast/PodcastRepository.kt b/sphinx/application/data/concepts/repositories/concept-repository-podcast/src/main/java/chat/sphinx/concept_repository_podcast/PodcastRepository.kt deleted file mode 100644 index 6eb02f525c..0000000000 --- a/sphinx/application/data/concepts/repositories/concept-repository-podcast/src/main/java/chat/sphinx/concept_repository_podcast/PodcastRepository.kt +++ /dev/null @@ -1,13 +0,0 @@ -package chat.sphinx.concept_repository_podcast - -import chat.sphinx.wrapper_common.dashboard.ChatId -import chat.sphinx.wrapper_common.feed.FeedId -import chat.sphinx.wrapper_podcast.Podcast -import chat.sphinx.wrapper_podcast.PodcastSearchResultRow -import kotlinx.coroutines.flow.Flow - -interface PodcastRepository { - fun getPodcastByChatId(chatId: ChatId): Flow - fun getPodcastById(feedId: FeedId): Flow - fun searchPodcastBy(searchTerm: String): Flow> -} \ No newline at end of file diff --git a/sphinx/application/data/features/feature-repository/build.gradle b/sphinx/application/data/features/feature-repository/build.gradle index 426b032d37..bd4554bc51 100644 --- a/sphinx/application/data/features/feature-repository/build.gradle +++ b/sphinx/application/data/features/feature-repository/build.gradle @@ -25,7 +25,7 @@ dependencies { api project(path: ':sphinx:application:data:concepts:repositories:concept-repository-media') api project(path: ':sphinx:application:data:concepts:repositories:concept-repository-message') api project(path: ':sphinx:application:data:concepts:repositories:concept-repository-subscription') - api project(path: ':sphinx:application:data:concepts:repositories:concept-repository-podcast') + api project(path: ':sphinx:application:data:concepts:repositories:concept-repository-feed') api project(path: ':sphinx:application:network:concepts:concept-meme-input-stream') api project(path: ':sphinx:application:network:concepts:queries:concept-network-query-meme-server') diff --git a/sphinx/application/data/features/feature-repository/src/main/java/chat/sphinx/feature_repository/SphinxRepository.kt b/sphinx/application/data/features/feature-repository/src/main/java/chat/sphinx/feature_repository/SphinxRepository.kt index 92a8c42313..a36fbe3fba 100644 --- a/sphinx/application/data/features/feature-repository/src/main/java/chat/sphinx/feature_repository/SphinxRepository.kt +++ b/sphinx/application/data/features/feature-repository/src/main/java/chat/sphinx/feature_repository/SphinxRepository.kt @@ -39,7 +39,7 @@ import chat.sphinx.concept_repository_message.model.AttachmentInfo import chat.sphinx.concept_repository_message.model.SendMessage import chat.sphinx.concept_repository_message.model.SendPayment import chat.sphinx.concept_repository_message.model.SendPaymentRequest -import chat.sphinx.concept_repository_podcast.PodcastRepository +import chat.sphinx.concept_repository_feed.FeedRepository import chat.sphinx.concept_repository_subscription.SubscriptionRepository import chat.sphinx.concept_socket_io.SocketIOManager import chat.sphinx.concept_socket_io.SphinxSocketIOMessage @@ -95,7 +95,6 @@ import chat.sphinx.wrapper_message_media.* import chat.sphinx.wrapper_message_media.token.MediaHost import chat.sphinx.wrapper_podcast.Podcast import chat.sphinx.wrapper_podcast.PodcastDestination -import chat.sphinx.wrapper_podcast.PodcastSearchResult import chat.sphinx.wrapper_podcast.PodcastSearchResultRow import chat.sphinx.wrapper_relay.AuthorizationToken import chat.sphinx.wrapper_relay.RelayUrl @@ -158,7 +157,7 @@ abstract class SphinxRepository( SubscriptionRepository, RepositoryDashboard, RepositoryMedia, - PodcastRepository, + FeedRepository, CoroutineDispatchers by dispatchers, SphinxSocketIOMessageListener { diff --git a/sphinx/application/sphinx/src/main/java/chat/sphinx/di/RepositoryModule.kt b/sphinx/application/sphinx/src/main/java/chat/sphinx/di/RepositoryModule.kt index 4a76e2247a..0bdbec4a91 100644 --- a/sphinx/application/sphinx/src/main/java/chat/sphinx/di/RepositoryModule.kt +++ b/sphinx/application/sphinx/src/main/java/chat/sphinx/di/RepositoryModule.kt @@ -20,7 +20,7 @@ import chat.sphinx.concept_repository_dashboard_android.RepositoryDashboardAndro import chat.sphinx.concept_repository_lightning.LightningRepository import chat.sphinx.concept_repository_media.RepositoryMedia import chat.sphinx.concept_repository_message.MessageRepository -import chat.sphinx.concept_repository_podcast.PodcastRepository +import chat.sphinx.concept_repository_feed.FeedRepository import chat.sphinx.concept_repository_subscription.SubscriptionRepository import chat.sphinx.concept_socket_io.SocketIOManager import chat.sphinx.database.SphinxCoreDBImpl @@ -198,9 +198,9 @@ object RepositoryModule { sphinxRepositoryAndroid @Provides - fun providePodcastRepository( + fun provideFeedRepository( sphinxRepositoryAndroid: SphinxRepositoryAndroid - ): PodcastRepository = + ): FeedRepository = sphinxRepositoryAndroid @Provides diff --git a/sphinx/screens-detail/join-tribe/join-tribe/build.gradle b/sphinx/screens-detail/join-tribe/join-tribe/build.gradle index 70c1041a49..38be0c6f98 100644 --- a/sphinx/screens-detail/join-tribe/join-tribe/build.gradle +++ b/sphinx/screens-detail/join-tribe/join-tribe/build.gradle @@ -42,6 +42,7 @@ dependencies { implementation project(path: ':sphinx:application:data:concepts:concept-media-cache') implementation project(path: ':sphinx:application:data:concepts:repositories:concept-repository-contact') implementation project(path: ':sphinx:application:data:concepts:repositories:concept-repository-chat') + implementation project(path: ':sphinx:application:data:concepts:repositories:concept-repository-feed') implementation project(path: ':sphinx:application:network:concepts:queries:concept-network-query-chat') implementation project(path: ':sphinx:application:common:menus:menu-bottom-picture') implementation project(path: ':sphinx:screens-detail:common:detail-resources') diff --git a/sphinx/screens-detail/join-tribe/join-tribe/src/main/java/chat/sphinx/join_tribe/ui/JoinTribeViewModel.kt b/sphinx/screens-detail/join-tribe/join-tribe/src/main/java/chat/sphinx/join_tribe/ui/JoinTribeViewModel.kt index 8905977b3a..b1576a79d4 100644 --- a/sphinx/screens-detail/join-tribe/join-tribe/src/main/java/chat/sphinx/join_tribe/ui/JoinTribeViewModel.kt +++ b/sphinx/screens-detail/join-tribe/join-tribe/src/main/java/chat/sphinx/join_tribe/ui/JoinTribeViewModel.kt @@ -13,6 +13,7 @@ import chat.sphinx.concept_network_query_chat.NetworkQueryChat import chat.sphinx.concept_network_query_chat.model.TribeDto import chat.sphinx.concept_repository_chat.ChatRepository import chat.sphinx.concept_repository_contact.ContactRepository +import chat.sphinx.concept_repository_feed.FeedRepository import chat.sphinx.concept_view_model_coordinator.ViewModelCoordinator import chat.sphinx.join_tribe.R import chat.sphinx.join_tribe.navigation.JoinTribeNavigator @@ -53,6 +54,7 @@ internal class JoinTribeViewModel @Inject constructor( private val app: Application, private val contactRepository: ContactRepository, private val chatRepository: ChatRepository, + private val feedRepository: FeedRepository, private val networkQueryChat: NetworkQueryChat, private val cameraCoordinator: ViewModelCoordinator, private val mediaCacheHandler: MediaCacheHandler, @@ -205,7 +207,7 @@ internal class JoinTribeViewModel @Inject constructor( nnTribeInfo.feed_url?.toFeedUrl()?.let { feedUrl -> nnTribeInfo.uuid?.toChatUUID()?.let { chatUUID -> nnTribeInfo.host?.toChatHost()?.let { chatHost -> - chatRepository.updateFeedContent( + feedRepository.updateFeedContent( chatId, chatHost, feedUrl, diff --git a/sphinx/screens-detail/newsletter-detail/newsletter-detail/build.gradle b/sphinx/screens-detail/newsletter-detail/newsletter-detail/build.gradle index 6dc585c504..a8db657fce 100644 --- a/sphinx/screens-detail/newsletter-detail/newsletter-detail/build.gradle +++ b/sphinx/screens-detail/newsletter-detail/newsletter-detail/build.gradle @@ -41,6 +41,7 @@ dependencies { implementation project(path: ':sphinx:application:data:concepts:concept-image-loader') implementation project(path: ':sphinx:application:data:concepts:repositories:concept-repository-chat') + implementation project(path: ':sphinx:application:data:concepts:repositories:concept-repository-feed') implementation project(path: ':sphinx:screens-detail:common:detail-resources') implementation project(path: ':sphinx:application:common:logger') diff --git a/sphinx/screens-detail/newsletter-detail/newsletter-detail/src/main/java/chat/sphinx/newsletter_detail/ui/NewsletterDetailViewModel.kt b/sphinx/screens-detail/newsletter-detail/newsletter-detail/src/main/java/chat/sphinx/newsletter_detail/ui/NewsletterDetailViewModel.kt index a39eac6f04..0d0c65cf4f 100644 --- a/sphinx/screens-detail/newsletter-detail/newsletter-detail/src/main/java/chat/sphinx/newsletter_detail/ui/NewsletterDetailViewModel.kt +++ b/sphinx/screens-detail/newsletter-detail/newsletter-detail/src/main/java/chat/sphinx/newsletter_detail/ui/NewsletterDetailViewModel.kt @@ -4,6 +4,7 @@ import android.app.Application import androidx.lifecycle.SavedStateHandle import androidx.lifecycle.viewModelScope import chat.sphinx.concept_repository_chat.ChatRepository +import chat.sphinx.concept_repository_feed.FeedRepository import chat.sphinx.newsletter_detail.R import chat.sphinx.newsletter_detail.navigation.NewsletterDetailNavigator import chat.sphinx.wrapper_common.dashboard.ChatId @@ -29,13 +30,14 @@ internal class NewsletterDetailViewModel @Inject constructor( savedStateHandle: SavedStateHandle, private val app: Application, private val chatRepository: ChatRepository, + private val feedRepository: FeedRepository, val navigator: NewsletterDetailNavigator ): BaseViewModel(dispatchers, NewsletterDetailViewState.Idle) { private val args: NewsletterDetailFragmentArgs by savedStateHandle.navArgs() private val newsletterSharedFlow: SharedFlow = flow { - emitAll(chatRepository.getFeedByChatId(args.chatId)) + emitAll(feedRepository.getFeedByChatId(args.chatId)) }.distinctUntilChanged().shareIn( viewModelScope, SharingStarted.WhileSubscribed(2_000), @@ -66,7 +68,7 @@ internal class NewsletterDetailViewModel @Inject constructor( chatRepository.getChatById(args.chatId).firstOrNull()?.let { chat -> chat.host?.let { chatHost -> args.argFeedUrl.toFeedUrl()?.let { feedUrl -> - chatRepository.updateFeedContent( + feedRepository.updateFeedContent( chatId = chat.id, host = chatHost, feedUrl = feedUrl, diff --git a/sphinx/screens-detail/podcast-player/podcast-player/build.gradle b/sphinx/screens-detail/podcast-player/podcast-player/build.gradle index a944c6e29f..cc90c7a1fb 100644 --- a/sphinx/screens-detail/podcast-player/podcast-player/build.gradle +++ b/sphinx/screens-detail/podcast-player/podcast-player/build.gradle @@ -44,7 +44,7 @@ dependencies { implementation project(path: ':sphinx:application:data:concepts:repositories:concept-repository-chat') implementation project(path: ':sphinx:application:data:concepts:repositories:concept-repository-message') implementation project(path: ':sphinx:application:data:concepts:repositories:concept-repository-contact') - implementation project(path: ':sphinx:application:data:concepts:repositories:concept-repository-podcast') + implementation project(path: ':sphinx:application:data:concepts:repositories:concept-repository-feed') implementation project(path: ':sphinx:application:network:concepts:queries:concept-network-query-chat') api project(path: ':sphinx:service:concepts:concept-service-media-player') diff --git a/sphinx/screens-detail/podcast-player/podcast-player/src/main/java/chat/sphinx/podcast_player/ui/PodcastPlayerViewModel.kt b/sphinx/screens-detail/podcast-player/podcast-player/src/main/java/chat/sphinx/podcast_player/ui/PodcastPlayerViewModel.kt index f0193dbf48..8840dd8523 100644 --- a/sphinx/screens-detail/podcast-player/podcast-player/src/main/java/chat/sphinx/podcast_player/ui/PodcastPlayerViewModel.kt +++ b/sphinx/screens-detail/podcast-player/podcast-player/src/main/java/chat/sphinx/podcast_player/ui/PodcastPlayerViewModel.kt @@ -9,7 +9,7 @@ import app.cash.exhaustive.Exhaustive import chat.sphinx.concept_repository_chat.ChatRepository import chat.sphinx.concept_repository_contact.ContactRepository import chat.sphinx.concept_repository_message.MessageRepository -import chat.sphinx.concept_repository_podcast.PodcastRepository +import chat.sphinx.concept_repository_feed.FeedRepository import chat.sphinx.concept_service_media.MediaPlayerServiceController import chat.sphinx.concept_service_media.MediaPlayerServiceState import chat.sphinx.concept_service_media.UserAction @@ -25,7 +25,6 @@ import chat.sphinx.wrapper_podcast.PodcastEpisode import dagger.hilt.android.lifecycle.HiltViewModel import io.matthewnelson.android_feature_navigation.util.navArgs import io.matthewnelson.android_feature_viewmodel.BaseViewModel -import io.matthewnelson.android_feature_viewmodel.updateViewState import io.matthewnelson.concept_coroutines.CoroutineDispatchers import io.matthewnelson.concept_views.viewstate.ViewStateContainer import kotlinx.coroutines.delay @@ -47,7 +46,7 @@ internal class PodcastPlayerViewModel @Inject constructor( private val chatRepository: ChatRepository, private val messageRepository: MessageRepository, private val contactRepository: ContactRepository, - private val podcastRepository: PodcastRepository, + private val feedRepository: FeedRepository, savedStateHandle: SavedStateHandle, private val mediaPlayerServiceController: MediaPlayerServiceController ) : BaseViewModel( @@ -60,9 +59,9 @@ internal class PodcastPlayerViewModel @Inject constructor( private val podcastSharedFlow: SharedFlow = flow { if (args.argChatId != ChatId.NULL_CHAT_ID.toLong()) { - emitAll(podcastRepository.getPodcastByChatId(args.chatId)) + emitAll(feedRepository.getPodcastByChatId(args.chatId)) } else { - emitAll(podcastRepository.getPodcastById(args.feedId)) + emitAll(feedRepository.getPodcastById(args.feedId)) } }.distinctUntilChanged().shareIn( viewModelScope, @@ -190,7 +189,7 @@ internal class PodcastPlayerViewModel @Inject constructor( val subscribed = (chat != null || (podcast?.subscribed?.isTrue() == true)) args.argFeedUrl.toFeedUrl()?.let { feedUrl -> - chatRepository.updateFeedContent( + feedRepository.updateFeedContent( chatId = chat?.id ?: ChatId(ChatId.NULL_CHAT_ID.toLong()), host = chatHost, feedUrl = feedUrl, @@ -227,7 +226,7 @@ internal class PodcastPlayerViewModel @Inject constructor( fun toggleSubscribeState(podcast: Podcast) { viewModelScope.launch(mainImmediate) { - chatRepository.toggleFeedSubscribeState( + feedRepository.toggleFeedSubscribeState( podcast.id, podcast.subscribed ) diff --git a/sphinx/screens-detail/video-screen/video-screen/build.gradle b/sphinx/screens-detail/video-screen/video-screen/build.gradle index b008e0b6a4..f30e13b174 100644 --- a/sphinx/screens-detail/video-screen/video-screen/build.gradle +++ b/sphinx/screens-detail/video-screen/video-screen/build.gradle @@ -46,6 +46,7 @@ dependencies { implementation project(path: ':sphinx:application:data:concepts:concept-image-loader') implementation project(path: ':sphinx:application:data:concepts:concept-relay') implementation project(path: ':sphinx:application:data:concepts:repositories:concept-repository-chat') + implementation project(path: ':sphinx:application:data:concepts:repositories:concept-repository-feed') implementation deps.androidx.lifecycle.hilt implementation deps.google.hilt diff --git a/sphinx/screens-detail/video-screen/video-screen/src/main/java/chat/sphinx/video_screen/ui/VideoFeedScreenViewModel.kt b/sphinx/screens-detail/video-screen/video-screen/src/main/java/chat/sphinx/video_screen/ui/VideoFeedScreenViewModel.kt index bdbaa775a4..c03d36cc66 100644 --- a/sphinx/screens-detail/video-screen/video-screen/src/main/java/chat/sphinx/video_screen/ui/VideoFeedScreenViewModel.kt +++ b/sphinx/screens-detail/video-screen/video-screen/src/main/java/chat/sphinx/video_screen/ui/VideoFeedScreenViewModel.kt @@ -2,6 +2,7 @@ package chat.sphinx.video_screen.ui import androidx.lifecycle.viewModelScope import chat.sphinx.concept_repository_chat.ChatRepository +import chat.sphinx.concept_repository_feed.FeedRepository import chat.sphinx.video_screen.ui.viewstate.SelectedVideoViewState import chat.sphinx.video_screen.ui.viewstate.VideoFeedScreenViewState import chat.sphinx.wrapper_common.dashboard.ChatId @@ -20,10 +21,11 @@ import kotlinx.coroutines.launch internal open class VideoFeedScreenViewModel( dispatchers: CoroutineDispatchers, private val chatRepository: ChatRepository, + private val feedRepository: FeedRepository, ): BaseViewModel(dispatchers, VideoFeedScreenViewState.Idle) { private val videoFeedSharedFlow: SharedFlow = flow { - emitAll(chatRepository.getFeedByChatId(getArgChatId())) + emitAll(feedRepository.getFeedByChatId(getArgChatId())) }.distinctUntilChanged().shareIn( viewModelScope, SharingStarted.WhileSubscribed(2_000), @@ -72,7 +74,7 @@ internal open class VideoFeedScreenViewModel( chatRepository.getChatById(getArgChatId()).firstOrNull()?.let { chat -> chat.host?.let { chatHost -> getArgFeedUrl()?.let { feedUrl -> - chatRepository.updateFeedContent( + feedRepository.updateFeedContent( chatId = chat.id, host = chatHost, feedUrl = feedUrl, diff --git a/sphinx/screens-detail/video-screen/video-screen/src/main/java/chat/sphinx/video_screen/ui/detail/VideoFeedDetailScreenViewModel.kt b/sphinx/screens-detail/video-screen/video-screen/src/main/java/chat/sphinx/video_screen/ui/detail/VideoFeedDetailScreenViewModel.kt index 2822371574..4c82108350 100644 --- a/sphinx/screens-detail/video-screen/video-screen/src/main/java/chat/sphinx/video_screen/ui/detail/VideoFeedDetailScreenViewModel.kt +++ b/sphinx/screens-detail/video-screen/video-screen/src/main/java/chat/sphinx/video_screen/ui/detail/VideoFeedDetailScreenViewModel.kt @@ -2,6 +2,7 @@ package chat.sphinx.video_screen.ui.detail import androidx.lifecycle.SavedStateHandle import chat.sphinx.concept_repository_chat.ChatRepository +import chat.sphinx.concept_repository_feed.FeedRepository import chat.sphinx.video_screen.ui.VideoFeedScreenViewModel import chat.sphinx.video_screen.ui.watch.chatId import chat.sphinx.video_screen.ui.watch.feedUrl @@ -23,9 +24,11 @@ internal class VideoFeedDetailScreenViewModel @Inject constructor( dispatchers: CoroutineDispatchers, savedStateHandle: SavedStateHandle, chatRepository: ChatRepository, + feedRepository: FeedRepository, ): VideoFeedScreenViewModel( dispatchers, - chatRepository + chatRepository, + feedRepository ) { private val args: VideoFeedDetailScreenFragmentArgs by savedStateHandle.navArgs() diff --git a/sphinx/screens-detail/video-screen/video-screen/src/main/java/chat/sphinx/video_screen/ui/watch/VideoFeedWatchScreenViewModel.kt b/sphinx/screens-detail/video-screen/video-screen/src/main/java/chat/sphinx/video_screen/ui/watch/VideoFeedWatchScreenViewModel.kt index f1d85f52a6..da6ebeccea 100644 --- a/sphinx/screens-detail/video-screen/video-screen/src/main/java/chat/sphinx/video_screen/ui/watch/VideoFeedWatchScreenViewModel.kt +++ b/sphinx/screens-detail/video-screen/video-screen/src/main/java/chat/sphinx/video_screen/ui/watch/VideoFeedWatchScreenViewModel.kt @@ -5,6 +5,7 @@ import android.widget.VideoView import androidx.lifecycle.SavedStateHandle import androidx.lifecycle.viewModelScope import chat.sphinx.concept_repository_chat.ChatRepository +import chat.sphinx.concept_repository_feed.FeedRepository import chat.sphinx.video_player_controller.VideoPlayerController import chat.sphinx.video_screen.ui.VideoFeedScreenViewModel import chat.sphinx.video_screen.ui.viewstate.PlayingVideoViewState @@ -28,9 +29,11 @@ internal class VideoFeedWatchScreenViewModel @Inject constructor( dispatchers: CoroutineDispatchers, savedStateHandle: SavedStateHandle, private val chatRepository: ChatRepository, + feedRepository: FeedRepository, ): VideoFeedScreenViewModel( dispatchers, - chatRepository + chatRepository, + feedRepository ) { private val args: VideoFeedWatchScreenFragmentArgs by savedStateHandle.navArgs() diff --git a/sphinx/screens/chats/chat-common/chat-common/build.gradle b/sphinx/screens/chats/chat-common/chat-common/build.gradle index cce36b34a5..b0a6715730 100644 --- a/sphinx/screens/chats/chat-common/chat-common/build.gradle +++ b/sphinx/screens/chats/chat-common/chat-common/build.gradle @@ -57,7 +57,7 @@ dependencies { api project(path: ':sphinx:application:data:concepts:repositories:concept-repository-contact') api project(path: ':sphinx:application:data:concepts:repositories:concept-repository-message') api project(path: ':sphinx:application:data:concepts:repositories:concept-repository-media') - api project(path: ':sphinx:application:data:concepts:repositories:concept-repository-podcast') + api project(path: ':sphinx:application:data:concepts:repositories:concept-repository-feed') implementation project(path: ':sphinx:application:network:concepts:clients:concept-network-client-crypto') diff --git a/sphinx/screens/chats/chat-tribe/chat-tribe/src/main/java/chat/sphinx/chat_tribe/ui/TribeFeedViewModel.kt b/sphinx/screens/chats/chat-tribe/chat-tribe/src/main/java/chat/sphinx/chat_tribe/ui/TribeFeedViewModel.kt index d4771d0908..5cb19d06b0 100644 --- a/sphinx/screens/chats/chat-tribe/chat-tribe/src/main/java/chat/sphinx/chat_tribe/ui/TribeFeedViewModel.kt +++ b/sphinx/screens/chats/chat-tribe/chat-tribe/src/main/java/chat/sphinx/chat_tribe/ui/TribeFeedViewModel.kt @@ -11,12 +11,11 @@ import chat.sphinx.chat_tribe.navigation.TribeChatNavigator import chat.sphinx.concept_repository_chat.ChatRepository import chat.sphinx.concept_repository_media.RepositoryMedia import chat.sphinx.concept_repository_message.MessageRepository -import chat.sphinx.concept_repository_podcast.PodcastRepository +import chat.sphinx.concept_repository_feed.FeedRepository import chat.sphinx.concept_service_media.MediaPlayerServiceController import chat.sphinx.concept_service_media.MediaPlayerServiceState import chat.sphinx.concept_service_media.UserAction import chat.sphinx.podcast_player.ui.getMediaDuration -import chat.sphinx.wrapper_chat.ChatHost import chat.sphinx.wrapper_chat.isTribeOwnedByAccount import chat.sphinx.wrapper_common.feed.isPodcast import chat.sphinx.wrapper_common.feed.toSubscribed @@ -46,7 +45,7 @@ internal class TribeFeedViewModel @Inject constructor( private val navigator: TribeChatNavigator, private val chatRepository: ChatRepository, private val messageRepository: MessageRepository, - private val podcastRepository: PodcastRepository, + private val feedRepository: FeedRepository, private val repositoryMedia: RepositoryMedia, private val mediaPlayerServiceController: MediaPlayerServiceController, ) : BaseViewModel(dispatchers, TribeFeedViewState.Idle), @@ -230,7 +229,7 @@ internal class TribeFeedViewModel @Inject constructor( is TribeFeedData.Result.FeedData -> { viewModelScope.launch(mainImmediate) { - chatRepository.updateFeedContent( + feedRepository.updateFeedContent( args.chatId, data.host, data.feedUrl, @@ -244,7 +243,7 @@ internal class TribeFeedViewModel @Inject constructor( viewModelScope.launch(mainImmediate) { delay(500L) - podcastRepository.getPodcastByChatId(args.chatId).collect { podcast -> + feedRepository.getPodcastByChatId(args.chatId).collect { podcast -> podcast?.let { nnPodcast -> podcastLoaded( nnPodcast, diff --git a/sphinx/screens/dashboard/dashboard/build.gradle b/sphinx/screens/dashboard/dashboard/build.gradle index 746c7250ea..30f3727355 100644 --- a/sphinx/screens/dashboard/dashboard/build.gradle +++ b/sphinx/screens/dashboard/dashboard/build.gradle @@ -40,7 +40,7 @@ dependencies { // Sphinx api project(path: ':sphinx:application:data:concepts:repositories:concept-repository-contact') api project(path: ':sphinx:application:data:concepts:repositories:concept-repository-chat') - api project(path: ':sphinx:application:data:concepts:repositories:concept-repository-podcast') + api project(path: ':sphinx:application:data:concepts:repositories:concept-repository-feed') api project(path: ':sphinx:application:common:wrappers:wrapper-chat') implementation project(path: ':sphinx:activity:insetter-activity') diff --git a/sphinx/screens/dashboard/dashboard/src/main/java/chat/sphinx/dashboard/ui/feed/FeedViewModel.kt b/sphinx/screens/dashboard/dashboard/src/main/java/chat/sphinx/dashboard/ui/feed/FeedViewModel.kt index ad62532516..09f95bde56 100644 --- a/sphinx/screens/dashboard/dashboard/src/main/java/chat/sphinx/dashboard/ui/feed/FeedViewModel.kt +++ b/sphinx/screens/dashboard/dashboard/src/main/java/chat/sphinx/dashboard/ui/feed/FeedViewModel.kt @@ -3,7 +3,7 @@ package chat.sphinx.dashboard.ui.feed import android.content.Context import androidx.lifecycle.viewModelScope import chat.sphinx.concept_repository_chat.ChatRepository -import chat.sphinx.concept_repository_podcast.PodcastRepository +import chat.sphinx.concept_repository_feed.FeedRepository import chat.sphinx.dashboard.navigation.DashboardNavigator import chat.sphinx.dashboard.ui.viewstates.FeedViewState import chat.sphinx.wrapper_chat.ChatHost @@ -27,7 +27,7 @@ import javax.inject.Inject class FeedViewModel @Inject constructor( val dashboardNavigator: DashboardNavigator, private val chatRepository: ChatRepository, - private val podcastRepository: PodcastRepository, + private val feedRepository: FeedRepository, dispatchers: CoroutineDispatchers, ): SideEffectViewModel< Context, @@ -59,7 +59,7 @@ class FeedViewModel @Inject constructor( ) viewModelScope.launch(mainImmediate) { - podcastRepository.searchPodcastBy(searchTerm).collect { searchResults -> + feedRepository.searchPodcastBy(searchTerm).collect { searchResults -> if (searchResults.isEmpty()) { updateViewState( FeedViewState.SearchPlaceHolder @@ -98,7 +98,7 @@ class FeedViewModel @Inject constructor( searchResultSelectedJob = viewModelScope.launch(mainImmediate) { searchResult.id.toFeedId()?.let { feedId -> - chatRepository.getFeedById(feedId).collect { feed -> + feedRepository.getFeedById(feedId).collect { feed -> feed?.let { nnFeed -> goToPodcastPlayer(nnFeed) callback() @@ -109,7 +109,7 @@ class FeedViewModel @Inject constructor( viewModelScope.launch(mainImmediate) { searchResult.url.toFeedUrl()?.let { feedUrl -> - chatRepository.updateFeedContent( + feedRepository.updateFeedContent( chatId = ChatId(ChatId.NULL_CHAT_ID.toLong()), host = ChatHost(Feed.TRIBES_DEFAULT_SERVER_URL), feedUrl = feedUrl,