Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ fun ModalRenderer(
)
}

Modal.DeleteConfirm -> DecisionInteractiveDialog(
Modal.DeleteImageConfirm -> DecisionInteractiveDialog(
title = R.string.interaction_delete_generation_title.asUiText(),
text = R.string.interaction_delete_generation_sub_title.asUiText(),
confirmActionResId = R.string.yes,
Expand Down Expand Up @@ -211,5 +211,17 @@ fun ModalRenderer(
) {
LanguageBottomSheet(onDismissRequest = dismiss)
}

is Modal.DeleteLocalModelConfirm -> DecisionInteractiveDialog(
title = R.string.interaction_delete_local_model_title.asUiText(),
text = UiText.Resource(
R.string.interaction_delete_local_model_sub_title,
screenModal.model.name,
),
confirmActionResId = R.string.yes,
dismissActionResId = R.string.no,
onConfirmAction = { processIntent(ServerSetupIntent.LocalModel.DeleteConfirm(screenModal.model)) },
onDismissRequest = dismiss,
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import com.shifthackz.aisdv1.core.model.UiText
import com.shifthackz.aisdv1.domain.entity.AiGenerationResult
import com.shifthackz.aisdv1.domain.entity.HordeProcessStatus
import com.shifthackz.aisdv1.domain.feature.diffusion.LocalDiffusion
import com.shifthackz.aisdv1.presentation.screen.setup.ServerSetupState

sealed interface Modal {

Expand All @@ -14,7 +15,7 @@ sealed interface Modal {

data object ClearAppCache : Modal

data object DeleteConfirm : Modal
data object DeleteImageConfirm : Modal

data object ConfirmExport : Modal

Expand Down Expand Up @@ -74,6 +75,9 @@ sealed interface Modal {
}
}

@Immutable
data class DeleteLocalModelConfirm(val model: ServerSetupState.LocalModel) : Modal

@Immutable
data class Error(val error: UiText) : Modal

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.shifthackz.aisdv1.presentation.screen.gallery.detail

import com.shifthackz.aisdv1.core.common.log.debugLog
import com.shifthackz.aisdv1.core.common.log.errorLog
import com.shifthackz.aisdv1.core.common.schedulers.SchedulersProvider
import com.shifthackz.aisdv1.core.common.schedulers.subscribeOnMainThread
Expand Down Expand Up @@ -43,15 +42,12 @@ class GalleryDetailViewModel(
}

override fun processIntent(intent: GalleryDetailIntent) {
debugLog("INTENT : $intent")
when (intent) {
is GalleryDetailIntent.CopyToClipboard -> {
emitEffect(GalleryDetailEffect.ShareClipBoard(intent.content.toString()))
}

GalleryDetailIntent.Delete.Request -> {
setActiveModal(Modal.DeleteConfirm)
}
GalleryDetailIntent.Delete.Request -> setActiveModal(Modal.DeleteImageConfirm)

GalleryDetailIntent.Delete.Confirm -> {
setActiveModal(Modal.None)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ sealed interface ServerSetupIntent : MviIntent {

data class UpdateHordeDefaultApiKey(val value: Boolean) : ServerSetupIntent

data class DownloadCardButtonClick(val model: ServerSetupState.LocalModel) : ServerSetupIntent

data class SelectLocalModel(val model: ServerSetupState.LocalModel) : ServerSetupIntent

data class AllowLocalCustomModel(val allow: Boolean) : ServerSetupIntent
Expand Down Expand Up @@ -77,4 +75,13 @@ sealed interface ServerSetupIntent : MviIntent {
get() = linksProvider.openAiInfoUrl
}
}

sealed interface LocalModel : ServerSetupIntent {

val model: ServerSetupState.LocalModel

data class ClickReduce(override val model: ServerSetupState.LocalModel) : LocalModel

data class DeleteConfirm(override val model: ServerSetupState.LocalModel) : LocalModel
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.shifthackz.aisdv1.presentation.screen.setup

import com.shifthackz.aisdv1.core.common.log.debugLog
import com.shifthackz.aisdv1.core.common.log.errorLog
import com.shifthackz.aisdv1.core.common.schedulers.SchedulersProvider
import com.shifthackz.aisdv1.core.common.schedulers.subscribeOnMainThread
Expand Down Expand Up @@ -94,7 +93,22 @@ class ServerSetupViewModel(

ServerSetupIntent.DismissDialog -> setScreenModal(Modal.None)

is ServerSetupIntent.DownloadCardButtonClick -> localModelDownloadClickReducer(intent.model)
is ServerSetupIntent.LocalModel.ClickReduce -> localModelDownloadClickReducer(intent.model)

is ServerSetupIntent.LocalModel.DeleteConfirm -> updateState {
!deleteModelUseCase(intent.model.id)
.subscribeOnMainThread(schedulersProvider)
.subscribeBy(::errorLog)
it.copy(
screenModal = Modal.None,
localModels = currentState.localModels.withNewState(
intent.model.copy(
downloadState = DownloadState.Unknown,
downloaded = false,
),
),
)
}

is ServerSetupIntent.SelectLocalModel -> {
if (currentState.localModels.any { it.downloadState is DownloadState.Downloading }) {
Expand Down Expand Up @@ -319,19 +333,8 @@ class ServerSetupViewModel(
}
}
// User deletes local model
localModel.downloaded -> {
updateState {
it.copy(
localModels = currentState.localModels.withNewState(
localModel.copy(
downloadState = DownloadState.Unknown,
downloaded = false,
),
),
)
}
!deleteModelUseCase(localModel.id).subscribeOnMainThread(schedulersProvider)
.subscribeBy(::errorLog)
localModel.downloaded -> updateState {
it.copy(screenModal = Modal.DeleteLocalModelConfirm(localModel))
}
// User requested new download operation
else -> {
Expand Down Expand Up @@ -364,7 +367,6 @@ class ServerSetupViewModel(
setScreenModal(Modal.Error(message.asUiText()))
},
onNext = { downloadState ->
debugLog("DOWNLOAD STATE : $downloadState")
updateState {
when (downloadState) {
is DownloadState.Complete -> it.copy(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ fun LocalDiffusionForm(
if (model.id != LocalAiModel.CUSTOM.id) {
Button(
modifier = Modifier.padding(end = 8.dp),
onClick = { processIntent(ServerSetupIntent.DownloadCardButtonClick(model)) },
onClick = { processIntent(ServerSetupIntent.LocalModel.ClickReduce(model)) },
) {
Text(
text = stringResource(
Expand Down
3 changes: 3 additions & 0 deletions presentation/src/main/res/values-ru/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,9 @@
<string name="interaction_delete_generation_title">Удалить изображение</string>
<string name="interaction_delete_generation_sub_title">Вы уверены, что хотите окончательно удалить это изображение?</string>

<string name="interaction_delete_local_model_title">Удалить модель</string>
<string name="interaction_delete_local_model_sub_title">Вы уверены, что хотите удалить модель "%1$s"?</string>

<string name="gallery_empty_title">Здесь еще ничего нет…</string>
<string name="gallery_empty_sub_title">Попытайтесь создать что-то, и вы увидите свое изображение здесь!</string>

Expand Down
3 changes: 3 additions & 0 deletions presentation/src/main/res/values-tr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,9 @@
<string name="interaction_delete_generation_title">Resmi sil</string>
<string name="interaction_delete_generation_sub_title">Kalıcı olarak bu resmi silmek istediğinize emin misiniz?</string>

<string name="interaction_delete_local_model_title">Modeli sil</string>
<string name="interaction_delete_local_model_sub_title">Modeli silmek istediğinizden emin misiniz "%1$s"?</string>

<string name="gallery_empty_title">Burada henüz bir şey yok…</string>
<string name="gallery_empty_sub_title">Bir şeyler üretmeyi deneyin! Ürettiğiniz resimler burada gözükecektir.</string>

Expand Down
3 changes: 3 additions & 0 deletions presentation/src/main/res/values-uk/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,9 @@
<string name="interaction_delete_generation_title">Видалити зображення</string>
<string name="interaction_delete_generation_sub_title">Ви впевнені, що хочете остаточно видалити це зображення?</string>

<string name="interaction_delete_local_model_title">Видалити модель</string>
<string name="interaction_delete_local_model_sub_title">Ви впевнені, що хочете видалити модель "%1$s"?</string>

<string name="gallery_empty_title">Тут ще нічого немає…</string>
<string name="gallery_empty_sub_title">Спробуйте створити щось, і ви побачите своє зображення тут!</string>

Expand Down
5 changes: 4 additions & 1 deletion presentation/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,10 @@
<string name="interaction_cache_sub_title">This will reset app settings and delete all the generated images. Do you want to proceed?</string>

<string name="interaction_delete_generation_title">Delete image</string>
<string name="interaction_delete_generation_sub_title">Are you sure you want to permanently remove this image?</string>
<string name="interaction_delete_generation_sub_title">Are you sure you want to permanently delete this image?</string>

<string name="interaction_delete_local_model_title">Delete model</string>
<string name="interaction_delete_local_model_sub_title">Are you sure you want to delete model "%1$s"?</string>

<string name="gallery_empty_title">There is nothing here yet…</string>
<string name="gallery_empty_sub_title">Try to generate something, and you will see your image here!</string>
Expand Down