Commit Graph

6 Commits

Author SHA1 Message Date
Nik Clayton 710e209e34
refactor: Ongoing work to remove the `activeAccount` idiom (#964)
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>
2024-11-13 11:45:16 +01:00
Nik Clayton c8aa4fd374
fix: Disable "Scheduled post" support on GoToSocial accounts (#1025)
GoToSocial servers don't support scheduled posts; they return the wrong
type, and this can cause a loop of posting.

The GoToSocial bug to implement scheduled posts is
https://github.com/superseriousbusiness/gotosocial/issues/1006.

Fix this by adding a new server capability for scheduled post support,
using it for most servers, and disabling it for GoToSocial.

If scheduled post support is not available for an account:

- The "Scheduled posts" menu option is not shown.
- The scheduling button (clock) when composing a post is hidden, so the
user cannot set scheduling parameters.

Fixes #963
2024-10-18 15:37:10 +02:00
Nik Clayton 668c073822
refactor: Assorted code inspection cleanups (#985)
Code inspection found some mechanical code cleanups.
2024-10-07 12:38:35 +02:00
Nik Clayton 65c73625f6
refactor: Create V2 filters with one API call (#979)
Previous code didn't encode v2 filter keywords, so created v2 filters by
first creating the filter with no keywords (one API call) then making
1-N API calls to add each keyword to the filter.

Fix this by adding a dedicated converter for the `NewContentFilter` type
that encodes it correctly so the filter can be created with a single API
call.

This necessitates moving some types around,
2024-10-05 14:53:23 +02:00
Nik Clayton fe1c586dae
refactor: Move ServerOperation and related types to core.model (#969) 2024-10-03 13:41:46 +02:00
Nik Clayton 8257ded395
refactor: Remove `TabData` type (#576)
`TabData` recorded the type of the timeline the user had added to a tab.
`TimelineKind` is another type that records general information about
configured timelines, with identical properties.

There's no need for both, so remove `TabData` and use `TimelineKind` in
its place.

`TimelineKind` is itself mis-named; it's not just the timeline's kind
but also holds data necessary to display that timeline (e.g., the list
ID if it's a `.UserList`, or the hashtags if it's a `.Hashtags`) so
rename to `Timeline` to better reflect its usage. Move it to a new
`core.model` module.
2024-03-30 23:27:25 +01:00