mirror of
https://github.com/Shabinder/SpotiFlyer.git
synced 2024-11-22 09:04:32 +01:00
Ui & TokenStore Fixes
This commit is contained in:
parent
bc6f91c7ef
commit
189441111b
@ -69,6 +69,10 @@ fun TrackCard(
|
|||||||
downloadTrack:()->Unit,
|
downloadTrack:()->Unit,
|
||||||
loadImage:suspend (String)-> ImageBitmap?
|
loadImage:suspend (String)-> ImageBitmap?
|
||||||
) {
|
) {
|
||||||
|
/*val status = remember { mutableStateOf(track.downloaded.name()) }
|
||||||
|
LaunchedEffect(track.downloaded.name()){
|
||||||
|
status.value = track.downloaded.name()
|
||||||
|
}*/
|
||||||
Row(verticalAlignment = Alignment.CenterVertically,modifier = Modifier.fillMaxWidth().padding(horizontal = 8.dp)) {
|
Row(verticalAlignment = Alignment.CenterVertically,modifier = Modifier.fillMaxWidth().padding(horizontal = 8.dp)) {
|
||||||
ImageLoad(
|
ImageLoad(
|
||||||
{loadImage(track.albumArtURL)},
|
{loadImage(track.albumArtURL)},
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package com.shabinder.common.list.store
|
package com.shabinder.common.list.store
|
||||||
|
|
||||||
import androidx.compose.runtime.mutableStateListOf
|
|
||||||
import androidx.compose.runtime.snapshots.SnapshotStateList
|
|
||||||
import com.arkivanov.mvikotlin.core.store.*
|
import com.arkivanov.mvikotlin.core.store.*
|
||||||
import com.arkivanov.mvikotlin.extensions.coroutines.SuspendExecutor
|
import com.arkivanov.mvikotlin.extensions.coroutines.SuspendExecutor
|
||||||
import com.shabinder.common.database.getLogger
|
import com.shabinder.common.database.getLogger
|
||||||
@ -16,9 +14,7 @@ import com.shabinder.common.models.PlatformQueryResult
|
|||||||
import com.shabinder.common.models.TrackDetails
|
import com.shabinder.common.models.TrackDetails
|
||||||
import com.shabinder.common.ui.showPopUpMessage
|
import com.shabinder.common.ui.showPopUpMessage
|
||||||
import kotlinx.coroutines.flow.MutableSharedFlow
|
import kotlinx.coroutines.flow.MutableSharedFlow
|
||||||
import kotlinx.coroutines.flow.StateFlow
|
|
||||||
import kotlinx.coroutines.flow.collectLatest
|
import kotlinx.coroutines.flow.collectLatest
|
||||||
import org.koin.ext.scope
|
|
||||||
|
|
||||||
internal class SpotiFlyerListStoreProvider(
|
internal class SpotiFlyerListStoreProvider(
|
||||||
private val dir: Dir,
|
private val dir: Dir,
|
||||||
@ -70,16 +66,15 @@ internal class SpotiFlyerListStoreProvider(
|
|||||||
else downloadTracks(finalList,fetchQuery.youtubeMusic::getYTIDBestMatch,dir::saveFileWithMetadata)
|
else downloadTracks(finalList,fetchQuery.youtubeMusic::getYTIDBestMatch,dir::saveFileWithMetadata)
|
||||||
|
|
||||||
val list = intent.trackList.map {
|
val list = intent.trackList.map {
|
||||||
if (it.downloaded == DownloadStatus.NotDownloaded) {
|
if (it.downloaded == DownloadStatus.NotDownloaded)
|
||||||
it.downloaded = DownloadStatus.Queued
|
return@map it.copy(downloaded = DownloadStatus.Queued)
|
||||||
}
|
|
||||||
it
|
it
|
||||||
}
|
}
|
||||||
dispatch(Result.UpdateTrackList(list.updateTracksStatuses(downloadProgressFlow.replayCache.getOrElse(0){ hashMapOf()})))
|
dispatch(Result.UpdateTrackList(list.updateTracksStatuses(downloadProgressFlow.replayCache.getOrElse(0){ hashMapOf()})))
|
||||||
}
|
}
|
||||||
is Intent.StartDownload -> {
|
is Intent.StartDownload -> {
|
||||||
downloadTracks(listOf(intent.track),fetchQuery.youtubeMusic::getYTIDBestMatch,dir::saveFileWithMetadata)
|
downloadTracks(listOf(intent.track),fetchQuery.youtubeMusic::getYTIDBestMatch,dir::saveFileWithMetadata)
|
||||||
dispatch(Result.UpdateTrackItem(intent.track.apply { downloaded = DownloadStatus.Queued }))
|
dispatch(Result.UpdateTrackItem(intent.track.copy(downloaded = DownloadStatus.Queued)))
|
||||||
}
|
}
|
||||||
is Intent.RefreshTracksStatuses -> queryActiveTracks()
|
is Intent.RefreshTracksStatuses -> queryActiveTracks()
|
||||||
}
|
}
|
||||||
@ -108,7 +103,7 @@ internal class SpotiFlyerListStoreProvider(
|
|||||||
for(newTrack in map){
|
for(newTrack in map){
|
||||||
titleList.indexOf(newTrack.key).let { position ->
|
titleList.indexOf(newTrack.key).let { position ->
|
||||||
if(position != -1){
|
if(position != -1){
|
||||||
updatedList.getOrNull(position)?.apply { downloaded = newTrack.value }?.also { updatedTrack ->
|
updatedList.getOrNull(position)?.copy(downloaded = newTrack.value)?.also { updatedTrack ->
|
||||||
updatedList[position] = updatedTrack
|
updatedList[position] = updatedTrack
|
||||||
logger.d("$position) ${updatedTrack.downloaded} - ${updatedTrack.title}","List Store Track Update")
|
logger.d("$position) ${updatedTrack.downloaded} - ${updatedTrack.title}","List Store Track Update")
|
||||||
}
|
}
|
||||||
|
@ -35,10 +35,9 @@ data class TrackDetails(
|
|||||||
var albumArtPath: String,
|
var albumArtPath: String,
|
||||||
var albumArtURL: String,
|
var albumArtURL: String,
|
||||||
var source: Source,
|
var source: Source,
|
||||||
var downloaded: DownloadStatus = DownloadStatus.NotDownloaded,
|
val downloaded: DownloadStatus = DownloadStatus.NotDownloaded,
|
||||||
var progress: Int = 2,//2 for visual progress bar hint
|
|
||||||
var outputFilePath: String,
|
var outputFilePath: String,
|
||||||
var videoID:String? = null
|
var videoID:String? = null,
|
||||||
):Parcelable
|
):Parcelable
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,16 +1,15 @@
|
|||||||
CREATE TABLE IF NOT EXISTS Token (
|
CREATE TABLE IF NOT EXISTS Token (
|
||||||
tokenIndex INTEGER NOT NULL DEFAULT 0 PRIMARY KEY ON CONFLICT REPLACE,
|
tokenIndex INTEGER NOT NULL PRIMARY KEY ON CONFLICT REPLACE,
|
||||||
accessToken TEXT NOT NULL,
|
accessToken TEXT NOT NULL,
|
||||||
expiry INTEGER NOT NULL
|
expiry INTEGER NOT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
add:
|
add:
|
||||||
INSERT OR REPLACE INTO Token (accessToken,expiry)
|
INSERT OR REPLACE INTO Token (tokenIndex,accessToken,expiry)
|
||||||
VALUES (?,?);
|
VALUES (0,?,?);
|
||||||
|
|
||||||
select:
|
select:
|
||||||
SELECT *
|
SELECT * FROM Token
|
||||||
FROM Token
|
|
||||||
WHERE tokenIndex = 0;
|
WHERE tokenIndex = 0;
|
||||||
|
|
||||||
clear:
|
clear:
|
||||||
|
@ -88,7 +88,7 @@ actual class Dir actual constructor(
|
|||||||
"-i ${m4aFile.absolutePath} -y -b:a 160k -acodec libmp3lame -vn ${m4aFile.absolutePath.substringBeforeLast('.') + ".mp3"}"
|
"-i ${m4aFile.absolutePath} -y -b:a 160k -acodec libmp3lame -vn ${m4aFile.absolutePath.substringBeforeLast('.') + ".mp3"}"
|
||||||
){ _, returnCode ->
|
){ _, returnCode ->
|
||||||
when (returnCode) {
|
when (returnCode) {
|
||||||
Config.RETURN_CODE_SUCCESS -> {
|
Config.RETURN_CODE_SUCCESS -> {
|
||||||
//FFMPEG task Completed
|
//FFMPEG task Completed
|
||||||
logger.d{ "Async command execution completed successfully." }
|
logger.d{ "Async command execution completed successfully." }
|
||||||
scope.launch {
|
scope.launch {
|
||||||
|
Loading…
Reference in New Issue
Block a user