Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix:update text bug #112

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

xiongxiongjiang
Copy link

@xiongxiongjiang xiongxiongjiang commented Nov 4, 2024

fix #104 #78

The reason the UI did not update after the message was updated is due to the author's comparison logic.

UIList.swift

if context.coordinator.sections == sections {
    return
}

MessagesSection.swift

static func == (lhs: MessagesSection, rhs: MessagesSection) -> Bool {
    lhs.date == rhs.date && lhs.rows == rhs.rows
}

MessageRow.swift

static func == (lhs: Self, rhs: Self) -> Bool {
    lhs.id == rhs.id
    && lhs.positionInUserGroup == rhs.positionInUserGroup
    && lhs.commentsPosition == rhs.commentsPosition
    && lhs.message.status == rhs.message.status
    && lhs.message.triggerRedraw == rhs.message.triggerRedraw
}

At this point, we can identify the issue: Although the author included all fields in their response at this link, the MessageRow did not account for one important field. As a result, the comparison of sections showed no changes, which prevented the update from being triggered.

Modification:

static func == (lhs: Self, rhs: Self) -> Bool {
    lhs.id == rhs.id
    && lhs.positionInUserGroup == rhs.positionInUserGroup
    && lhs.commentsPosition == rhs.commentsPosition
    && lhs.message.status == rhs.message.status
    && lhs.message.triggerRedraw == rhs.message.triggerRedraw
    && lhs.message.text == rhs.message.text // add this
}

@xiongxiongjiang xiongxiongjiang changed the title fix:fix update text bug fix:update text bug Nov 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

How to implement dynamic message?
1 participant