Skip to content

Commit

Permalink
fix(RichTextEditor): Remove old code
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilippeWeidmann committed Jan 13, 2023
1 parent 889f460 commit 71dbe06
Showing 1 changed file with 1 addition and 10 deletions.
11 changes: 1 addition & 10 deletions Mail/Helpers/RichTextEditor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,6 @@ struct RichTextEditor: UIViewRepresentable {
@Binding var isShowingPhotoLibrary: Bool
var alert: ObservedObject<NewMessageAlert>.Wrapper

private var isFirstTime = true
private var delegateCount = 0
private var isInitialized: Bool {
delegateCount > 2
}

init(model: Binding<RichTextEditorModel>, body: Binding<String>,
alert: ObservedObject<NewMessageAlert>.Wrapper,
isShowingCamera: Binding<Bool>, isShowingFileSelection: Binding<Bool>, isShowingPhotoLibrary: Binding<Bool>) {
Expand Down Expand Up @@ -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
Expand All @@ -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
}
}

Expand Down

0 comments on commit 71dbe06

Please sign in to comment.