Skip to content
Snippets Groups Projects
Commit 1b09947f authored by Janne Mareike Koschinski's avatar Janne Mareike Koschinski
Browse files

Fixed a serialization bug

parent a8c3c347
No related branches found
No related tags found
No related merge requests found
...@@ -181,16 +181,28 @@ class IrcFormatSerializer @Inject constructor(private val context: Context) { ...@@ -181,16 +181,28 @@ class IrcFormatSerializer @Inject constructor(private val context: Context) {
val afterForegroundCode = mircColorMap[afterForeground] val afterForegroundCode = mircColorMap[afterForeground]
val afterBackgroundCode = mircColorMap[afterBackground] val afterBackgroundCode = mircColorMap[afterBackground]
if (afterForegroundCode != null || afterBackgroundCode != null) { val hasForegroundBefore = foreground != null
val hasBackgroundBefore = background != null
val foregroundBeforeCodeValid = foregroundCode != null
val backgroundBeforeCodeValid = backgroundCode != null
val hasForegroundAfter = afterForeground != null
val hasBackgroundAfter = afterBackground != null
val foregroundAfterCodeValid = afterForegroundCode != null
val backgroundAfterCodeValid = afterBackgroundCode != null
if ((!hasBackgroundAfter || backgroundAfterCodeValid) &&
(!hasForegroundAfter || foregroundAfterCodeValid)) {
if (afterForegroundCode == backgroundCode && afterBackgroundCode == foregroundCode) { if (afterForegroundCode == backgroundCode && afterBackgroundCode == foregroundCode) {
writeSwap(afterForegroundCode, afterBackgroundCode) writeSwap(afterForegroundCode, afterBackgroundCode)
} else { } else {
writeColor(afterForegroundCode, afterBackgroundCode) writeColor(afterForegroundCode, afterBackgroundCode)
} }
} else if (afterForeground != null || afterBackground != null) { } else if (hasForegroundAfter || hasBackgroundAfter) {
writeHexColor(afterForeground, afterBackground) writeHexColor(afterForeground, afterBackground)
} else { } else {
if (foregroundCode != null || backgroundCode != null) { if ((!hasBackgroundBefore || backgroundBeforeCodeValid) &&
(!hasForegroundBefore || foregroundBeforeCodeValid)) {
writeColor(afterForeground, afterBackground) writeColor(afterForeground, afterBackground)
} else { } else {
writeHexColor(afterForeground, afterBackground) writeHexColor(afterForeground, afterBackground)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment