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

The filter is not applied when changing the original collection #49

Open
gserrg opened this issue Mar 23, 2020 · 2 comments
Open

The filter is not applied when changing the original collection #49

gserrg opened this issue Mar 23, 2020 · 2 comments
Labels
bug Something isn't working

Comments

@gserrg
Copy link

gserrg commented Mar 23, 2020

If we stay inin the “Photos with objects” filtering mode, and then start processing the next batch of photos, then upon completion this list is not updated, you need to manually enable the display of all photos and then return to the filter.

In short, the filter is not automatically applied when updating the original image collection. In order for the filter to be updated, you need to call it explicitly.

@gserrg gserrg changed the title Сброс выбранной фотографии в списке изображений Нужно проработать режим открытия новой папки с изображениями Mar 23, 2020
@gosha20777 gosha20777 changed the title Нужно проработать режим открытия новой папки с изображениями The filter is not applied when changing the original collection Mar 24, 2020
@gosha20777 gosha20777 added the bug Something isn't working label Mar 24, 2020
@gosha20777
Copy link
Contributor

This is because ReactiveUI Dynamic.Data is able to handle filter changes only when the target property that sets the filter changes. But the filter does not track collection changes.

Look at example here:

SourceList<PhotoViewModel> _photos { get; set; } = new SourceList<PhotoViewModel>();
private ReadOnlyObservableCollection<PhotoViewModel> _photoCollection;
...
public MainWindowViewModel(Window window)
{
    ...
    var typeFilter = this
                .WhenValueChanged(x => x.FilterType)
                .Select(TypeFilter);
    _photos.Connect()
                .Filter(typeFilter)
                .ObserveOn(RxApp.MainThreadScheduler)
                .Bind(out _photoCollection)
                .DisposeMany()
                .Subscribe();
    ...
}
...

private Func<PhotoViewModel, bool> TypeFilter(int fitlerType)
 {
    switch (fitlerType)
    {
        case Any:
            return x => true;
        case WithObject:
            return x => x.Photo.Attribute == Attribute.WithObject;
        case Favorite:
            return x => x.Photo.Attribute == Attribute.Favorite;
        default:
            throw new Exception("invalid filter");
    }
}

So i really do not know how to make it update filter when the _photos source list changed. @worldbeater may be you knows?

@gosha20777
Copy link
Contributor

@gserrg I am find a temporary solution -) I simply can add button with 🔄 same sign "update" in the left of filter. and you can click in it to update the collection)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants