Skip to content

Commit

Permalink
🐛 Max search item length (#210)
Browse files Browse the repository at this point in the history
  • Loading branch information
manuel-rw authored Aug 6, 2023
1 parent 996a1d0 commit ad14c2c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
7 changes: 6 additions & 1 deletion src/models/search/AlbumSearchHint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Track } from '../shared/Track';
import { JellyfinSearchService } from '../../clients/jellyfin/jellyfin.search.service';

import { SearchHint } from './SearchHint';
import { trimStringToFixedLength } from 'src/utils/stringUtils/stringUtils';

export class AlbumSearchHint extends SearchHint {
override toString(): string {
Expand All @@ -17,7 +18,11 @@ export class AlbumSearchHint extends SearchHint {
);
}

return new AlbumSearchHint(hint.Id, hint.Name, hint.RunTimeTicks / 10000);
return new AlbumSearchHint(
hint.Id,
trimStringToFixedLength(hint.Name, 50),
hint.RunTimeTicks / 10000,
);
}

override async toTracks(
Expand Down
3 changes: 2 additions & 1 deletion src/models/search/PlaylistSearchHint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { JellyfinSearchService } from '../../clients/jellyfin/jellyfin.search.se

import { SearchHint } from './SearchHint';
import { convertToTracks } from 'src/utils/trackConverter';
import { trimStringToFixedLength } from 'src/utils/stringUtils/stringUtils';

export class PlaylistSearchHint extends SearchHint {
override toString(): string {
Expand All @@ -20,7 +21,7 @@ export class PlaylistSearchHint extends SearchHint {

return new PlaylistSearchHint(
hint.Id,
hint.Name,
trimStringToFixedLength(hint.Name, 50),
hint.RunTimeTicks / 10000,
);
}
Expand Down
5 changes: 3 additions & 2 deletions src/models/search/SearchHint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { z } from 'zod';

import { JellyfinSearchService } from '../../clients/jellyfin/jellyfin.search.service';
import { Track } from '../shared/Track';
import { trimStringToFixedLength } from 'src/utils/stringUtils/stringUtils';

export class SearchHint {
constructor(
Expand Down Expand Up @@ -45,7 +46,7 @@ export class SearchHint {

return new SearchHint(
result.data.Id,
result.data.Name,
trimStringToFixedLength(result.data.Name, 50),
result.data.RunTimeTicks / 10000,
);
}
Expand All @@ -58,7 +59,7 @@ export class SearchHint {
}
return new SearchHint(
baseItem.Id,
baseItem.Name,
trimStringToFixedLength(baseItem.Name, 50),
baseItem.RunTimeTicks / 10000,
);
}
Expand Down

0 comments on commit ad14c2c

Please sign in to comment.