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

@IntDef(Toast.LENGTH_SHORT, Toast.LENGTH_LONG)
annotation class ToastDuration

suspend fun toastAsync(
Copy link
Member

Choose a reason for hiding this comment

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

This seems unnecessarily confusing to me. I am sorry, that I said we could extract it to utils. It does not make sense. I think it's much better to simply trigger and handle cancelation in place when needed. Either in the screens (preferably) or the view model if you think that's much cleaner.

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.

2 participants