From 71dbe0663d696e2ceaafe903719ec21b5eac437f Mon Sep 17 00:00:00 2001 From: Philippe Weidmann Date: Fri, 13 Jan 2023 15:00:32 +0100 Subject: [PATCH] fix(RichTextEditor): Remove old code --- Mail/Helpers/RichTextEditor.swift | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/Mail/Helpers/RichTextEditor.swift b/Mail/Helpers/RichTextEditor.swift index 5c2e1d93d..c017aa068 100644 --- a/Mail/Helpers/RichTextEditor.swift +++ b/Mail/Helpers/RichTextEditor.swift @@ -32,12 +32,6 @@ struct RichTextEditor: UIViewRepresentable { @Binding var isShowingPhotoLibrary: Bool var alert: ObservedObject.Wrapper - private var isFirstTime = true - private var delegateCount = 0 - private var isInitialized: Bool { - delegateCount > 2 - } - init(model: Binding, body: Binding, alert: ObservedObject.Wrapper, isShowingCamera: Binding, isShowingFileSelection: Binding, isShowingPhotoLibrary: Binding) { @@ -72,8 +66,6 @@ struct RichTextEditor: UIViewRepresentable { } func editor(_ editor: SQTextEditorView, cursorPositionDidChange position: SQEditorCursorPosition) { - parent.delegateCount += 1 - guard parent.isInitialized else { return } let newCursorPosition = CGFloat(position.bottom) + 20 if parent.model.cursorPosition != newCursorPosition { parent.model.cursorPosition = newCursorPosition @@ -89,10 +81,9 @@ struct RichTextEditor: UIViewRepresentable { func editorContentChanged(_ editor: SQTextEditorView, content: String) { var parentBody = parent.body.trimmingCharacters(in: .whitespacesAndNewlines) parentBody = parentBody.replacingOccurrences(of: "\r", with: "") - if parentBody != content && !parent.isFirstTime { + if parentBody != content { parent.body = content } - parent.isFirstTime = false } }