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,
|
||||
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)) {
|
||||
ImageLoad(
|
||||
{loadImage(track.albumArtURL)},
|
||||
|
@ -1,7 +1,5 @@
|
||||
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.extensions.coroutines.SuspendExecutor
|
||||
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.ui.showPopUpMessage
|
||||
import kotlinx.coroutines.flow.MutableSharedFlow
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
import kotlinx.coroutines.flow.collectLatest
|
||||
import org.koin.ext.scope
|
||||
|
||||
internal class SpotiFlyerListStoreProvider(
|
||||
private val dir: Dir,
|
||||
@ -70,16 +66,15 @@ internal class SpotiFlyerListStoreProvider(
|
||||
else downloadTracks(finalList,fetchQuery.youtubeMusic::getYTIDBestMatch,dir::saveFileWithMetadata)
|
||||
|
||||
val list = intent.trackList.map {
|
||||
if (it.downloaded == DownloadStatus.NotDownloaded) {
|
||||
it.downloaded = DownloadStatus.Queued
|
||||
}
|
||||
if (it.downloaded == DownloadStatus.NotDownloaded)
|
||||
return@map it.copy(downloaded = DownloadStatus.Queued)
|
||||
it
|
||||
}
|
||||
dispatch(Result.UpdateTrackList(list.updateTracksStatuses(downloadProgressFlow.replayCache.getOrElse(0){ hashMapOf()})))
|
||||
}
|
||||
is Intent.StartDownload -> {
|
||||
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()
|
||||
}
|
||||
@ -108,7 +103,7 @@ internal class SpotiFlyerListStoreProvider(
|
||||
for(newTrack in map){
|
||||
titleList.indexOf(newTrack.key).let { position ->
|
||||
if(position != -1){
|
||||
updatedList.getOrNull(position)?.apply { downloaded = newTrack.value }?.also { updatedTrack ->
|
||||
updatedList.getOrNull(position)?.copy(downloaded = newTrack.value)?.also { updatedTrack ->
|
||||
updatedList[position] = updatedTrack
|
||||
logger.d("$position) ${updatedTrack.downloaded} - ${updatedTrack.title}","List Store Track Update")
|
||||
}
|
||||
|
@ -35,10 +35,9 @@ data class TrackDetails(
|
||||
var albumArtPath: String,
|
||||
var albumArtURL: String,
|
||||
var source: Source,
|
||||
var downloaded: DownloadStatus = DownloadStatus.NotDownloaded,
|
||||
var progress: Int = 2,//2 for visual progress bar hint
|
||||
val downloaded: DownloadStatus = DownloadStatus.NotDownloaded,
|
||||
var outputFilePath: String,
|
||||
var videoID:String? = null
|
||||
var videoID:String? = null,
|
||||
):Parcelable
|
||||
|
||||
|
||||
|
@ -1,16 +1,15 @@
|
||||
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,
|
||||
expiry INTEGER NOT NULL
|
||||
);
|
||||
|
||||
add:
|
||||
INSERT OR REPLACE INTO Token (accessToken,expiry)
|
||||
VALUES (?,?);
|
||||
INSERT OR REPLACE INTO Token (tokenIndex,accessToken,expiry)
|
||||
VALUES (0,?,?);
|
||||
|
||||
select:
|
||||
SELECT *
|
||||
FROM Token
|
||||
SELECT * FROM Token
|
||||
WHERE tokenIndex = 0;
|
||||
|
||||
clear:
|
||||
|
Loading…
Reference in New Issue
Block a user