Skip to content

Commit

Permalink
Potential fix for #172
Browse files Browse the repository at this point in the history
Upping versionCode to 108
  • Loading branch information
Dima-Android committed Oct 16, 2024
1 parent 885e9b7 commit 9d044d4
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,19 @@ class StoreItemDbRequest(
field.key == FieldKeys.Item.title || field.baseKey == FieldKeys.Item.title -> {
item.baseTitle = value
}

field.key == FieldKeys.Item.note && item.rawType == ItemTypes.note -> {
item.baseTitle = NotePreviewGenerator.preview(value) ?: ""
item.htmlFreeContent = if(value.isEmpty()) null else value
try {
item.baseTitle = NotePreviewGenerator.preview(value) ?: ""
} catch (e: Exception) {
Timber.e(
e,
"StoreItemsDbResponseRequest: unable to set baseTitle after value was processed by NotePreviewGenerator. Original value = ${
value.take(210)
}"
)
}
item.htmlFreeContent = value.ifEmpty { null }
}
field.key == FieldKeys.Item.Annotation.comment && item.rawType == ItemTypes.annotation -> {
item.htmlFreeContent = if(value.isEmpty()) null else value.strippedRichTextTags
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,26 @@ class NotePreviewGenerator {
return null
}
var stripped = note.strippedHtmlTags.basicUnescape
stripped = stripped.replace("\t", "")
stripped = stripped.replace("\t", "")
stripped = stripped.split("\\r\\n|\\n|\\r").firstOrNull() ?: stripped
stripped = stripped.trim()

val maxCharacters = 200
if (stripped.length > maxCharacters) {
stripped = stripped.take(maxCharacters)
}
if (stripped.isNotEmpty()) {
//Has a valid surrogate pair at the very end of the stripped text
if (stripped.hasSurrogatePairAt(stripped.length - 2)) {
return stripped
}

val lastChar = stripped[stripped.length - 1]
//If last char is the surrogate without a pair
if (lastChar.isLowSurrogate() || lastChar.isHighSurrogate()) {
return stripped.substring(0, stripped.length - 1)
}
}
return stripped
}
}
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 = 107 // Must be updated on every build
val versionCode = 108 // Must be updated on every build
val version = Version(
major = 1,
minor = 0,
Expand Down

0 comments on commit 9d044d4

Please sign in to comment.