Skip to content

Conversation

@ArnyminerZ
Copy link
Member

Purpose

Right now AddSubscriptionScreen has a lot of overloads, and complicated LaunchedEffect calls.

Simply too much logic is on the UI. We should move it to the view model, or simplify/remove as needed.

Related to #726

Short description

  • Got rid of an overload of AddSubscriptionScreen

Checklist

  • The PR has a proper title, description and label.
  • I have self-reviewed the PR.
  • I have added documentation to complex functions and functions that can be used by other modules.
  • I have added reasonable tests or consciously decided to not add tests.

Signed-off-by: Arnau Mora <arnyminerz@proton.me>
@ArnyminerZ ArnyminerZ self-assigned this Sep 28, 2025
@ArnyminerZ ArnyminerZ added the refactoring Quality improvement of existing functions label Sep 28, 2025
@ArnyminerZ ArnyminerZ requested a review from Copilot September 28, 2025 14:11
@ArnyminerZ ArnyminerZ marked this pull request as ready for review September 28, 2025 14:12
@ArnyminerZ ArnyminerZ requested a review from sunkup September 28, 2025 14:12
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR is the first iteration of cleaning up the AddSubscriptionScreen by removing overloads and moving UI logic to the view model. The main goal is to reduce complexity in the UI layer and better separate concerns.

  • Removed one overload of AddSubscriptionScreen and consolidated the logic
  • Moved file picking logic and initialization logic from UI to the view model
  • Simplified UI state management by removing success handling from the composable

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
AddSubscriptionScreen.kt Removed overload, simplified LaunchedEffect calls, moved UI logic to view model
AddSubscriptionModel.kt Added initialize() and onFilePicked() methods, moved Toast handling from UI to view model
Comments suppressed due to low confidence (1)

app/src/main/java/at/bitfire/icsdroid/model/AddSubscriptionModel.kt:1

  • The createSubscription() method returns Unit, not a Job or Deferred, so invokeOnCompletion cannot be called on it. This will cause a compilation error.
package at.bitfire.icsdroid.model

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@ArnyminerZ
Copy link
Member Author

Okay, I will take a look at this...

@ArnyminerZ ArnyminerZ marked this pull request as draft September 28, 2025 14:13
@ArnyminerZ ArnyminerZ removed the request for review from sunkup September 28, 2025 14:13
@ArnyminerZ
Copy link
Member Author

Showing Toast messages from the view model violates the separation of concerns principle. UI-related operations like Toast should remain in the UI layer, not in the view model.

I mean, in any case, even though it's now being displayed from the ViewModel, before, the toast was still being triggered from the VM, so it doesn't make any sense...

…el.kt

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@ArnyminerZ
Copy link
Member Author

I will ignore copilot.

@ArnyminerZ ArnyminerZ marked this pull request as ready for review September 28, 2025 14:17
@ArnyminerZ ArnyminerZ requested a review from sunkup September 28, 2025 14:17
Signed-off-by: Arnau Mora <arnyminerz@proton.me>
Signed-off-by: Arnau Mora <arnyminerz@proton.me>
@ArnyminerZ ArnyminerZ removed the request for review from sunkup September 28, 2025 14:26
@ArnyminerZ ArnyminerZ marked this pull request as draft September 28, 2025 14:26
Signed-off-by: Arnau Mora <arnyminerz@proton.me>
Signed-off-by: Arnau Mora <arnyminerz@proton.me>
@ArnyminerZ ArnyminerZ requested a review from sunkup September 28, 2025 14:43
@ArnyminerZ ArnyminerZ marked this pull request as ready for review September 28, 2025 14:43
Copy link
Member

@sunkup sunkup left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding local file does not work. After picking file the subscribe button does not show up.

Signed-off-by: Arnau Mora <arnyminerz@proton.me>
Signed-off-by: Arnau Mora <arnyminerz@proton.me>
Signed-off-by: Arnau Mora <arnyminerz@proton.me>
@ArnyminerZ ArnyminerZ requested a review from sunkup September 29, 2025 10:40
Signed-off-by: Arnau Mora <arnyminerz@proton.me>
Signed-off-by: Arnau Mora <arnyminerz@proton.me>
Signed-off-by: Arnau Mora <arnyminerz@proton.me>
Copy link
Member

@sunkup sunkup left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comments. Looks good otherwise.

# Conflicts:
#	app/src/main/java/at/bitfire/icsdroid/ui/screen/AddSubscriptionScreen.kt
Signed-off-by: Arnau Mora <arnyminerz@proton.me>
@sunkup sunkup marked this pull request as draft December 11, 2025 09:56
@sunkup sunkup linked an issue Jan 7, 2026 that may be closed by this pull request
Signed-off-by: Arnau Mora <arnyminerz@proton.me>
@ArnyminerZ ArnyminerZ marked this pull request as ready for review January 12, 2026 10:24
@ArnyminerZ ArnyminerZ requested review from sunkup and removed request for sunkup January 12, 2026 10:24
@ArnyminerZ ArnyminerZ marked this pull request as draft January 12, 2026 10:25
Signed-off-by: Arnau Mora <arnyminerz@proton.me>
Signed-off-by: Arnau Mora <arnyminerz@proton.me>
@ArnyminerZ ArnyminerZ requested a review from sunkup January 12, 2026 11:00
@ArnyminerZ ArnyminerZ marked this pull request as ready for review January 12, 2026 11:00
Copy link
Member

@sunkup sunkup left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! The init block looks kind of scary, we could improve it for clarity. And I also think hashing and summing the objects might not be as performant as simply comparing the affected properties. And would there not also be risk for unnecessary recompositions?

I am happy to review again if you want to add the suggestions, but feel free to merge if you don't think the changes are necessary. 👍

Edit: I also think we should use a more descriptive title along the lines of: "Move logic from add subscription screen to model".

Signed-off-by: Arnau Mora <arnyminerz@proton.me>
Signed-off-by: Arnau Mora <arnyminerz@proton.me>
Signed-off-by: Arnau Mora <arnyminerz@proton.me>
@ArnyminerZ ArnyminerZ changed the title First iteration of AddSubscriptionScreen cleanup Move logic from UI in AddSubscriptionScreen to AddSubscriptionModel Jan 13, 2026
@ArnyminerZ ArnyminerZ requested a review from sunkup January 13, 2026 09:37
Copy link
Member

@sunkup sunkup left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Feel free to merge.

@ArnyminerZ ArnyminerZ merged commit dd700bb into main Jan 13, 2026
6 checks passed
@ArnyminerZ ArnyminerZ deleted the clean-add-subscription-screem branch January 13, 2026 09:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactoring Quality improvement of existing functions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Move logic from UI in AddSubscriptionScreen to AddSubscriptionModel

2 participants