Skip to content

Commit

Permalink
TW-683: Update pub lock
Browse files Browse the repository at this point in the history
  • Loading branch information
Julian KOUNE committed Dec 16, 2023
1 parent 014be33 commit b3dd975
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 4 deletions.
37 changes: 37 additions & 0 deletions docs/adr/0013-converting-linebreaks-in-sdk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# 13. Converting Linebreaks in SDK

Date: 2023-13-12

## Status

Accepted

## Context

In Twake Chat, we allow users to send messages with linebreaks. However, we only limit them to 2 linebreaks in a row. This is to prevent users from sending messages with too many linebreaks, which would make the chat hard to read.

## Decision

- Add a new method (syntax) to the SDK that converts more then 2 linebreaks in a row to 1 linebreak.
- Process the whole message and not line by line before sending it to the server.

```dart
class MultipleLinebreaksSyntax extends InlineSyntax {
MultipleLinebreaksSyntax() : super(r'\n{2,}');
@override
bool onMatch(InlineParser parser, Match match) {
parser.addNode(Element.empty('br'));
return true;
}
}
```

The regex `r'\n{2,}'` matches 2 or more linebreaks in a row.
If the regex matches, we replace the linebreaks with a `<br>` tag.

```dart
## Consequences
- The SDK will be able to convert more than 2 linebreaks in a row to 1 linebreak.
6 changes: 3 additions & 3 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -949,8 +949,8 @@ packages:
dependency: "direct main"
description:
path: "."
ref: master
resolved-ref: "608fb381790d068664f73e33c3277671e5e172ca"
ref: TW-1135-support-br
resolved-ref: "8362c0f07bd4178fd1c832f718e97941b48becfc"
url: "https://github.com/linagora/flutter_matrix_html.git"
source: git
version: "1.2.0"
Expand Down Expand Up @@ -1583,7 +1583,7 @@ packages:
description:
path: "."
ref: "twake-supported-0.22.6"
resolved-ref: bfff7db647b177a0a0e04780e063bfbdd22031b8
resolved-ref: e5e67b2d0158b9398eb6430841c2bed7f61d8997
url: "[email protected]:linagora/matrix-dart-sdk.git"
source: git
version: "0.22.6"
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ dependencies:
flutter_matrix_html:
git:
url: https://github.com/linagora/flutter_matrix_html.git
ref: master
ref: TW-1135-support-br
overflow_view: ^0.3.1
json_annotation: ^4.8.1
contacts_service:
Expand Down

0 comments on commit b3dd975

Please sign in to comment.