@@ -2,6 +2,14 @@ import axios, { type AxiosResponse } from "axios";
22import Constants from "./constants" ;
33import { ALL } from "@/config/constants" ;
44
5+ function validateAlbumId ( album_id : string | undefined ) : boolean {
6+ if ( album_id === undefined || album_id === ALL ) {
7+ return false ;
8+ }
9+ // We check if the length of album_id is 24 characters, that excldes all the smarts albums
10+ return album_id . length === 24 ;
11+ }
12+
513const MetricsService = {
614 get ( ) : Promise < AxiosResponse < App . Http . Resources . Models . LiveMetricsResource [ ] > > {
715 return axios . get ( `${ Constants . getApiUrl ( ) } Metrics` , { data : { } } ) ;
@@ -13,17 +21,15 @@ const MetricsService = {
1321 // Do not send a request if no photo_id is provided, otherwise it breaks in front-end.
1422 return Promise . resolve ( null ) ;
1523 }
16- // This is the case if we are in global search mode.
17- if ( album_id === undefined || album_id === ALL ) {
24+ if ( validateAlbumId ( album_id ) ) {
1825 return Promise . resolve ( null ) ;
1926 }
2027
2128 return axios . post ( `${ Constants . getApiUrl ( ) } Metrics::photo` , { photo_ids : [ photo_id ] , from_id : album_id } ) ;
2229 } ,
2330
2431 favourite ( photo_id : string , album_id : string | undefined ) : Promise < AxiosResponse < null > | null > {
25- // This is the case if we are in global search mode.
26- if ( album_id === undefined || album_id === ALL ) {
32+ if ( validateAlbumId ( album_id ) ) {
2733 return Promise . resolve ( null ) ;
2834 }
2935
0 commit comments