Skip to content

Commit

Permalink
Sync feed updates (#83)
Browse files Browse the repository at this point in the history
* Remove code to update a folder

* Update fastlane

* Sync changes when updating a feed

* Sync unsubscribe state
  • Loading branch information
jocmp authored Apr 8, 2024
1 parent c9d5f52 commit 568c708
Show file tree
Hide file tree
Showing 47 changed files with 620 additions and 931 deletions.
59 changes: 31 additions & 28 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,29 +1,32 @@
GEM
remote: https://rubygems.org/
specs:
CFPropertyList (3.0.6)
CFPropertyList (3.0.7)
base64
nkf
rexml
addressable (2.8.6)
public_suffix (>= 2.0.2, < 6.0)
artifactory (3.0.15)
artifactory (3.0.17)
atomos (0.1.3)
aws-eventstream (1.3.0)
aws-partitions (1.880.0)
aws-sdk-core (3.190.2)
aws-partitions (1.909.0)
aws-sdk-core (3.191.6)
aws-eventstream (~> 1, >= 1.3.0)
aws-partitions (~> 1, >= 1.651.0)
aws-sigv4 (~> 1.8)
jmespath (~> 1, >= 1.6.1)
aws-sdk-kms (1.76.0)
aws-sdk-core (~> 3, >= 3.188.0)
aws-sdk-kms (1.78.0)
aws-sdk-core (~> 3, >= 3.191.0)
aws-sigv4 (~> 1.1)
aws-sdk-s3 (1.142.0)
aws-sdk-core (~> 3, >= 3.189.0)
aws-sdk-s3 (1.146.1)
aws-sdk-core (~> 3, >= 3.191.0)
aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.8)
aws-sigv4 (1.8.0)
aws-eventstream (~> 1, >= 1.0.2)
babosa (1.0.4)
base64 (0.2.0)
claide (1.1.0)
colored (1.2)
colored2 (3.1.2)
Expand All @@ -35,7 +38,7 @@ GEM
domain_name (0.6.20240107)
dotenv (2.8.1)
emoji_regex (3.2.3)
excon (0.109.0)
excon (0.110.0)
faraday (1.10.3)
faraday-em_http (~> 1.0)
faraday-em_synchrony (~> 1.0)
Expand Down Expand Up @@ -64,15 +67,15 @@ GEM
faraday-retry (1.0.3)
faraday_middleware (1.2.0)
faraday (~> 1.0)
fastimage (2.3.0)
fastlane (2.219.0)
fastimage (2.3.1)
fastlane (2.220.0)
CFPropertyList (>= 2.3, < 4.0.0)
addressable (>= 2.8, < 3.0.0)
artifactory (~> 3.0)
aws-sdk-s3 (~> 1.0)
babosa (>= 1.0.3, < 2.0.0)
bundler (>= 1.12.0, < 3.0.0)
colored
colored (~> 1.2)
commander (~> 4.6)
dotenv (>= 2.1.1, < 3.0.0)
emoji_regex (>= 0.1, < 4.0)
Expand All @@ -93,10 +96,10 @@ GEM
mini_magick (>= 4.9.4, < 5.0.0)
multipart-post (>= 2.0.0, < 3.0.0)
naturally (~> 2.2)
optparse (>= 0.1.1)
optparse (>= 0.1.1, < 1.0.0)
plist (>= 3.1.0, < 4.0.0)
rubyzip (>= 2.0.0, < 3.0.0)
security (= 0.1.3)
security (= 0.1.5)
simctl (~> 1.6.3)
terminal-notifier (>= 2.0.0, < 3.0.0)
terminal-table (~> 3)
Expand All @@ -105,31 +108,30 @@ GEM
word_wrap (~> 1.0.0)
xcodeproj (>= 1.13.0, < 2.0.0)
xcpretty (~> 0.3.0)
xcpretty-travis-formatter (>= 0.0.3)
xcpretty-travis-formatter (>= 0.0.3, < 2.0.0)
gh_inspector (1.1.3)
google-apis-androidpublisher_v3 (0.54.0)
google-apis-core (>= 0.11.0, < 2.a)
google-apis-core (0.11.2)
google-apis-core (0.11.3)
addressable (~> 2.5, >= 2.5.1)
googleauth (>= 0.16.2, < 2.a)
httpclient (>= 2.8.1, < 3.a)
mini_mime (~> 1.0)
representable (~> 3.0)
retriable (>= 2.0, < 4.a)
rexml
webrick
google-apis-iamcredentials_v1 (0.17.0)
google-apis-core (>= 0.11.0, < 2.a)
google-apis-playcustomapp_v1 (0.13.0)
google-apis-core (>= 0.11.0, < 2.a)
google-apis-storage_v1 (0.31.0)
google-apis-core (>= 0.11.0, < 2.a)
google-cloud-core (1.6.1)
google-cloud-core (1.7.0)
google-cloud-env (>= 1.0, < 3.a)
google-cloud-errors (~> 1.0)
google-cloud-env (1.6.0)
faraday (>= 0.17.3, < 3.0)
google-cloud-errors (1.3.1)
google-cloud-errors (1.4.0)
google-cloud-storage (1.47.0)
addressable (~> 2.8)
digest-crc (~> 0.4)
Expand All @@ -149,19 +151,21 @@ GEM
domain_name (~> 0.5)
httpclient (2.8.3)
jmespath (1.6.2)
json (2.7.1)
jwt (2.7.1)
json (2.7.2)
jwt (2.8.1)
base64
mini_magick (4.12.0)
mini_mime (1.1.5)
multi_json (1.15.0)
multipart-post (2.3.0)
multipart-post (2.4.0)
nanaimo (0.3.0)
naturally (2.2.1)
nkf (0.2.0)
optparse (0.4.0)
os (1.1.4)
plist (3.7.1)
public_suffix (5.0.4)
rake (13.1.0)
public_suffix (5.0.5)
rake (13.2.1)
representable (3.2.0)
declarative (< 0.1.0)
trailblazer-option (>= 0.1.1, < 0.2.0)
Expand All @@ -171,8 +175,8 @@ GEM
rouge (2.0.7)
ruby2_keywords (0.0.5)
rubyzip (2.3.2)
security (0.1.3)
signet (0.18.0)
security (0.1.5)
signet (0.19.0)
addressable (~> 2.8)
faraday (>= 0.17.5, < 3.a)
jwt (>= 1.5, < 3.0)
Expand All @@ -190,9 +194,8 @@ GEM
tty-cursor (~> 0.7)
uber (0.1.0)
unicode-display_width (2.5.0)
webrick (1.8.1)
word_wrap (1.0.0)
xcodeproj (1.23.0)
xcodeproj (1.24.0)
CFPropertyList (>= 2.3.3, < 4.0)
atomos (~> 0.1.3)
claide (>= 1.0.2, < 2.0)
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.BasilReader"
tools:targetApi="31">
android:enableOnBackInvokedCallback="true"
tools:targetApi="33">
<activity
android:name=".MainActivity"
android:exported="true"
android:label="@string/app_name"
android:theme="@style/Theme.BasilReader">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import com.jocmp.basil.Folder
import com.jocmp.basil.buildPager
import com.jocmp.basil.countAll
import com.jocmp.basilreader.common.AppPreferences
import com.jocmp.basilreader.refresher.RefreshScheduler
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.Job
Expand All @@ -29,7 +28,6 @@ import kotlinx.coroutines.launch
@OptIn(ExperimentalCoroutinesApi::class)
class AccountViewModel(
private val account: Account,
private val refreshScheduler: RefreshScheduler,
private val appPreferences: AppPreferences,
) : ViewModel() {
private var refreshJob: Job? = null
Expand All @@ -51,6 +49,8 @@ class AccountViewModel(
.withPositiveCount(filterStatus)
}

val allFeeds = account.allFeeds

val feeds = account.feeds.combine(_counts) { feeds, latestCounts ->
feeds.map { copyFeedCounts(it, latestCounts) }
.withPositiveCount(filterStatus)
Expand Down Expand Up @@ -80,7 +80,7 @@ class AccountViewModel(

suspend fun selectFeed(feedID: String) {
val feed = account.findFeed(feedID) ?: return
val feedFilter = ArticleFilter.Feeds(feed = feed, feedStatus = filter.value.status)
val feedFilter = ArticleFilter.Feeds(feedID = feed.id, feedStatus = filter.value.status)

selectArticleFilter(feedFilter)
}
Expand All @@ -89,7 +89,7 @@ class AccountViewModel(
viewModelScope.launch {
val folder = account.findFolder(title) ?: return@launch
val feedFilter =
ArticleFilter.Folders(folder = folder, folderStatus = filter.value.status)
ArticleFilter.Folders(folderTitle = folder.title, folderStatus = filter.value.status)

selectArticleFilter(feedFilter)
}
Expand All @@ -102,19 +102,12 @@ class AccountViewModel(
}
}

fun removeFolder(folderTitle: String) {
viewModelScope.launch {
account.removeFolder(title = folderTitle)
resetToDefaultFilter()
}
}

fun refreshFeed(onComplete: () -> Unit) {
refreshJob?.cancel()

refreshJob = viewModelScope.launch(Dispatchers.IO) {
account.refresh()

onComplete()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ import com.jocmp.basilreader.ui.components.rememberWebViewNavigator
import com.jocmp.basilreader.ui.fixtures.FeedPreviewFixture
import com.jocmp.basilreader.ui.fixtures.FolderPreviewFixture
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.async
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.emptyFlow
Expand All @@ -60,6 +59,7 @@ fun ArticleLayout(
filter: ArticleFilter,
folders: List<Folder>,
feeds: List<Feed>,
allFeeds: List<Feed>,
articles: Flow<PagingData<Article>>,
article: Article?,
statusCount: Long,
Expand All @@ -69,10 +69,8 @@ fun ArticleLayout(
onSelectArticleFilter: () -> Unit,
onSelectStatus: (status: ArticleStatus) -> Unit,
onSelectArticle: (articleID: String, completion: (article: Article) -> Unit) -> Unit,
onEditFolder: (folderTitle: String) -> Unit,
onEditFeed: (feedID: String) -> Unit,
onRemoveFeed: (feedID: String) -> Unit,
onRemoveFolder: (folderTitle: String) -> Unit,
onNavigateToAccounts: () -> Unit,
onClearArticle: () -> Unit,
onToggleArticleRead: () -> Unit,
Expand All @@ -94,6 +92,7 @@ fun ArticleLayout(
val state = rememberPullToRefreshState()
val snackbarHost = remember { SnackbarHostState() }
val addFeedSuccessMessage = stringResource(R.string.add_feed_success)
val currentFeed = findCurrentFeed(filter, allFeeds)

val navigateToDetail = {
navigator.navigateTo(ListDetailPaneScaffoldRole.Detail)
Expand Down Expand Up @@ -168,7 +167,13 @@ fun ArticleLayout(
Scaffold(
topBar = {
TopAppBar(
title = { FilterAppBarTitle(filter) },
title = {
FilterAppBarTitle(
filter = filter,
allFeeds = allFeeds,
folders = folders,
)
},
navigationIcon = {
IconButton(onClick = { coroutineScope.launch { drawerState.open() } }) {
Icon(
Expand All @@ -178,13 +183,13 @@ fun ArticleLayout(
}
},
actions = {
FilterActionMenu(
filter = filter,
onFeedEdit = onEditFeed,
onFolderEdit = onEditFolder,
onRemoveFeed = onRemoveFeed,
onRemoveFolder = onRemoveFolder,
)
if (currentFeed != null) {
FilterActionMenu(
feed = currentFeed,
onFeedEdit = onEditFeed,
onRemoveFeed = onRemoveFeed,
)
}
}
)
},
Expand Down Expand Up @@ -251,6 +256,14 @@ fun ArticleLayout(
}
}

fun findCurrentFeed(filter: ArticleFilter, feeds: List<Feed>): Feed? {
if (filter is ArticleFilter.Feeds) {
return feeds.find { it.id == filter.feedID }
}

return null
}

@Preview
@Composable
fun ArticleLayoutPreview() {
Expand All @@ -260,26 +273,25 @@ fun ArticleLayoutPreview() {
MaterialTheme {
ArticleLayout(
filter = ArticleFilter.default(),
allFeeds = emptyList(),
folders = folders,
feeds = feeds,
articles = emptyFlow(),
article = null,
statusCount = 30,
drawerValue = DrawerValue.Open,
onFeedRefresh = {},
onSelectFolder = {},
onSelectFeed = {},
onSelectArticleFilter = { },
onSelectStatus = {},
onSelectArticle = { _, _ -> },
onEditFolder = {},
onEditFeed = {},
onRemoveFeed = {},
onRemoveFolder = {},
onNavigateToAccounts = { },
onClearArticle = { },
onToggleArticleRead = { },
onToggleArticleStar = {},
drawerValue = DrawerValue.Open,
)
}
}
Loading

0 comments on commit 568c708

Please sign in to comment.