Skip to content

Commit

Permalink
Merge pull request #697 from stakwork/aa/fix/calculate-storage-percen…
Browse files Browse the repository at this point in the history
…tage

Fix calculate store percentage crash on Profile
  • Loading branch information
tomastiminskas authored Jan 5, 2024
2 parents 7566f1b + c8f4845 commit c8b2e26
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package chat.sphinx.wrapper_common

import java.util.Locale


fun calculateStoragePercentage(storageData: StorageData): StoragePercentage {
val freeStorage = storageData.freeStorage?.value ?: 0L
Expand All @@ -8,11 +10,11 @@ fun calculateStoragePercentage(storageData: StorageData): StoragePercentage {
storageData.files.totalSize.value

return StoragePercentage(
freeStorage = String.format("%.3f", freeStorage.toFloat() / totalStorage).toFloat(),
image = String.format("%.3f", storageData.images.totalSize.value.toFloat() / totalStorage).toFloat(),
video = String.format("%.3f", storageData.video.totalSize.value.toFloat() / totalStorage).toFloat(),
audio = String.format("%.3f", storageData.audio.totalSize.value.toFloat() / totalStorage).toFloat(),
files = String.format("%.3f", storageData.files.totalSize.value.toFloat() / totalStorage).toFloat()
freeStorage = String.format(Locale.ENGLISH, "%.3f", freeStorage.toFloat() / totalStorage).toFloat(),
image = String.format(Locale.ENGLISH, "%.3f", storageData.images.totalSize.value.toFloat() / totalStorage).toFloat(),
video = String.format(Locale.ENGLISH, "%.3f", storageData.video.totalSize.value.toFloat() / totalStorage).toFloat(),
audio = String.format(Locale.ENGLISH, "%.3f", storageData.audio.totalSize.value.toFloat() / totalStorage).toFloat(),
files = String.format(Locale.ENGLISH, "%.3f", storageData.files.totalSize.value.toFloat() / totalStorage).toFloat()
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ internal class SphinxFirebaseMessagingService: FirebaseMessagingService() {

// Extract data from the message
// Extract data from the message
val title: String = p0.data["message"] ?: ""
val title: String = p0.data["title"] ?: ""
val messageBody: String = p0.data["body"] ?: ""
val chatId: Long? = (p0.data["chat_id"] ?: "").toLongOrNull()

Expand Down

0 comments on commit c8b2e26

Please sign in to comment.