From 15f3dbbb87ecdfe6459c1c3fc69d817be524a38e Mon Sep 17 00:00:00 2001 From: Anya Wallace Date: Thu, 22 Feb 2024 11:22:45 -0800 Subject: [PATCH] update past year filter constant --- packages/core/constants/index.ts | 17 +++++------------ packages/core/state/selection/reducer.ts | 4 ++-- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/packages/core/constants/index.ts b/packages/core/constants/index.ts index 9a1442e6b..e875bd763 100644 --- a/packages/core/constants/index.ts +++ b/packages/core/constants/index.ts @@ -38,17 +38,16 @@ const DATE_LAST_MONTH = new Date(BEGINNING_OF_TODAY); DATE_LAST_MONTH.setMonth(BEGINNING_OF_TODAY.getMonth() - 1); const DATE_LAST_WEEK = new Date(BEGINNING_OF_TODAY); DATE_LAST_WEEK.setDate(BEGINNING_OF_TODAY.getDate() - 7); +export const PAST_YEAR_FILTER = new FileFilter( + AnnotationName.UPLOADED, + `RANGE(${DATE_LAST_YEAR.toISOString()},${END_OF_TODAY.toISOString()})` +); export const RELATIVE_DATE_RANGES = [ { name: "Uploaded in last year", description: "This will automatically filter files down to those uploaded within the last year", - filters: [ - new FileFilter( - AnnotationName.UPLOADED, - `RANGE(${DATE_LAST_YEAR.toISOString()},${END_OF_TODAY.toISOString()})` - ), - ], + filters: [PAST_YEAR_FILTER], hierarchy: undefined, sort: undefined, }, @@ -106,12 +105,6 @@ export const RELATIVE_DATE_RANGES = [ sort: undefined, }, ]; -export const INITIAL_DATE_FILTER = [ - new FileFilter( - AnnotationName.UPLOADED, - `RANGE(${DATE_LAST_YEAR.toISOString()},${END_OF_TODAY.toISOString()})` - ), -]; export const TOP_LEVEL_FILE_ANNOTATIONS = [ new Annotation({ diff --git a/packages/core/state/selection/reducer.ts b/packages/core/state/selection/reducer.ts index e885eb595..0148d01a2 100644 --- a/packages/core/state/selection/reducer.ts +++ b/packages/core/state/selection/reducer.ts @@ -2,7 +2,7 @@ import { makeReducer } from "@aics/redux-utils"; import { castArray, difference, omit, without } from "lodash"; import interaction from "../interaction"; -import { AnnotationName, INITIAL_DATE_FILTER } from "../../constants"; +import { AnnotationName, PAST_YEAR_FILTER } from "../../constants"; import Annotation from "../../entity/Annotation"; import FileFilter from "../../entity/FileFilter"; import FileFolder from "../../entity/FileFolder"; @@ -58,7 +58,7 @@ export const initialState = { }, displayAnnotations: [], fileSelection: new FileSelection(), - filters: [...INITIAL_DATE_FILTER], + filters: [PAST_YEAR_FILTER], openFileFolders: [], shouldDisplaySmallFont: false, sortColumn: new FileSort(AnnotationName.UPLOADED, SortOrder.DESC),