detail: band-aid crashes when library unavailable
Band-aid a crash that would occur when the library is somehow unavailable in the detail view. Now, if it's unavailable, the app simple navigates away. Not sure how this is happening, but I'd imagine it's some caching shenanigans I need to fix by using volatile on any shared field.
This commit is contained in:
@@ -183,7 +183,7 @@ class DetailViewModel(application: Application) :
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
logD("Opening Song [uid: $uid]")
|
logD("Opening Song [uid: $uid]")
|
||||||
_currentSong.value = requireMusic<Song>(uid).also(::loadProperties)
|
_currentSong.value = requireMusic<Song>(uid)?.also(::loadProperties)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -197,7 +197,7 @@ class DetailViewModel(application: Application) :
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
logD("Opening Album [uid: $uid]")
|
logD("Opening Album [uid: $uid]")
|
||||||
_currentAlbum.value = requireMusic<Album>(uid).also(::refreshAlbumList)
|
_currentAlbum.value = requireMusic<Album>(uid)?.also(::refreshAlbumList)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -211,7 +211,7 @@ class DetailViewModel(application: Application) :
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
logD("Opening Artist [uid: $uid]")
|
logD("Opening Artist [uid: $uid]")
|
||||||
_currentArtist.value = requireMusic<Artist>(uid).also(::refreshArtistList)
|
_currentArtist.value = requireMusic<Artist>(uid)?.also(::refreshArtistList)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -225,11 +225,10 @@ class DetailViewModel(application: Application) :
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
logD("Opening Genre [uid: $uid]")
|
logD("Opening Genre [uid: $uid]")
|
||||||
_currentGenre.value = requireMusic<Genre>(uid).also(::refreshGenreList)
|
_currentGenre.value = requireMusic<Genre>(uid)?.also(::refreshGenreList)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun <T : Music> requireMusic(uid: Music.UID): T =
|
private fun <T : Music> requireMusic(uid: Music.UID) = musicStore.library?.find<T>(uid)
|
||||||
requireNotNull(unlikelyToBeNull(musicStore.library).find(uid)) { "Invalid id provided" }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start a new job to load a [DetailSong] based on the properties of the given [Song]'s file.
|
* Start a new job to load a [DetailSong] based on the properties of the given [Song]'s file.
|
||||||
|
|||||||
@@ -30,6 +30,8 @@ import org.oxycblt.auxio.music.filesystem.useQuery
|
|||||||
* generally recommended to use this over Indexer to keep track of the library state, as the
|
* generally recommended to use this over Indexer to keep track of the library state, as the
|
||||||
* interface will be less volatile.
|
* interface will be less volatile.
|
||||||
*
|
*
|
||||||
|
* TODO: Use volatile on individual fields
|
||||||
|
*
|
||||||
* @author Alexander Capehart (OxygenCobalt)
|
* @author Alexander Capehart (OxygenCobalt)
|
||||||
*/
|
*/
|
||||||
class MusicStore private constructor() {
|
class MusicStore private constructor() {
|
||||||
|
|||||||
Reference in New Issue
Block a user