Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export class MonthGroup {
this.#initialCount = initialCount;
this.#sortOrder = order;

this.yearMonth = yearMonth;
this.yearMonth = { year: yearMonth.year, month: yearMonth.month };
this.monthGroupTitle = formatMonthGroupTitle(fromTimelinePlainYearMonth(yearMonth));

this.loader = new CancellableTask(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,29 @@ describe('TimelineManager', () => {
expect(getMonthGroupByDate(timelineManager, { year: 2024, month: 3 })).not.toBeUndefined();
expect(getMonthGroupByDate(timelineManager, { year: 2024, month: 3 })?.getAssets().length).toEqual(1);
});

it('yearMonth is not a shared reference with asset.localDateTime (reference bug)', () => {
const asset = deriveLocalDateTimeFromFileCreatedAt(
timelineAssetFactory.build({
fileCreatedAt: fromISODateTimeUTCToObject('2024-01-20T12:00:00.000Z'),
}),
);

timelineManager.upsertAssets([asset]);
const januaryMonth = getMonthGroupByDate(timelineManager, { year: 2024, month: 1 })!;
const monthYearMonth = januaryMonth.yearMonth;

const originalMonth = monthYearMonth.month;
expect(originalMonth).toEqual(1);

// Simulating updateObject
asset.localDateTime.month = 3;
asset.localDateTime.day = 20;

expect(monthYearMonth.month).toEqual(originalMonth);
expect(monthYearMonth.month).toEqual(1);
});

it('asset is removed during upsert when TimelineManager if visibility changes', async () => {
await timelineManager.updateOptions({
visibility: AssetVisibility.Archive,
Expand Down
Loading