Skip to content

Commit

Permalink
Sort fallbacks last-to-first
Browse files Browse the repository at this point in the history
Otherwise removing them doesn't work right
  • Loading branch information
singpolyma committed Oct 8, 2024
1 parent a2949dc commit 22db517
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion snikket/ChatMessage.hx
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ class ChatMessage {
final fallbacks: Array<{start: Int, end: Int}> = cast payloads.filter(
(p) -> p.attr.get("xmlns") == "urn:xmpp:fallback:0" && (p.attr.get("for") == "jabber:x:oob" || p.attr.get("for") == "urn:xmpp:sims:1" || (replyToMessage != null && p.attr.get("for") == "urn:xmpp:reply:0") || p.attr.get("for") == "http://jabber.org/protocol/address")
).map((p) -> p.getChild("body")).map((b) -> b == null ? null : { start: Std.parseInt(b.attr.get("start") ?? "0") ?? 0, end: Std.parseInt(b.attr.get("end") ?? Std.string(codepoints.length)) ?? codepoints.length }).filter((b) -> b != null);
fallbacks.sort((x, y) -> x.start - y.start);
fallbacks.sort((x, y) -> y.start - x.start);
for (fallback in fallbacks) {
codepoints.splice(fallback.start, (fallback.end - fallback.start));
}
Expand Down

0 comments on commit 22db517

Please sign in to comment.