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

Create view with custom lists to edit #5909

Merged
merged 1 commit into from
Mar 15, 2024

Conversation

rablador
Copy link
Contributor

@rablador rablador commented Mar 6, 2024

When a user decides to edit a custom list they will be sent to a view with all available custom lists. It should look like the view with similar functionality in api access methods. Clicking on one of lists will take the user to an edit screen.


This change is Reviewable

@rablador rablador added the iOS Issues related to iOS label Mar 6, 2024
Copy link

linear bot commented Mar 6, 2024

@rablador rablador force-pushed the create-view-with-custom-lists-to-edit-ios-542 branch 5 times, most recently from d143b39 to 6a5dc32 Compare March 12, 2024 08:58
@rablador rablador force-pushed the create-view-with-custom-lists-to-edit-ios-542 branch from 6a5dc32 to 68903ea Compare March 12, 2024 09:04
Copy link
Contributor

@buggmagnet buggmagnet left a comment

Choose a reason for hiding this comment

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

Reviewed 16 of 16 files at r1, all commit messages.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @rablador)


ios/MullvadVPN/Coordinators/LocationCoordinator.swift line 147 at r1 (raw file):

                "CUSTOM_LIST_ACTION_SHEET_NEW_LIST",
                tableName: "CustomLists",
                value: "Add new list",

Shall we add a TODO comment for localisation purposes ?


ios/MullvadVPN/Coordinators/CustomLists/CustomListInteractor.swift line 25 at r1 (raw file):

    func saveCustomList(viewModel: CustomListViewModel) throws {
        try _ = repository.save(list: viewModel.customList)

Did you mean try repository.save(list: viewModel.customList) ?


ios/MullvadVPN/Coordinators/CustomLists/ListCustomListViewController.swift line 97 at r1 (raw file):

            "LIST_CUSTOM_LIST_NAVIGATION_TITLE",
            tableName: "CustomList",
            value: "Edit custom list",

Let's add / reuse localized strings here as well


ios/MullvadVPN/Coordinators/CustomLists/ListCustomListViewController.swift line 101 at r1 (raw file):

        )

        navigationItem.rightBarButtonItem = UIBarButtonItem(

If I'm not mistaken, rightBarButtonItem has a strong reference to the UIBarButtonItem which means by extension, a strong reference to the closure passed to UIAction's handler and therefore, to self.

Long story short, I think we want to do the following instead

primaryAction: UIAction(handler: {[weak self] _ in
    self?.didFinish?()
})

Copy link
Collaborator

@mojganii mojganii left a comment

Choose a reason for hiding this comment

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

Reviewable status: all files reviewed, 8 unresolved discussions (waiting on @buggmagnet and @rablador)


ios/MullvadVPN/Coordinators/LocationCoordinator.swift line 131 at r1 (raw file):

    }

    private func showCustomListActionSheet() {

nit: do really we need to make a function for this which is called once? IMO this can be placed into didRequestRouteToCustomLists


ios/MullvadVPN/Coordinators/LocationCoordinator.swift line 145 at r1 (raw file):

        actionSheet.addAction(UIAlertAction(
            title: NSLocalizedString(
                "CUSTOM_LIST_ACTION_SHEET_NEW_LIST",

it seems the sentence is not desprictive.

Code snippet:

  actionSheet.addAction(UIAlertAction(
            title: NSLocalizedString(
                "CUSTOM_LIST_ACTION_SHEET_ADD_NEW_LIST",
                tableName: "CustomLists",
                value: "Add new list",
                comment: ""
            ),
            style: .default,
            handler: { _ in
                self.showAddCustomList()
            }
        ))

ios/MullvadVPN/Coordinators/CustomLists/CustomListInteractor.swift line 12 at r1 (raw file):

protocol CustomListInteractorProtocol {
    func fetchAllCustomLists() -> [CustomList]

CustomList keywords in function names are redundant .


ios/MullvadVPN/Coordinators/CustomLists/ListCustomListViewController.swift line 101 at r1 (raw file):

Previously, buggmagnet wrote…

If I'm not mistaken, rightBarButtonItem has a strong reference to the UIBarButtonItem which means by extension, a strong reference to the closure passed to UIAction's handler and therefore, to self.

Long story short, I think we want to do the following instead

primaryAction: UIAction(handler: {[weak self] _ in
    self?.didFinish?()
})

+1


ios/MullvadVPN/Coordinators/CustomLists/ListCustomListViewController.swift line 145 at r1 (raw file):

extension ListCustomListViewController: UITableViewDelegate {
    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        UIMetrics.SettingsCell.apiAccessCellHeight

it has noting to do with api access.let's table view use UITableView.automaticDimension or set hardcoded value.

Copy link
Collaborator

@mojganii mojganii left a comment

Choose a reason for hiding this comment

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

Reviewable status: all files reviewed, 8 unresolved discussions (waiting on @buggmagnet and @rablador)


ios/MullvadVPN/Coordinators/CustomLists/ListCustomListViewController.swift line 145 at r1 (raw file):

Previously, mojganii wrote…

it has noting to do with api access.let's table view use UITableView.automaticDimension or set hardcoded value.

moreover, if all cells have the same height I would suggest to do that through tableView.rowHeight = X instead of recalculating them every time by tableview

@rablador rablador force-pushed the create-view-with-custom-lists-to-edit-ios-542 branch 6 times, most recently from 34c8560 to c6c49c7 Compare March 13, 2024 14:13
Copy link
Contributor Author

@rablador rablador left a comment

Choose a reason for hiding this comment

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

Reviewable status: 5 of 24 files reviewed, 7 unresolved discussions (waiting on @buggmagnet and @mojganii)


ios/MullvadVPN/Coordinators/LocationCoordinator.swift line 131 at r1 (raw file):

Previously, mojganii wrote…

nit: do really we need to make a function for this which is called once? IMO this can be placed into didRequestRouteToCustomLists

Done.


ios/MullvadVPN/Coordinators/LocationCoordinator.swift line 145 at r1 (raw file):

Previously, mojganii wrote…

it seems the sentence is not desprictive.

Done.


ios/MullvadVPN/Coordinators/LocationCoordinator.swift line 147 at r1 (raw file):

Previously, buggmagnet wrote…

Shall we add a TODO comment for localisation purposes ?

Not sure I follow.


ios/MullvadVPN/Coordinators/CustomLists/CustomListInteractor.swift line 12 at r1 (raw file):

Previously, mojganii wrote…

CustomList keywords in function names are redundant .

Done.


ios/MullvadVPN/Coordinators/CustomLists/CustomListInteractor.swift line 25 at r1 (raw file):

Previously, buggmagnet wrote…

Did you mean try repository.save(list: viewModel.customList) ?

Done.


ios/MullvadVPN/Coordinators/CustomLists/ListCustomListViewController.swift line 97 at r1 (raw file):

Previously, buggmagnet wrote…

Let's add / reuse localized strings here as well

Resuse from where?


ios/MullvadVPN/Coordinators/CustomLists/ListCustomListViewController.swift line 101 at r1 (raw file):

Previously, mojganii wrote…

+1

Done.


ios/MullvadVPN/Coordinators/CustomLists/ListCustomListViewController.swift line 145 at r1 (raw file):

Previously, mojganii wrote…

moreover, if all cells have the same height I would suggest to do that through tableView.rowHeight = X instead of recalculating them every time by tableview

Done.

Copy link
Contributor Author

@rablador rablador left a comment

Choose a reason for hiding this comment

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

Reviewable status: 5 of 24 files reviewed, 8 unresolved discussions (waiting on @buggmagnet and @mojganii)


ios/MullvadVPN/Coordinators/CustomLists/ListCustomListCoordinator.swift line 73 at r2 (raw file):

    }

    private func updateRelayConstraints(for action: EditCustomListCoordinator.FinishAction, in list: CustomList) {

Makes sure we update the relay constraints / relay selector whenever we make changes to a list we're currently using.

@rablador rablador force-pushed the create-view-with-custom-lists-to-edit-ios-542 branch from c6c49c7 to 58b1b13 Compare March 14, 2024 07:54
Copy link
Contributor

@buggmagnet buggmagnet left a comment

Choose a reason for hiding this comment

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

Reviewed 19 of 19 files at r2, 1 of 1 files at r3, all commit messages.
Reviewable status: all files reviewed, 9 unresolved discussions (waiting on @mojganii and @rablador)


ios/MullvadTypes/RelayConstraints.swift line 32 at r3 (raw file):

    // Added in 2024.1
    public var locations: RelayConstraint<UserSelectedRelays>

As it stands right now, if the user updates their application whilst being connected, it will force them into blocked mode because their currently selected relay constraints will not match anymore.

Can we prevent this from happening ?


ios/MullvadVPN/Coordinators/LocationCoordinator.swift line 147 at r1 (raw file):

Previously, rablador (Jon Petersson) wrote…

Not sure I follow.

Nevermind, I think I misread the original code


ios/MullvadVPN/Coordinators/LocationCoordinator.swift line 45 at r3 (raw file):

    deinit {
        print("deinit LocationCoordinator")

We probably want to remove this


ios/MullvadVPN/Coordinators/CustomLists/ListCustomListCoordinator.swift line 48 at r3 (raw file):

    deinit {
        print("deinit ListCustomListCoordinator")

Let's remove this too


ios/MullvadVPN.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved line 22 at r3 (raw file):

    }
  ],
  "version" : 3

This comes from Xcode 15.3 which we do not use yet in the CI, please revert this file with the following command
git checkout main -- MullvadVPN.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/

@rablador rablador force-pushed the create-view-with-custom-lists-to-edit-ios-542 branch from 58b1b13 to 0226a14 Compare March 14, 2024 10:26
Copy link
Contributor Author

@rablador rablador left a comment

Choose a reason for hiding this comment

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

Dismissed @buggmagnet from a discussion.
Reviewable status: 20 of 25 files reviewed, 8 unresolved discussions (waiting on @buggmagnet and @mojganii)


ios/MullvadTypes/RelayConstraints.swift line 32 at r3 (raw file):

Previously, buggmagnet wrote…

As it stands right now, if the user updates their application whilst being connected, it will force them into blocked mode because their currently selected relay constraints will not match anymore.

Can we prevent this from happening ?

I'll do a migration for it.


ios/MullvadVPN/Coordinators/LocationCoordinator.swift line 147 at r1 (raw file):

Previously, buggmagnet wrote…

Nevermind, I think I misread the original code

Ok, no change then.


ios/MullvadVPN/Coordinators/LocationCoordinator.swift line 45 at r3 (raw file):

Previously, buggmagnet wrote…

We probably want to remove this

Done.


ios/MullvadVPN/Coordinators/CustomLists/ListCustomListCoordinator.swift line 48 at r3 (raw file):

Previously, buggmagnet wrote…

Let's remove this too

Done.


ios/MullvadVPN.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved line 22 at r3 (raw file):

Previously, buggmagnet wrote…

This comes from Xcode 15.3 which we do not use yet in the CI, please revert this file with the following command
git checkout main -- MullvadVPN.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/

Done.

Copy link
Contributor Author

@rablador rablador left a comment

Choose a reason for hiding this comment

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

Reviewable status: 20 of 25 files reviewed, 9 unresolved discussions (waiting on @buggmagnet and @mojganii)


ios/MullvadTypes/RelayLocation.swift line 134 at r4 (raw file):

}

/// - Warning: Deprecated, use UserSelectedRelays instead.

Opting not to use @available(*, deprecated) here since it will forever give us a deprecation warning when migrating from RelayLocations to UserSelectedLocations in RelayConstraints.

@rablador rablador force-pushed the create-view-with-custom-lists-to-edit-ios-542 branch from 0226a14 to 06b029f Compare March 14, 2024 10:49
Copy link
Contributor

@buggmagnet buggmagnet left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 5 of 5 files at r4, all commit messages.
Reviewable status: all files reviewed, 5 unresolved discussions (waiting on @mojganii)

@rablador rablador force-pushed the create-view-with-custom-lists-to-edit-ios-542 branch from 06b029f to fb75ef3 Compare March 14, 2024 13:10
Copy link
Contributor

@buggmagnet buggmagnet left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 2 of 2 files at r5, all commit messages.
Reviewable status: all files reviewed, 5 unresolved discussions (waiting on @mojganii)

@rablador rablador force-pushed the create-view-with-custom-lists-to-edit-ios-542 branch from fb75ef3 to d7a0e27 Compare March 14, 2024 13:35
Copy link
Collaborator

@mojganii mojganii left a comment

Choose a reason for hiding this comment

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

when I delete a custom list which is selected as an active RelayConstarints the app doesn't go to block state.

Reviewable status: 24 of 26 files reviewed, 5 unresolved discussions (waiting on @buggmagnet)

@rablador rablador force-pushed the create-view-with-custom-lists-to-edit-ios-542 branch 2 times, most recently from f237367 to ee921d1 Compare March 14, 2024 14:32
Copy link
Contributor Author

@rablador rablador left a comment

Choose a reason for hiding this comment

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

Have you tested on device? It doesn't work on simulator.

Reviewable status: 24 of 26 files reviewed, 5 unresolved discussions (waiting on @buggmagnet and @mojganii)

@rablador rablador force-pushed the create-view-with-custom-lists-to-edit-ios-542 branch from ee921d1 to 5bfae16 Compare March 14, 2024 14:45
@rablador rablador force-pushed the create-view-with-custom-lists-to-edit-ios-542 branch from 5bfae16 to 2d8ad57 Compare March 14, 2024 14:54
Copy link
Contributor

@buggmagnet buggmagnet left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 4 of 4 files at r7, all commit messages.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @mojganii)

Copy link
Collaborator

@mojganii mojganii left a comment

Choose a reason for hiding this comment

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

In the real device it goes on blocked state.

Reviewable status: all files reviewed, 4 unresolved discussions

@buggmagnet buggmagnet merged commit b4c2b25 into main Mar 15, 2024
6 of 7 checks passed
@buggmagnet buggmagnet deleted the create-view-with-custom-lists-to-edit-ios-542 branch March 15, 2024 12:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
iOS Issues related to iOS
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants