Skip to content

Commit b6893bc

Browse files
committed
Initialize the hash values on first switch of mode
1 parent 69a8863 commit b6893bc

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

aztec/src/main/kotlin/org/wordpress/aztec/toolbar/AztecToolbar.kt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,12 @@ class AztecToolbar : FrameLayout, IAztecToolbar, OnMenuItemClickListener {
575575
private fun syncSourceFromEditor() {
576576
val editorHtml = editor!!.toPlainHtml(true)
577577
val sha256 = AztecText.calculateSHA256(editorHtml)
578+
579+
if (editorContentParsedSHA256LastSwitch.isEmpty()) {
580+
// initialize the var if it's the first time we're about to use it
581+
editorContentParsedSHA256LastSwitch = sha256
582+
}
583+
578584
if (editor!!.hasChanges() != NO_CHANGES || !Arrays.equals(editorContentParsedSHA256LastSwitch, sha256)) {
579585
sourceEditor!!.displayStyledAndFormattedHtml(editorHtml)
580586
}
@@ -585,6 +591,12 @@ class AztecToolbar : FrameLayout, IAztecToolbar, OnMenuItemClickListener {
585591
// temp var of the source html to load it to the editor if needed
586592
val sourceHtml = sourceEditor!!.getPureHtml(true)
587593
val sha256 = AztecText.calculateSHA256(sourceHtml)
594+
595+
if (sourceContentParsedSHA256LastSwitch.isEmpty()) {
596+
// initialize the var if it's the first time we're about to use it
597+
sourceContentParsedSHA256LastSwitch = sha256
598+
}
599+
588600
if (sourceEditor!!.hasChanges() != NO_CHANGES || !Arrays.equals(sourceContentParsedSHA256LastSwitch, sha256)) {
589601
editor!!.fromHtml(sourceHtml)
590602
}

0 commit comments

Comments
 (0)