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

Apply filtering on custom lists #5980

Merged
merged 1 commit into from
Mar 28, 2024

Conversation

mojganii
Copy link
Collaborator

@mojganii mojganii commented Mar 19, 2024

When a filter is applied, the custom lists should only display items that match the specified constraints. Any items that do not meet these constraints should be excluded from the list.


This change is Reviewable

@mojganii mojganii added bug iOS Issues related to iOS labels Mar 19, 2024
@mojganii mojganii requested review from rablador and buggmagnet March 19, 2024 15:37
@mojganii mojganii self-assigned this Mar 19, 2024
Copy link

linear bot commented Mar 19, 2024

Copy link
Contributor

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

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


ios/MullvadVPN/View controllers/SelectLocation/CustomListsDataSource.swift line 28 at r1 (raw file):

    /// Constructs a collection of node trees by copying each matching counterpart
    /// from the complete list of nodes created in ``AllLocationDataSource``.
    func reload(allLocationNodes: [LocationNode], isFiltered: Bool) {

Nit: This change can be made much smaller by changing the original code from ...fetchAll().map to ...fetchAll().compactMap and ... (see below)


ios/MullvadVPN/View controllers/SelectLocation/CustomListsDataSource.swift line 51 at r1 (raw file):

            }

            // Indicates if the relays are filtered by ``Ownership`` or ``Provider``, node should be added while it has children

... and:

if isFiltered && listNode.children.isEmpty {
    return nil
} else {
     return listNode
}

Copy link
Contributor

@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: all files reviewed, 1 unresolved discussion (waiting on @mojganii)


ios/MullvadVPN/View controllers/SelectLocation/CustomListsDataSource.swift line 28 at r1 (raw file):

Previously, rablador (Jon Petersson) wrote…

Nit: This change can be made much smaller by changing the original code from ...fetchAll().map to ...fetchAll().compactMap and ... (see below)

Nit: This change can be made much smaller by changing the original code to use a compactMap instead.

Code snippet:

      nodes = repository.fetchAll().compactMap { list in
            
            [...]

            // Indicates if the relays are filtered by ``Ownership`` or ``Provider``, node should be added while it has children
            if isFiltered && listNode.children.isEmpty {
                return nil
            } else {
                return listNode
            }
        }

Copy link
Contributor

@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: all files reviewed, 1 unresolved discussion (waiting on @mojganii)


ios/MullvadVPN/View controllers/SelectLocation/CustomListsDataSource.swift line 28 at r1 (raw file):

    /// Constructs a collection of node trees by copying each matching counterpart
    /// from the complete list of nodes created in ``AllLocationDataSource``.
    func reload(allLocationNodes: [LocationNode], isFiltered: Bool) {

Nit: This change can be made much smaller by changing the original code to use a compactMap instead.

Code snippet:

nodes = repository.fetchAll().compactMap { list in
    [...]
    
    // Indicates if the relays are filtered by ``Ownership`` or ``Provider``, node should be added while it has children
    if isFiltered && listNode.children.isEmpty {
        return nil
    } else {
        return listNode
    }
}

Copy link
Contributor

@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: all files reviewed, 1 unresolved discussion (waiting on @mojganii)

@mojganii mojganii force-pushed the apply-relay-filters-to-custom-lists-ios-564 branch from b248cb3 to c426ab9 Compare March 22, 2024 12:51
Copy link
Collaborator Author

@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: 1 of 3 files reviewed, 1 unresolved discussion (waiting on @rablador)


ios/MullvadVPN/View controllers/SelectLocation/CustomListsDataSource.swift line 28 at r1 (raw file):

Previously, rablador (Jon Petersson) wrote…

Nit: This change can be made much smaller by changing the original code to use a compactMap instead.

Considered


ios/MullvadVPN/View controllers/SelectLocation/CustomListsDataSource.swift line 51 at r1 (raw file):

Previously, rablador (Jon Petersson) wrote…

... and:

if isFiltered && listNode.children.isEmpty {
    return nil
} else {
     return listNode
}

Indeed.

@mojganii mojganii requested a review from rablador March 22, 2024 12:54
Copy link
Contributor

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

Reviewed 2 of 2 files at r2, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved

@rablador rablador force-pushed the apply-relay-filters-to-custom-lists-ios-564 branch 2 times, most recently from 49aefbe to 6ca1714 Compare March 25, 2024 14:24
Copy link
Contributor

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

Reviewed 1 of 1 files at r3, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved

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 1 of 3 files at r1, 1 of 2 files at r2, 1 of 1 files at r3, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved

@buggmagnet buggmagnet force-pushed the apply-relay-filters-to-custom-lists-ios-564 branch from 6ca1714 to e108acb Compare March 28, 2024 12:16
@buggmagnet buggmagnet merged commit 679d6d1 into main Mar 28, 2024
7 checks passed
@buggmagnet buggmagnet deleted the apply-relay-filters-to-custom-lists-ios-564 branch March 28, 2024 12:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug iOS Issues related to iOS
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants