mirror of
https://github.com/johrpan/musicus_mobile.git
synced 2025-10-25 19:27:24 +02:00
mobile: Fix handling of works without sections
This commit is contained in:
parent
3af7c23bbc
commit
0ccebb2217
3 changed files with 11 additions and 6 deletions
|
|
@ -341,8 +341,10 @@ class _PlaybackService extends BackgroundAudioTask {
|
|||
if (partIds.isNotEmpty) {
|
||||
subtitleBuffer.write(': ');
|
||||
|
||||
final section =
|
||||
workInfo.sections.lastWhere((s) => s.beforePartIndex <= partIds[0]);
|
||||
final section = workInfo.sections.lastWhere(
|
||||
(s) => s.beforePartIndex <= partIds[0],
|
||||
orElse: () => null,
|
||||
);
|
||||
|
||||
if (section != null) {
|
||||
subtitleBuffer.write(section.title);
|
||||
|
|
|
|||
|
|
@ -100,6 +100,7 @@ class _ProgramScreenState extends State<ProgramScreen> {
|
|||
if (recordingInfo.recording.work != lastWorkId) {
|
||||
lastWorkId = recordingInfo.recording.work;
|
||||
workInfo = await backend.db.getWork(lastWorkId);
|
||||
lastSectionIndex = null;
|
||||
}
|
||||
|
||||
children.addAll([
|
||||
|
|
@ -118,7 +119,7 @@ class _ProgramScreenState extends State<ProgramScreen> {
|
|||
|
||||
final sectionIndex = workInfo.sections
|
||||
.lastIndexWhere((s) => s.beforePartIndex <= partId);
|
||||
if (sectionIndex != lastSectionIndex) {
|
||||
if (sectionIndex != lastSectionIndex && sectionIndex >= 0) {
|
||||
lastSectionIndex = sectionIndex;
|
||||
children.add(Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
|
|
|
|||
|
|
@ -62,9 +62,11 @@ class _PlayerBarState extends State<PlayerBar> {
|
|||
if (_partIds.isNotEmpty) {
|
||||
subtitleBuffer.write(': ');
|
||||
|
||||
final section = _workInfo.sections
|
||||
.lastWhere((s) => s.beforePartIndex <= _partIds[0]);
|
||||
|
||||
final section = _workInfo.sections.lastWhere(
|
||||
(s) => s.beforePartIndex <= _partIds[0],
|
||||
orElse: () => null,
|
||||
);
|
||||
|
||||
if (section != null) {
|
||||
subtitleBuffer.write(section.title);
|
||||
subtitleBuffer.write(': ');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue