Skip to content

Commit 555df8b

Browse files
authored
Merge pull request #719 from wordpress-mobile/issue/718-update-on-first-mode-switch
Issue/718 update on first mode switch
2 parents 5400bf9 + b4793de commit 555df8b

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

app/src/main/kotlin/org/wordpress/aztec/demo/MainActivity.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,9 @@ open class MainActivity : AppCompatActivity(),
418418
}
419419

420420
if (savedInstanceState == null) {
421-
aztec.visualEditor.fromHtml(aztec.sourceEditor?.getPureHtml()!!)
421+
if (!isRunningTest) {
422+
aztec.visualEditor.fromHtml(EXAMPLE)
423+
}
422424
aztec.initSourceEditorHistory()
423425
}
424426

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)