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

Search filter: enable "online in the past 6 months" by default #1434

Merged
merged 1 commit into from May 4, 2020

Conversation

simison
Copy link
Contributor

@simison simison commented Apr 29, 2020

As @rumwerfer noted in #1381 (comment), "online within the last 6 months" toggle in map search wasn't on by default.

This makes 6 months default and requires people to toggle it off to get users from the past 24 months. Anyone not logged longer than that won't be visible on the map no matter how the toggle is set.

Proposed Changes

  • Enable "online in the past 6 months" by default

Testing Instructions

  • Open map search and filters panel
  • You can either open in an incognito window to ensure you don't have filter settings in local storage saved, or you can manually delete "trustroots.search.filters" entry as seen in 2nd screenshot. Go to the "Application" tab and to "Local Storage".

Screenshot 2020-04-29 at 09 14 30

Screenshot 2020-04-29 at 09 14 50

By default, the toggle is on. You can also ensure from networks tab that correct "seen" value is sent (24 when the toggle is disabled, 6 months when enabled):

image

@sitarane
Copy link
Contributor

Hey, I don't see how this:

Screenshot from 2020-04-29 23-35-11

Achieves what we want here.

Pass test on Firefox and Chrome, but I'm not sure where to look for the code changes.

@nicksellen
Copy link
Contributor

I agree with @sitarane - it looks like you forgot to commit a change?

@simison
Copy link
Contributor Author

simison commented May 4, 2020

No that's all we need. :-) The existing toggle just switches between 6 and 24 months. It's not possible to have "show everyone past 24 months". Now that 6 months is the default, we could extend the 24 to something longer that we think is still reasonable, or set it to "infinite".

Default filters are returned when no filters are saved in localStorage:

// Look up for filters from cache.
// Returns `defaultFilters` if nothing is found.
let filters = locker.supported()
? locker.get(cachePrefix, defaultFilters)
: defaultFilters;

Here's the toggle which is now on by default since it sees 6 months vs 24 months as value:

<label tr-switch>
<input
type="checkbox"
ng-model="search.onlineInPast6Months"
ng-change="search.onSeenFilterChange()"
/>
Online in the past 6 months
</label>

function onSeenFilterChange() {
vm.filters.seen.months = vm.onlineInPast6Months ? 6 : 24;
// `vm.filters.seen` is still out of sync at this point,
// but in next cycle after `$timeout` we have updated version.
$timeout(function() {
// Save new value to cache
FiltersService.set('seen', vm.filters.seen);
onFiltersUpdated();
});
}

Without the change the filter defaults to 24 months.

Unless I'm missing something?

@nicksellen
Copy link
Contributor

OK, I see now :) Actually, I don't see how I didn't see before. Oh well, brains are a funny thing.

@simison
Copy link
Contributor Author

simison commented May 4, 2020

It's a little complicated bit of code just nature of Angular.js services, hope we can simplify it with React. :-)

@simison simison merged commit 7c74395 into master May 4, 2020
@simison simison deleted the update/filters-6-months branch May 4, 2020 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants