Skip to content

Commit

Permalink
Show proper error message on quota error when sharing file to app Closes
Browse files Browse the repository at this point in the history
 #214

Upping versionCode to 134
  • Loading branch information
Dima-Android committed Feb 13, 2025
1 parent 58b18a7 commit 2dcbed8
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import org.zotero.android.database.requests.ReadGroupDbRequest
import org.zotero.android.sync.LibraryIdentifier
import org.zotero.android.sync.Parsing
import org.zotero.android.sync.SchemaError
import org.zotero.android.sync.SyncActionError
import org.zotero.android.translator.data.AttachmentState
import org.zotero.android.translator.data.TranslationWebViewError
import org.zotero.android.uicomponents.Strings
Expand Down Expand Up @@ -153,6 +154,11 @@ class ShareErrorProcessor @Inject constructor(
if (error is TranslationWebViewError) {
return AttachmentState.Error.webViewError(error)
}
if (error is SyncActionError.authorizationFailed) {
if (libraryId != null) {
return AttachmentState.Error.quotaLimit(libraryId)
}
}
}

is CustomResult.GeneralError.NetworkError -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ internal class ShareViewModel @Inject constructor(
private lateinit var selectedCollectionId: CollectionIdentifier
private lateinit var selectedLibraryId: LibraryIdentifier
private lateinit var attachmentKey: String
private var wasAttachmentUploaded: Boolean = false

@Subscribe(threadMode = ThreadMode.MAIN)
fun onEvent(tagPickerResult: TagPickerResult) {
Expand Down Expand Up @@ -387,7 +388,7 @@ internal class ShareViewModel @Inject constructor(

private fun finishSync(successful: Boolean) {
Timber.i("ShareViewModel: finishSync success = $successful")
if (!successful) {
if (!successful && wasAttachmentUploaded) {
updateState {
copy(collectionPickerState = CollectionPickerState.failed)
}
Expand Down Expand Up @@ -979,6 +980,7 @@ internal class ShareViewModel @Inject constructor(
zipMimetype = this.zipMimetype,
processUploadToZoteroException = ::processUploadToZoteroException,
onBack = {
wasAttachmentUploaded = true
maybeSaveCachedDataInPdfWorker()
})
} else {
Expand All @@ -988,6 +990,7 @@ internal class ShareViewModel @Inject constructor(
defaultMimetype = this.defaultMimetype,
processUploadToZoteroException = ::processUploadToZoteroException,
onBack = {
wasAttachmentUploaded = true
maybeSaveCachedDataInPdfWorker()
}
)
Expand All @@ -1005,7 +1008,9 @@ internal class ShareViewModel @Inject constructor(
tags = tags
)
} else {
triggerEffect(ShareViewEffect.NavigateBack)
if (wasAttachmentUploaded) {
triggerEffect(ShareViewEffect.NavigateBack)
}
}


Expand All @@ -1016,7 +1021,8 @@ internal class ShareViewModel @Inject constructor(
error: CustomResult.GeneralError,
data: UploadData
) {

wasAttachmentUploaded = false
maybeSaveCachedDataInPdfWorker()
updateState {
copy(
attachmentState = AttachmentState.failed(
Expand Down Expand Up @@ -1065,7 +1071,9 @@ internal class ShareViewModel @Inject constructor(
updateState { copy(retrieveMetadataState = RetrieveMetadataState.failed(update.errorMessage)) }
}
is PdfWorkerController.Update.recognizedAndSaved -> {
triggerEffect(ShareViewEffect.NavigateBack)
if (wasAttachmentUploaded) {
triggerEffect(ShareViewEffect.NavigateBack)
}
}
is PdfWorkerController.Update.recognizedAndKeptInMemory -> {
updateState {
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/BuildConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ object BuildConfig {
const val compileSdkVersion = 34
const val targetSdk = 34

val versionCode = 133 // Must be updated on every build
val versionCode = 134 // Must be updated on every build
val version = Version(
major = 1,
minor = 0,
Expand Down

0 comments on commit 2dcbed8

Please sign in to comment.