Skip to content

Commit

Permalink
convert initial date range into a constant
Browse files Browse the repository at this point in the history
  • Loading branch information
aswallace committed Feb 21, 2024
1 parent 1d147c1 commit 61b6d61
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
6 changes: 6 additions & 0 deletions packages/core/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@ 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({
Expand Down
8 changes: 2 additions & 6 deletions packages/core/state/selection/reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { makeReducer } from "@aics/redux-utils";
import { castArray, difference, omit, without } from "lodash";

import interaction from "../interaction";
import { AnnotationName, RELATIVE_DATE_RANGES } from "../../constants";
import { AnnotationName, INITIAL_DATE_FILTER } from "../../constants";
import Annotation from "../../entity/Annotation";
import FileFilter from "../../entity/FileFilter";
import FileFolder from "../../entity/FileFolder";
Expand Down Expand Up @@ -46,10 +46,6 @@ export interface SelectionStateBranch {
tutorial?: Tutorial;
}

const initialDateFilter = RELATIVE_DATE_RANGES.filter((relativeDateRange) =>
relativeDateRange.name.toLowerCase().includes("last year")
)[0].filters;

export const initialState = {
annotationHierarchy: [],
availableAnnotationsForHierarchy: [],
Expand All @@ -62,7 +58,7 @@ export const initialState = {
},
displayAnnotations: [],
fileSelection: new FileSelection(),
filters: [...initialDateFilter],
filters: [...INITIAL_DATE_FILTER],
openFileFolders: [],
shouldDisplaySmallFont: false,
sortColumn: new FileSort(AnnotationName.UPLOADED, SortOrder.DESC),
Expand Down

0 comments on commit 61b6d61

Please sign in to comment.