Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wip: rewrite to remove ambient account #964

Open
wants to merge 81 commits into
base: main
Choose a base branch
from

Conversation

nikclayton
Copy link
Contributor

Absolutely not ready to merge, but pushing this makes it easier to see which bits get pulled out in to the separate PRs.


This does a few things:

  • Uses a new PachliAccount type through most of the app. This holds information that was separate (e.g., content filters, lists) in one place. The information is loaded when the app launches or the active account switches.

  • By fetching data when the account is switched / loaded it simplifies error handling, as more code can now assume the data has already been loaded. If it hasn't the code path is simply unreachable.

  • Starts to remove the "activeAccount" idiom from the code. Instead of the active account being "ambient information" every activity/fragment/viewmodel/operation is going to work with an explicitly specified account. This does a few things:

    • It ensures that long running network operations, or actions that require multiple network operations, can't inadvertently have the active account change out from under them
    • It opens up the possibility of "acting as one account while logged in as another". E.g., have two accounts, and be logged in to one account and boost a post you've seen from your other account

The new anti-harassment features will add several different types of
filtering options through the UI.

To ensure there is no confusion, rename the existing "Filters" UI and
code to "Content filters" to accurately describe what they operate on,
distinct from new filters which will act on account metadata.

Fixes #926.
# Conflicts:
#	app/src/main/res/values-gl/strings.xml
Stops MainActivity referencing AccountManager.
Instead of storing the current state in memory, push changes down to
the database, and expose flows of those changes.

Convert consumers of AccountManager.activeAccount. The change so far
is bare minimum to get things building and working, some tests don't
work yet.

Filters and lists also don't work properly because of races with the
InstanceSwitchAuthInterceptor. That'll be fixed in the next commit,
where they'll be part of the Account info and fetched when the account
info is fetched during the account switch process.
…ewmodel

# Conflicts:
#	app/lint-baseline.xml
#	app/src/main/java/app/pachli/components/notifications/NotificationsViewModel.kt
#	app/src/main/java/app/pachli/components/timeline/viewmodel/TimelineViewModel.kt
#	app/src/main/java/app/pachli/fragment/SFragment.kt
#	app/src/main/res/values-nb-rNO/strings.xml
#	app/src/main/res/values/strings.xml
#	core/domain/build.gradle.kts
…ewmodel

# Conflicts:
#	app/lint-baseline.xml
#	app/src/main/java/app/pachli/TimelineActivity.kt
#	app/src/main/java/app/pachli/adapter/FilterableStatusViewHolder.kt
#	app/src/main/java/app/pachli/adapter/StatusViewHolder.kt
#	app/src/main/java/app/pachli/components/filters/ContentFiltersActivity.kt
#	app/src/main/java/app/pachli/components/filters/ContentFiltersListener.kt
#	app/src/main/java/app/pachli/components/filters/ContentFiltersViewModel.kt
#	app/src/main/java/app/pachli/components/filters/EditContentFilterActivity.kt
#	app/src/main/java/app/pachli/components/filters/EditContentFilterViewModel.kt
#	app/src/main/java/app/pachli/components/filters/FiltersAdapter.kt
#	app/src/main/java/app/pachli/components/notifications/NotificationsFragment.kt
#	app/src/main/java/app/pachli/components/notifications/NotificationsPagingAdapter.kt
#	app/src/main/java/app/pachli/components/notifications/NotificationsViewModel.kt
#	app/src/main/java/app/pachli/components/preference/AccountPreferencesFragment.kt
#	app/src/main/java/app/pachli/components/search/fragments/SearchStatusesFragment.kt
#	app/src/main/java/app/pachli/components/timeline/TimelineFragment.kt
#	app/src/main/java/app/pachli/components/timeline/TimelinePagingAdapter.kt
#	app/src/main/java/app/pachli/components/timeline/viewmodel/CachedTimelineViewModel.kt
#	app/src/main/java/app/pachli/components/timeline/viewmodel/NetworkTimelineViewModel.kt
#	app/src/main/java/app/pachli/components/timeline/viewmodel/TimelineViewModel.kt
#	app/src/main/java/app/pachli/components/trending/viewmodel/TrendingTagsViewModel.kt
#	app/src/main/java/app/pachli/components/viewthread/ThreadAdapter.kt
#	app/src/main/java/app/pachli/components/viewthread/ViewThreadFragment.kt
#	app/src/main/java/app/pachli/components/viewthread/ViewThreadViewModel.kt
#	app/src/main/java/app/pachli/network/ContentFilterModel.kt
#	app/src/main/java/app/pachli/viewdata/NotificationViewData.kt
#	app/src/main/java/app/pachli/viewdata/StatusViewData.kt
#	app/src/test/java/app/pachli/ContentFilterV1Test.kt
#	app/src/test/java/app/pachli/components/filters/ContentContentFilterViewDataTest.kt
#	app/src/test/java/app/pachli/components/notifications/NotificationsViewModelTestBase.kt
#	app/src/test/java/app/pachli/components/timeline/CachedTimelineViewModelTestBase.kt
#	app/src/test/java/app/pachli/components/timeline/NetworkTimelineViewModelTestBase.kt
#	app/src/test/java/app/pachli/components/viewthread/ViewThreadViewModelTest.kt
#	core/data/src/main/kotlin/app/pachli/core/data/model/ContentFilter.kt
#	core/data/src/main/kotlin/app/pachli/core/data/repository/ContentFiltersRepository.kt
#	core/data/src/test/kotlin/app/pachli/core/data/repository/filtersRepository/BaseContentFiltersRepositoryTest.kt
#	core/data/src/test/kotlin/app/pachli/core/data/repository/filtersRepository/ContentFiltersRepositoryTestFlow.kt
#	core/data/src/test/kotlin/app/pachli/core/data/repository/filtersRepository/ContentFiltersRepositoryTestUpdate.kt
#	core/navigation/src/main/kotlin/app/pachli/core/navigation/Navigation.kt
#	core/network/src/main/kotlin/app/pachli/core/network/model/FilterAction.kt
#	core/network/src/main/kotlin/app/pachli/core/network/model/FilterV1.kt
#	core/network/src/main/kotlin/app/pachli/core/network/retrofit/MastodonApi.kt
…ewmodel

# Conflicts:
#	app/src/main/java/app/pachli/MainActivity.kt
…ewmodel

# Conflicts:
#	app/src/main/java/app/pachli/MainActivity.kt
#	app/src/main/java/app/pachli/components/notifications/PushNotificationHelper.kt
#	app/src/main/java/app/pachli/components/notifications/domain/AndroidNotificationsAreEnabledUseCase.kt
#	app/src/main/java/app/pachli/components/notifications/domain/EnableAllNotificationsUseCase.kt
#	app/src/main/java/app/pachli/components/preference/NotificationPreferencesFragment.kt
…ewmodel

# Conflicts:
#	app/src/main/java/app/pachli/MainActivity.kt
#	app/src/main/java/app/pachli/usecase/LogoutUseCase.kt
…ewmodel

# Conflicts:
#	app/src/main/java/app/pachli/components/search/SearchActivity.kt
#	core/data/src/main/kotlin/app/pachli/core/data/model/Server.kt
#	core/data/src/main/kotlin/app/pachli/core/data/repository/ContentFiltersRepository.kt
#	core/data/src/main/kotlin/app/pachli/core/data/repository/ServerRepository.kt
#	core/data/src/test/kotlin/app/pachli/core/data/model/ServerTest.kt
#	core/data/src/test/kotlin/app/pachli/core/data/repository/filtersRepository/BaseContentFiltersRepositoryTest.kt
#	core/model/build.gradle.kts
#	core/model/src/main/kotlin/app/pachli/core/model/ServerOperation.kt
#	core/network/src/main/kotlin/app/pachli/core/network/model/nodeinfo/NodeInfo.kt
…ewmodel

# Conflicts:
#	app/src/main/java/app/pachli/components/notifications/NotificationsViewModel.kt
#	app/src/main/java/app/pachli/components/notifications/PushNotificationHelper.kt
#	app/src/main/java/app/pachli/components/preference/NotificationPreferencesFragment.kt
#	app/src/main/java/app/pachli/components/search/SearchViewModel.kt
#	app/src/main/java/app/pachli/components/timeline/NetworkTimelineRepository.kt
#	app/src/main/java/app/pachli/components/timeline/viewmodel/CachedTimelineRemoteMediator.kt
#	app/src/main/java/app/pachli/components/timeline/viewmodel/NetworkTimelineRemoteMediator.kt
#	app/src/main/java/app/pachli/components/timeline/viewmodel/TimelineViewModel.kt
#	app/src/main/java/app/pachli/components/viewthread/ViewThreadViewModel.kt
#	app/src/main/java/app/pachli/util/ShareShortcutHelper.kt
#	app/src/test/java/app/pachli/components/timeline/CachedTimelineRemoteMediatorTest.kt
#	app/src/test/java/app/pachli/components/timeline/NetworkTimelineRemoteMediatorTest.kt
#	core/activity/build.gradle.kts
#	core/activity/src/main/kotlin/app/pachli/core/activity/BaseActivity.kt
#	core/data/build.gradle.kts
#	core/data/src/main/kotlin/app/pachli/core/data/repository/AccountManager.kt
#	core/domain/build.gradle.kts
…ewmodel

# Conflicts:
#	feature/suggestions/src/main/kotlin/app/pachli/feature/suggestions/SuggestionsViewModel.kt
…ewmodel

# Conflicts:
#	app/src/main/java/app/pachli/TimelineActivity.kt
#	app/src/main/java/app/pachli/adapter/FilterableStatusViewHolder.kt
#	app/src/main/java/app/pachli/components/filters/ContentFiltersActivity.kt
#	app/src/main/java/app/pachli/components/filters/ContentFiltersViewModel.kt
#	app/src/main/java/app/pachli/components/filters/EditContentFilterActivity.kt
#	app/src/main/java/app/pachli/components/filters/EditContentFilterViewModel.kt
#	app/src/main/java/app/pachli/components/timeline/viewmodel/CachedTimelineViewModel.kt
#	app/src/main/java/app/pachli/components/timeline/viewmodel/NetworkTimelineViewModel.kt
#	app/src/main/java/app/pachli/components/timeline/viewmodel/TimelineViewModel.kt
#	app/src/main/java/app/pachli/components/trending/viewmodel/TrendingTagsViewModel.kt
#	app/src/main/java/app/pachli/network/ContentFilterModel.kt
#	app/src/test/java/app/pachli/ContentFilterV1Test.kt
#	app/src/test/java/app/pachli/components/filters/ContentContentFilterViewDataTest.kt
#	core/data/src/main/kotlin/app/pachli/core/data/model/ContentFilter.kt
#	core/data/src/main/kotlin/app/pachli/core/data/repository/ContentFiltersRepository.kt
#	core/data/src/test/kotlin/app/pachli/core/data/repository/filtersRepository/ContentFiltersRepositoryTestFlow.kt
#	core/data/src/test/kotlin/app/pachli/core/data/repository/filtersRepository/ContentFiltersRepositoryTestUpdate.kt
#	core/navigation/src/main/kotlin/app/pachli/core/navigation/Navigation.kt
#	core/network/src/main/kotlin/app/pachli/core/network/retrofit/NewContentFilterConverterFactory.kt
Tests that rely on stubbing the MastodonAPI may have incorrect
behaviour if some of the API methods called by the system-under-test
are not stubbed. This can be difficult to track down.

Make this easier by adding a default answer for the MastodonAPI used
in tests. Any un-stubbed methods will throw an `AssertionError` with
enough information to identify the method that should be stubbed and
where it was called from.
…ewmodel

# Conflicts:
#	core/network-test/src/main/kotlin/app/pachli/core/network/di/test/FakeMastodonApiModule.kt
…ewmodel

# Conflicts:
#	app/src/main/java/app/pachli/viewmodel/EditProfileViewModel.kt
…ewmodel

# Conflicts:
#	core/database/schemas/app.pachli.core.database.AppDatabase/6.json
#	core/database/src/main/kotlin/app/pachli/core/database/AppDatabase.kt
- handle error cases, provide retry or re-auth options
-
- Allows MainActivity to show refresh errors with a retry option
…ewmodel

# Conflicts:
#	app/src/main/java/app/pachli/components/timeline/viewmodel/TimelineViewModel.kt
#	app/src/main/java/app/pachli/components/viewthread/ViewThreadViewModel.kt
…ewmodel

# Conflicts:
#	app/src/main/java/app/pachli/MainActivity.kt
#	app/src/main/java/app/pachli/components/compose/ComposeViewModel.kt
#	app/src/main/java/app/pachli/components/preference/PreferencesFragment.kt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant