Skip to content

Commit

Permalink
refactor: Ongoing work to remove the activeAccount idiom (#964)
Browse files Browse the repository at this point in the history
Continue the work to remove the "activeAccount" idiom.

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

- Fetching data when the account is switched / loaded 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.

- This 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.

- Add a database migration to populate existing accounts with default
data when the user updates the app.

- Refactor code that used those list and filter repositories to get the
data from the PachliAccount instead. New local and remote data sources
are implemented, and the list and filter repositories mediate between
those sources.

- Start a ViewModel for MainActivity, which includes:
  - Sending user actions as UiAction objects
  - Providing a flow of uiState for MainActivity to react to
  - Remove most uses of SharedPreferencesRepository from MainActivity
  - Show messages about errors that occur when logging in

- Refactor intent routing in MainActivity to make the logic clearer.

- Add new `core.data` types to push more `core.network` types out of the
UI code
  - `core.data.model.MastodonList` for `core.network.model.MastoList`
  - `core.data.model.Server` for `core.network.model.Server`

- Continue the work to send the Pachli account ID to the code that uses
it.
  - Most view models now get the account ID via assisted injection.
- QueuedMedia now includes the AccountEntity so it can operate with any
account. Modify the `uploadMedia` API call to include explicit
authentication details.

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
  • Loading branch information
nikclayton and renovate[bot] authored Nov 13, 2024
1 parent 6c178b5 commit 710e209
Show file tree
Hide file tree
Showing 195 changed files with 7,983 additions and 3,376 deletions.
58 changes: 29 additions & 29 deletions app/lint-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,7 @@
errorLine2=" ^">
<location
file="src/main/res/values-nb-rNO/strings.xml"
line="629"
line="626"
column="43"/>
</issue>

Expand All @@ -723,7 +723,7 @@
errorLine2=" ^">
<location
file="src/main/res/values-nb-rNO/strings.xml"
line="721"
line="718"
column="51"/>
</issue>

Expand All @@ -734,7 +734,7 @@
errorLine2=" ^">
<location
file="src/main/res/values-nb-rNO/strings.xml"
line="745"
line="742"
column="68"/>
</issue>

Expand Down Expand Up @@ -800,7 +800,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/res/values/strings.xml"
line="444"
line="442"
column="5"/>
</issue>

Expand All @@ -811,7 +811,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/res/values/strings.xml"
line="617"
line="614"
column="5"/>
</issue>

Expand Down Expand Up @@ -1383,7 +1383,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/res/values/strings.xml"
line="410"
line="408"
column="13"/>
</issue>

Expand All @@ -1394,7 +1394,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/res/values/strings.xml"
line="413"
line="411"
column="13"/>
</issue>

Expand All @@ -1405,7 +1405,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/res/values/strings.xml"
line="414"
line="412"
column="13"/>
</issue>

Expand All @@ -1416,7 +1416,7 @@
errorLine2=" ~~~~~~~~~~~~">
<location
file="src/main/res/values/strings.xml"
line="415"
line="413"
column="13"/>
</issue>

Expand All @@ -1427,7 +1427,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/res/values/strings.xml"
line="417"
line="415"
column="13"/>
</issue>

Expand All @@ -1438,7 +1438,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/res/values/strings.xml"
line="429"
line="427"
column="13"/>
</issue>

Expand All @@ -1449,7 +1449,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/res/values/strings.xml"
line="430"
line="428"
column="13"/>
</issue>

Expand All @@ -1460,7 +1460,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/res/values/strings.xml"
line="482"
line="480"
column="13"/>
</issue>

Expand All @@ -1471,7 +1471,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/res/values/strings.xml"
line="483"
line="481"
column="13"/>
</issue>

Expand All @@ -1482,7 +1482,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/res/values/strings.xml"
line="494"
line="491"
column="13"/>
</issue>

Expand All @@ -1493,7 +1493,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/res/values/strings.xml"
line="495"
line="492"
column="13"/>
</issue>

Expand All @@ -1504,7 +1504,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/res/values/strings.xml"
line="496"
line="493"
column="13"/>
</issue>

Expand All @@ -1515,7 +1515,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/res/values/strings.xml"
line="499"
line="496"
column="13"/>
</issue>

Expand All @@ -1526,7 +1526,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/res/values/strings.xml"
line="537"
line="534"
column="13"/>
</issue>

Expand All @@ -1537,7 +1537,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/res/values/strings.xml"
line="579"
line="576"
column="13"/>
</issue>

Expand All @@ -1548,7 +1548,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/res/values/strings.xml"
line="585"
line="582"
column="13"/>
</issue>

Expand All @@ -1559,7 +1559,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/res/values/strings.xml"
line="609"
line="606"
column="13"/>
</issue>

Expand All @@ -1570,7 +1570,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/res/values/strings.xml"
line="635"
line="632"
column="13"/>
</issue>

Expand Down Expand Up @@ -1687,7 +1687,7 @@
errorLine2=" ~~~~~~~~">
<location
file="src/main/res/layout/activity_compose.xml"
line="368"
line="369"
column="10"/>
</issue>

Expand Down Expand Up @@ -2541,12 +2541,12 @@
<issue
id="ReportShortcutUsage"
message="Calling this method indicates use of dynamic shortcuts, but there are no calls to methods that track shortcut usage, such as `pushDynamicShortcut` or `reportShortcutUsed`. Calling these methods is recommended, as they track shortcut usage and allow launchers to adjust which shortcuts appear based on activation history. Please see https://developer.android.com/develop/ui/views/launch/shortcuts/managing-shortcuts#track-usage"
errorLine1=" ShortcutManagerCompat.setDynamicShortcuts(context, shortcuts)"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
errorLine1=" ShortcutManagerCompat.setDynamicShortcuts(context, shortcuts)"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/app/pachli/util/ShareShortcutHelper.kt"
line="96"
column="5"/>
file="src/main/java/app/pachli/util/UpdateShortCutsUseCase.kt"
line="106"
column="9"/>
</issue>

<issue
Expand Down
1 change: 1 addition & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@

# keep members of our model classes, they are used in json de/serialization
-keepclassmembers class app.pachli.core.network.model.** { *; }
-keepclassmembers class app.pachli.core.model.** { *; }

-keep public enum app.pachli.core.network.model.*$** {
**[] $VALUES;
Expand Down
Loading

0 comments on commit 710e209

Please sign in to comment.