Skip to content
Closed
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feel free to use 1.2.2 here already.

As an fyi:
We are mainly developing on the releases/2.0.0 branch at the moment (latest docker tag).
Since this is a minor fix tho let's include it in the stable version based on main too. I gona rebase or merge the changes into the release branch once they hit main 👍


### Fixed

- Normalize artist timestamp parsing in the frontend New additions view to correctly handle seconds/milliseconds and ignore invalid values. [#289](https://github.com/pSpitzner/beets-flask/issues/289)

## [1.2.1] - 25-12-28

### Fixed
Expand Down
6 changes: 3 additions & 3 deletions backend/beets_flask/importer/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,10 +271,10 @@ def get_config_value(self, key: str, type_func: Callable | None = None) -> Any:
# get settings from user settings, this is not a dict, but confuse config
# the confuse config views do not throw key errors, and their .get() is not
# the same as dict.get(), but rather resolves the value.
default = get_config()
config_view = get_config()
for p in path:
default = default[p]
default = default.get(type_func) if type_func else default.get()
config_view = config_view[p]
default = config_view.get(type_func) if type_func else config_view.get()
return default

# -------------------------- State handling helpers -------------------------- #
Expand Down
18 changes: 5 additions & 13 deletions frontend/src/api/library.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { infiniteQueryOptions, queryOptions } from '@tanstack/react-query';

import { toHex } from '@/components/common/strings';
import { parseApiDate } from '@/components/common/units/time';
import {
AlbumResponse,
AlbumResponseExpanded,
Expand Down Expand Up @@ -272,19 +273,10 @@ export const artistsQueryOptions = () => ({

for (let i = 0; i < artists.length; i++) {
const artist = artists[i];
// Convert timestamps to Date objects
if (artist.last_item_added) {
artist.last_item_added = new Date(artist.last_item_added);
}
if (artist.last_album_added) {
artist.last_album_added = new Date(artist.last_album_added);
}
if (artist.first_item_added) {
artist.first_item_added = new Date(artist.first_item_added);
}
if (artist.first_album_added) {
artist.first_album_added = new Date(artist.first_album_added);
}
artist.last_item_added = parseApiDate(artist.last_item_added);
artist.last_album_added = parseApiDate(artist.last_album_added);
artist.first_item_added = parseApiDate(artist.first_item_added);
artist.first_album_added = parseApiDate(artist.first_album_added);
}
return artists;
// TODO: fill cache data for single artists queries
Expand Down
21 changes: 21 additions & 0 deletions frontend/src/components/common/units/time.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
export const parseApiDate = (value: unknown): Date | undefined => {
if (value === null || value === undefined) {
return undefined;
}

const numeric = typeof value === 'number' ? value : Number(value);
if (!Number.isNaN(numeric)) {
// Some API responses provide UNIX seconds while others use milliseconds.
Copy link
Copy Markdown
Collaborator

@semohr semohr Mar 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know which endpoints return UNIX seconds and which return milliseconds? It might be cleaner to fix this inconsistency in the backend instead of a workaround in the frontend.

const timestamp = numeric < 1e12 ? numeric * 1000 : numeric;
const date = new Date(timestamp);
return Number.isNaN(date.getTime()) ? undefined : date;
}

if (typeof value === 'string') {
const date = new Date(value);
return Number.isNaN(date.getTime()) ? undefined : date;
}

return undefined;
};

export const relativeTime = (date?: Date | null) => {
if (!date) return 'never';

Expand Down
Loading