Skip to content

Commit

Permalink
Fix timeline "new year" bug (#1412)
Browse files Browse the repository at this point in the history
Co-authored-by: Amit Wadhwa <awadhwa@gmail.com>
  • Loading branch information
ericboucher and wadhwamatic authored Jan 16, 2025
1 parent e85b377 commit 3ad6e08
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ jobs:

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install Poetry
uses: snok/install-poetry@v1
with:
Expand Down
11 changes: 6 additions & 5 deletions frontend/src/components/MapView/DateSelector/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,9 @@ const DateSelector = memo(() => {
if (firstIndex === -1) {
return layer.dateItems;
}
// truncate the date item array at index matching timeline first date
// truncate the date item array at index matching timeline first date with a buffer of 1 day decrements
// eslint-disable-next-line fp/no-mutating-methods
return layer.dateItems.slice(firstIndex);
return layer.dateItems.slice(firstIndex - 1);
}),
];
}, [orderedLayers, timelineStartDate]);
Expand Down Expand Up @@ -365,13 +365,13 @@ const DateSelector = memo(() => {
return;
}
const time = date.getTime();
const selectedIndex = findDateIndex(selectableDates, date.getTime());
const selectedIndex = findDateIndex(availableDates, date.getTime());
checkSelectedDateForLayerSupport(date.getTime());
if (
selectedIndex < 0 ||
(stateStartDate &&
datesAreEqualWithoutTime(
selectableDates[selectedIndex],
availableDates[selectedIndex],
stateStartDate,
))
) {
Expand All @@ -381,7 +381,7 @@ const DateSelector = memo(() => {
dispatch(updateDateRange({ startDate: time }));
},
[
selectableDates,
availableDates,
checkSelectedDateForLayerSupport,
stateStartDate,
updateHistory,
Expand All @@ -396,6 +396,7 @@ const DateSelector = memo(() => {
isUpdatingHistory: boolean,
) => {
const selectedIndex = findDateIndex(availableDates, date);

if (availableDates[selectedIndex + increment]) {
updateStartDate(
new Date(availableDates[selectedIndex + increment]),
Expand Down

0 comments on commit 3ad6e08

Please sign in to comment.