Following changes have been made in filterFunction() :
If the filter field of a user is a JSON array (when user doesn't signup, the filter array is, by default a JSON array) , then firstly, it is tried to parse it to an array, otherwise if it is an array, we take it directly. If it is a string but not in JSON format, then an array of length 1 is created out of it.
If the filter field of a slide is an array, we try to filter the slides which have at least one filter in common with the user filters, otherwise if it is a single string we search the filter in the user filter.
Motivation and Context
Earlier, whenever user created an account using the signup.html page, the filters were stored as JSON array, but in the filterFunction it was not parsed to an array, but directly converted to an array of length 1 always.
Like, suppose I created a user with filters ['secret' , 'super-secret'] , it would be saved as "['secret' , 'super-secret']" and in filterFunction, this was converted to an array that contains only this single string. (But it should have 2 elements 'secret' and 'super-secret', ideally)
This also allows multiple filters for a slide, required for #camicroscope/caMicroscope/pull/391 , to fix #camicroscope/caMicroscope/issues/386
How Has This Been Tested?
This has been tested along with #camicroscope/caMicroscope/pull/391 , creating various types of users, with various filters.
Types of changes
**What types of changes does your code introduce? Put an x in all the boxes that apply:
[x] Bug fix (non-breaking change which fixes an issue)
[x] New feature (non-breaking change which adds functionality)
[ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
Checklist:
[x] My code follows the code style of this project.
[ ] My change requires a change to the documentation.
Description
Following changes have been made in filterFunction() :
If the
filter
field of a user is a JSON array (when user doesn't signup, the filter array is, by default a JSON array) , then firstly, it is tried to parse it to an array, otherwise if it is an array, we take it directly. If it is a string but not in JSON format, then an array of length 1 is created out of it.If the
filter
field of a slide is an array, we try to filter the slides which have at least one filter in common with the user filters, otherwise if it is a single string we search the filter in the user filter.Motivation and Context
Earlier, whenever user created an account using the
signup.html
page, the filters were stored as JSON array, but in the filterFunction it was not parsed to an array, but directly converted to an array of length 1 always. Like, suppose I created a user with filters['secret' , 'super-secret']
, it would be saved as"['secret' , 'super-secret']"
and in filterFunction, this was converted to an array that contains only this single string. (But it should have 2 elements 'secret' and 'super-secret', ideally)This also allows multiple filters for a slide, required for #camicroscope/caMicroscope/pull/391 , to fix #camicroscope/caMicroscope/issues/386
How Has This Been Tested?
Types of changes
**What types of changes does your code introduce? Put an
x
in all the boxes that apply:Checklist: