From fc06da627969d3e5f8608aa4276a84087cf9e8a4 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Fri, 28 Oct 2022 13:08:49 +0200 Subject: [PATCH 001/107] feat(ui): add sendMessageKey and clearQuotedMessageKey --- .../src/platform_widget_base.dart | 4 +- .../message_input/stream_message_input.dart | 60 +++++++++++++------ 2 files changed, 45 insertions(+), 19 deletions(-) diff --git a/packages/stream_chat_flutter/lib/platform_widget_builder/src/platform_widget_base.dart b/packages/stream_chat_flutter/lib/platform_widget_builder/src/platform_widget_base.dart index 9d3470d66..0487bd439 100644 --- a/packages/stream_chat_flutter/lib/platform_widget_builder/src/platform_widget_base.dart +++ b/packages/stream_chat_flutter/lib/platform_widget_builder/src/platform_widget_base.dart @@ -1,4 +1,4 @@ -import 'package:flutter/material.dart' show Theme; +import 'package:flutter/foundation.dart'; import 'package:flutter/widgets.dart'; /// A generic widget builder function. @@ -30,7 +30,7 @@ abstract class PlatformWidgetBase : CrossFadeState.showSecond, ), ), - // PlatformWidgetBuilder( - // mobile: (context, child) => _buildFilePickerSection(), - // ), ], ), ), @@ -753,25 +759,45 @@ class StreamMessageInputState extends State LimitedBox( maxHeight: widget.maxHeight, child: PlatformWidgetBuilder( - web: (context, child) => KeyboardShortcutRunner( - onEnterKeypress: sendMessage, - onEscapeKeypress: () { - if (_hasQuotedMessage && - _effectiveController.text.isEmpty) { - widget.onQuotedMessageCleared?.call(); + web: (context, child) => Focus( + child: child!, + onKeyEvent: (node, event) { + if (widget.sendMessageKey != null && + event.physicalKey == widget.sendMessageKey) { + sendMessage(); + return KeyEventResult.handled; + } else if (widget.clearQuotedMessageKey != null && + event.physicalKey == + widget.clearQuotedMessageKey) { + if (_hasQuotedMessage && + _effectiveController.text.isEmpty) { + widget.onQuotedMessageCleared?.call(); + } + return KeyEventResult.handled; } + + return KeyEventResult.ignored; }, - child: child!, ), - desktop: (context, child) => KeyboardShortcutRunner( - onEnterKeypress: sendMessage, - onEscapeKeypress: () { - if (_hasQuotedMessage && - _effectiveController.text.isEmpty) { - widget.onQuotedMessageCleared?.call(); + desktop: (context, child) => Focus( + child: child!, + onKeyEvent: (node, event) { + if (widget.sendMessageKey != null && + event.physicalKey == widget.sendMessageKey) { + sendMessage(); + return KeyEventResult.handled; + } else if (widget.clearQuotedMessageKey != null && + event.physicalKey == + widget.clearQuotedMessageKey) { + if (_hasQuotedMessage && + _effectiveController.text.isEmpty) { + widget.onQuotedMessageCleared?.call(); + } + return KeyEventResult.handled; } + + return KeyEventResult.ignored; }, - child: child!, ), mobile: (context, child) => child, child: StreamMessageTextField( From d814d5b0a3fdf5152138bb4e9b15cfb3521cf385 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Fri, 28 Oct 2022 13:09:36 +0200 Subject: [PATCH 002/107] chore(ui): update changelog --- packages/stream_chat_flutter/CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/stream_chat_flutter/CHANGELOG.md b/packages/stream_chat_flutter/CHANGELOG.md index 61782c021..e8047b763 100644 --- a/packages/stream_chat_flutter/CHANGELOG.md +++ b/packages/stream_chat_flutter/CHANGELOG.md @@ -1,3 +1,9 @@ +## Upcoming + +✅ Added + +- Added `StreamMessageInput.sendMessageKey` and `StreamMessageInput.clearQuotedMessageKey` to customize the keys used to send and clear the quoted message. + ## 5.1.0 🐞 Fixed From 64e41475d9b4da457c93e6e7498aa439cb6b68f7 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Mon, 31 Oct 2022 12:22:56 +0100 Subject: [PATCH 003/107] fix(ui): use a predicate instead of a key --- packages/stream_chat_flutter/CHANGELOG.md | 2 +- .../message_input/stream_message_input.dart | 80 +++++++++---------- .../lib/src/utils/typedefs.dart | 5 ++ 3 files changed, 46 insertions(+), 41 deletions(-) diff --git a/packages/stream_chat_flutter/CHANGELOG.md b/packages/stream_chat_flutter/CHANGELOG.md index e8047b763..82e1da486 100644 --- a/packages/stream_chat_flutter/CHANGELOG.md +++ b/packages/stream_chat_flutter/CHANGELOG.md @@ -2,7 +2,7 @@ ✅ Added -- Added `StreamMessageInput.sendMessageKey` and `StreamMessageInput.clearQuotedMessageKey` to customize the keys used to send and clear the quoted message. +- Added `StreamMessageInput.sendMessageKeyPredicate` and `StreamMessageInput.clearQuotedMessageKeyPredicate` to customize the keys used to send and clear the quoted message. ## 5.1.0 diff --git a/packages/stream_chat_flutter/lib/src/message_input/stream_message_input.dart b/packages/stream_chat_flutter/lib/src/message_input/stream_message_input.dart index 4f83d0803..0a7aa4d38 100644 --- a/packages/stream_chat_flutter/lib/src/message_input/stream_message_input.dart +++ b/packages/stream_chat_flutter/lib/src/message_input/stream_message_input.dart @@ -111,15 +111,16 @@ class StreamMessageInput extends StatefulWidget { this.enableMentionsOverlay = true, this.onQuotedMessageCleared, this.enableActionAnimation = true, - this.sendMessageKey = PhysicalKeyboardKey.enter, - this.clearQuotedMessageKey = PhysicalKeyboardKey.escape, + this.sendMessageKeyPredicate = _defaultSendMessageKeyPredicate, + this.clearQuotedMessageKeyPredicate = + _defaultClearQuotedMessageKeyPredicate, }); - /// The key used to send a message on web/desktop - final PhysicalKeyboardKey? sendMessageKey; + /// The predicate used to send a message on desktop/web + final RawKeyEventPredicate? sendMessageKeyPredicate; - /// The key used to send a message on web/desktop - final PhysicalKeyboardKey? clearQuotedMessageKey; + /// The predicate used to clear the quoted message on desktop/web + final RawKeyEventPredicate? clearQuotedMessageKeyPredicate; /// If true the message input will animate the actions while you type final bool enableActionAnimation; @@ -261,6 +262,18 @@ class StreamMessageInput extends StatefulWidget { static bool _defaultValidator(Message message) => message.text?.isNotEmpty == true || message.attachments.isNotEmpty; + static bool _defaultSendMessageKeyPredicate( + FocusNode node, + RawKeyEvent event, + ) => + event.logicalKey == LogicalKeyboardKey.enter; + + static bool _defaultClearQuotedMessageKeyPredicate( + FocusNode node, + RawKeyEvent event, + ) => + event.logicalKey == LogicalKeyboardKey.escape; + @override StreamMessageInputState createState() => StreamMessageInputState(); } @@ -760,44 +773,12 @@ class StreamMessageInputState extends State maxHeight: widget.maxHeight, child: PlatformWidgetBuilder( web: (context, child) => Focus( + onKey: _handleKeyPressed, child: child!, - onKeyEvent: (node, event) { - if (widget.sendMessageKey != null && - event.physicalKey == widget.sendMessageKey) { - sendMessage(); - return KeyEventResult.handled; - } else if (widget.clearQuotedMessageKey != null && - event.physicalKey == - widget.clearQuotedMessageKey) { - if (_hasQuotedMessage && - _effectiveController.text.isEmpty) { - widget.onQuotedMessageCleared?.call(); - } - return KeyEventResult.handled; - } - - return KeyEventResult.ignored; - }, ), desktop: (context, child) => Focus( + onKey: _handleKeyPressed, child: child!, - onKeyEvent: (node, event) { - if (widget.sendMessageKey != null && - event.physicalKey == widget.sendMessageKey) { - sendMessage(); - return KeyEventResult.handled; - } else if (widget.clearQuotedMessageKey != null && - event.physicalKey == - widget.clearQuotedMessageKey) { - if (_hasQuotedMessage && - _effectiveController.text.isEmpty) { - widget.onQuotedMessageCleared?.call(); - } - return KeyEventResult.handled; - } - - return KeyEventResult.ignored; - }, ), mobile: (context, child) => child, child: StreamMessageTextField( @@ -827,6 +808,25 @@ class StreamMessageInputState extends State ); } + KeyEventResult _handleKeyPressed( + FocusNode node, + RawKeyEvent event, + ) { + if (widget.sendMessageKeyPredicate != null && + widget.sendMessageKeyPredicate!(node, event)) { + sendMessage(); + return KeyEventResult.handled; + } else if (widget.clearQuotedMessageKeyPredicate != null && + widget.clearQuotedMessageKeyPredicate!(node, event)) { + if (_hasQuotedMessage && _effectiveController.text.isEmpty) { + widget.onQuotedMessageCleared?.call(); + } + return KeyEventResult.handled; + } + + return KeyEventResult.ignored; + } + InputDecoration _getInputDecoration(BuildContext context) { final passedDecoration = _messageInputTheme.inputDecoration; return InputDecoration( diff --git a/packages/stream_chat_flutter/lib/src/utils/typedefs.dart b/packages/stream_chat_flutter/lib/src/utils/typedefs.dart index b6e1af432..fda46b2dc 100644 --- a/packages/stream_chat_flutter/lib/src/utils/typedefs.dart +++ b/packages/stream_chat_flutter/lib/src/utils/typedefs.dart @@ -340,6 +340,11 @@ typedef DownloadedPathCallback = void Function(String? path); /// {@endtemplate} typedef UserTapCallback = void Function(User, Widget?); +/// {@template rawKeyEventPredicate} +/// Callback called to react to a raw key event +/// {@endtemplate} +typedef RawKeyEventPredicate = bool Function(FocusNode, RawKeyEvent); + /// {@template userItemBuilder} /// Builder used to create a custom [ListUserItem] from a [User] /// {@endtemplate} From 749b7144c350a7a1b3e38150f892a291354b586b Mon Sep 17 00:00:00 2001 From: Jeroen Leenarts Date: Tue, 6 Dec 2022 15:40:17 +0100 Subject: [PATCH 004/107] Add vale config --- .styles/Google/AMPM.yml | 9 ++ .styles/Google/Acronyms.yml | 64 +++++++++ .styles/Google/Colons.yml | 8 ++ .styles/Google/Contractions.yml | 30 +++++ .styles/Google/DateFormat.yml | 9 ++ .styles/Google/Ellipses.yml | 9 ++ .styles/Google/EmDash.yml | 12 ++ .styles/Google/EnDash.yml | 13 ++ .styles/Google/Exclamation.yml | 7 + .styles/Google/FirstPerson.yml | 13 ++ .styles/Google/Gender.yml | 9 ++ .styles/Google/GenderBias.yml | 45 +++++++ .styles/Google/HeadingPunctuation.yml | 13 ++ .styles/Google/Headings.yml | 29 ++++ .styles/Google/Latin.yml | 11 ++ .styles/Google/LyHyphens.yml | 14 ++ .styles/Google/OptionalPlurals.yml | 12 ++ .styles/Google/Ordinal.yml | 7 + .styles/Google/OxfordComma.yml | 7 + .styles/Google/Parens.yml | 7 + .styles/Google/Passive.yml | 184 ++++++++++++++++++++++++++ .styles/Google/Periods.yml | 7 + .styles/Google/Quotes.yml | 7 + .styles/Google/Ranges.yml | 7 + .styles/Google/Semicolons.yml | 8 ++ .styles/Google/Slang.yml | 11 ++ .styles/Google/Spacing.yml | 8 ++ .styles/Google/Spelling.yml | 8 ++ .styles/Google/Units.yml | 8 ++ .styles/Google/We.yml | 11 ++ .styles/Google/Will.yml | 7 + .styles/Google/WordList.yml | 80 +++++++++++ .styles/Google/meta.json | 4 + .styles/Google/vocab.txt | 0 .styles/Vocab/Base/accept.txt | 15 +++ .styles/Vocab/Base/reject.txt | 0 .vale.ini | 19 +++ 37 files changed, 712 insertions(+) create mode 100644 .styles/Google/AMPM.yml create mode 100644 .styles/Google/Acronyms.yml create mode 100644 .styles/Google/Colons.yml create mode 100644 .styles/Google/Contractions.yml create mode 100644 .styles/Google/DateFormat.yml create mode 100644 .styles/Google/Ellipses.yml create mode 100644 .styles/Google/EmDash.yml create mode 100644 .styles/Google/EnDash.yml create mode 100644 .styles/Google/Exclamation.yml create mode 100644 .styles/Google/FirstPerson.yml create mode 100644 .styles/Google/Gender.yml create mode 100644 .styles/Google/GenderBias.yml create mode 100644 .styles/Google/HeadingPunctuation.yml create mode 100644 .styles/Google/Headings.yml create mode 100644 .styles/Google/Latin.yml create mode 100644 .styles/Google/LyHyphens.yml create mode 100644 .styles/Google/OptionalPlurals.yml create mode 100644 .styles/Google/Ordinal.yml create mode 100644 .styles/Google/OxfordComma.yml create mode 100644 .styles/Google/Parens.yml create mode 100644 .styles/Google/Passive.yml create mode 100644 .styles/Google/Periods.yml create mode 100644 .styles/Google/Quotes.yml create mode 100644 .styles/Google/Ranges.yml create mode 100644 .styles/Google/Semicolons.yml create mode 100644 .styles/Google/Slang.yml create mode 100644 .styles/Google/Spacing.yml create mode 100644 .styles/Google/Spelling.yml create mode 100644 .styles/Google/Units.yml create mode 100644 .styles/Google/We.yml create mode 100644 .styles/Google/Will.yml create mode 100644 .styles/Google/WordList.yml create mode 100644 .styles/Google/meta.json create mode 100644 .styles/Google/vocab.txt create mode 100644 .styles/Vocab/Base/accept.txt create mode 100644 .styles/Vocab/Base/reject.txt create mode 100644 .vale.ini diff --git a/.styles/Google/AMPM.yml b/.styles/Google/AMPM.yml new file mode 100644 index 000000000..fbdc6e4f8 --- /dev/null +++ b/.styles/Google/AMPM.yml @@ -0,0 +1,9 @@ +extends: existence +message: "Use 'AM' or 'PM' (preceded by a space)." +link: 'https://developers.google.com/style/word-list' +level: error +nonword: true +tokens: + - '\d{1,2}[AP]M' + - '\d{1,2} ?[ap]m' + - '\d{1,2} ?[aApP]\.[mM]\.' diff --git a/.styles/Google/Acronyms.yml b/.styles/Google/Acronyms.yml new file mode 100644 index 000000000..f41af0189 --- /dev/null +++ b/.styles/Google/Acronyms.yml @@ -0,0 +1,64 @@ +extends: conditional +message: "Spell out '%s', if it's unfamiliar to the audience." +link: 'https://developers.google.com/style/abbreviations' +level: suggestion +ignorecase: false +# Ensures that the existence of 'first' implies the existence of 'second'. +first: '\b([A-Z]{3,5})\b' +second: '(?:\b[A-Z][a-z]+ )+\(([A-Z]{3,5})\)' +# ... with the exception of these: +exceptions: + - API + - ASP + - CLI + - CPU + - CSS + - CSV + - DEBUG + - DOM + - DPI + - FAQ + - GCC + - GDB + - GET + - GPU + - GTK + - GUI + - HTML + - HTTP + - HTTPS + - IDE + - JAR + - JSON + - JSX + - LESS + - LLDB + - NET + - NOTE + - NVDA + - OSS + - PATH + - PDF + - PHP + - POST + - RAM + - REPL + - RSA + - SCM + - SCSS + - SDK + - SQL + - SSH + - SSL + - SVG + - TBD + - TCP + - TODO + - URI + - URL + - USB + - UTF + - XML + - XSS + - YAML + - ZIP diff --git a/.styles/Google/Colons.yml b/.styles/Google/Colons.yml new file mode 100644 index 000000000..99363fbd4 --- /dev/null +++ b/.styles/Google/Colons.yml @@ -0,0 +1,8 @@ +extends: existence +message: "'%s' should be in lowercase." +link: 'https://developers.google.com/style/colons' +nonword: true +level: warning +scope: sentence +tokens: + - ':\s[A-Z]' diff --git a/.styles/Google/Contractions.yml b/.styles/Google/Contractions.yml new file mode 100644 index 000000000..95234987b --- /dev/null +++ b/.styles/Google/Contractions.yml @@ -0,0 +1,30 @@ +extends: substitution +message: "Feel free to use '%s' instead of '%s'." +link: 'https://developers.google.com/style/contractions' +level: suggestion +ignorecase: true +action: + name: replace +swap: + are not: aren't + cannot: can't + could not: couldn't + did not: didn't + do not: don't + does not: doesn't + has not: hasn't + have not: haven't + how is: how's + is not: isn't + it is: it's + should not: shouldn't + that is: that's + they are: they're + was not: wasn't + we are: we're + we have: we've + were not: weren't + what is: what's + when is: when's + where is: where's + will not: won't diff --git a/.styles/Google/DateFormat.yml b/.styles/Google/DateFormat.yml new file mode 100644 index 000000000..e9d227fa1 --- /dev/null +++ b/.styles/Google/DateFormat.yml @@ -0,0 +1,9 @@ +extends: existence +message: "Use 'July 31, 2016' format, not '%s'." +link: 'https://developers.google.com/style/dates-times' +ignorecase: true +level: error +nonword: true +tokens: + - '\d{1,2}(?:\.|/)\d{1,2}(?:\.|/)\d{4}' + - '\d{1,2} (?:Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)|May|Jun(?:e)|Jul(?:y)|Aug(?:ust)|Sep(?:tember)?|Oct(?:ober)|Nov(?:ember)?|Dec(?:ember)?) \d{4}' diff --git a/.styles/Google/Ellipses.yml b/.styles/Google/Ellipses.yml new file mode 100644 index 000000000..1e070517b --- /dev/null +++ b/.styles/Google/Ellipses.yml @@ -0,0 +1,9 @@ +extends: existence +message: "In general, don't use an ellipsis." +link: 'https://developers.google.com/style/ellipses' +nonword: true +level: warning +action: + name: remove +tokens: + - '\.\.\.' diff --git a/.styles/Google/EmDash.yml b/.styles/Google/EmDash.yml new file mode 100644 index 000000000..1befe72aa --- /dev/null +++ b/.styles/Google/EmDash.yml @@ -0,0 +1,12 @@ +extends: existence +message: "Don't put a space before or after a dash." +link: 'https://developers.google.com/style/dashes' +nonword: true +level: error +action: + name: edit + params: + - remove + - ' ' +tokens: + - '\s[—–]\s' diff --git a/.styles/Google/EnDash.yml b/.styles/Google/EnDash.yml new file mode 100644 index 000000000..b314dc4e9 --- /dev/null +++ b/.styles/Google/EnDash.yml @@ -0,0 +1,13 @@ +extends: existence +message: "Use an em dash ('—') instead of '–'." +link: 'https://developers.google.com/style/dashes' +nonword: true +level: error +action: + name: edit + params: + - replace + - '-' + - '—' +tokens: + - '–' diff --git a/.styles/Google/Exclamation.yml b/.styles/Google/Exclamation.yml new file mode 100644 index 000000000..3e15181b2 --- /dev/null +++ b/.styles/Google/Exclamation.yml @@ -0,0 +1,7 @@ +extends: existence +message: "Don't use exclamation points in text." +link: 'https://developers.google.com/style/exclamation-points' +nonword: true +level: error +tokens: + - '\w!(?:\s|$)' diff --git a/.styles/Google/FirstPerson.yml b/.styles/Google/FirstPerson.yml new file mode 100644 index 000000000..0b7b8828c --- /dev/null +++ b/.styles/Google/FirstPerson.yml @@ -0,0 +1,13 @@ +extends: existence +message: "Avoid first-person pronouns such as '%s'." +link: 'https://developers.google.com/style/pronouns#personal-pronouns' +ignorecase: true +level: warning +nonword: true +tokens: + - (?:^|\s)I\s + - (?:^|\s)I,\s + - \bI'm\b + - \bme\b + - \bmy\b + - \bmine\b diff --git a/.styles/Google/Gender.yml b/.styles/Google/Gender.yml new file mode 100644 index 000000000..c8486181d --- /dev/null +++ b/.styles/Google/Gender.yml @@ -0,0 +1,9 @@ +extends: existence +message: "Don't use '%s' as a gender-neutral pronoun." +link: 'https://developers.google.com/style/pronouns#gender-neutral-pronouns' +level: error +ignorecase: true +tokens: + - he/she + - s/he + - \(s\)he diff --git a/.styles/Google/GenderBias.yml b/.styles/Google/GenderBias.yml new file mode 100644 index 000000000..261cfb666 --- /dev/null +++ b/.styles/Google/GenderBias.yml @@ -0,0 +1,45 @@ +extends: substitution +message: "Consider using '%s' instead of '%s'." +link: 'https://developers.google.com/style/inclusive-documentation' +ignorecase: true +level: error +swap: + (?:alumna|alumnus): graduate + (?:alumnae|alumni): graduates + air(?:m[ae]n|wom[ae]n): pilot(s) + anchor(?:m[ae]n|wom[ae]n): anchor(s) + authoress: author + camera(?:m[ae]n|wom[ae]n): camera operator(s) + chair(?:m[ae]n|wom[ae]n): chair(s) + congress(?:m[ae]n|wom[ae]n): member(s) of congress + door(?:m[ae]|wom[ae]n): concierge(s) + draft(?:m[ae]n|wom[ae]n): drafter(s) + fire(?:m[ae]n|wom[ae]n): firefighter(s) + fisher(?:m[ae]n|wom[ae]n): fisher(s) + fresh(?:m[ae]n|wom[ae]n): first-year student(s) + garbage(?:m[ae]n|wom[ae]n): waste collector(s) + lady lawyer: lawyer + ladylike: courteous + landlord: building manager + mail(?:m[ae]n|wom[ae]n): mail carriers + man and wife: husband and wife + man enough: strong enough + mankind: human kind + manmade: manufactured + manpower: personnel + men and girls: men and women + middle(?:m[ae]n|wom[ae]n): intermediary + news(?:m[ae]n|wom[ae]n): journalist(s) + ombuds(?:man|woman): ombuds + oneupmanship: upstaging + poetess: poet + police(?:m[ae]n|wom[ae]n): police officer(s) + repair(?:m[ae]n|wom[ae]n): technician(s) + sales(?:m[ae]n|wom[ae]n): salesperson or sales people + service(?:m[ae]n|wom[ae]n): soldier(s) + steward(?:ess)?: flight attendant + tribes(?:m[ae]n|wom[ae]n): tribe member(s) + waitress: waiter + woman doctor: doctor + woman scientist[s]?: scientist(s) + work(?:m[ae]n|wom[ae]n): worker(s) diff --git a/.styles/Google/HeadingPunctuation.yml b/.styles/Google/HeadingPunctuation.yml new file mode 100644 index 000000000..b538be5b4 --- /dev/null +++ b/.styles/Google/HeadingPunctuation.yml @@ -0,0 +1,13 @@ +extends: existence +message: "Don't put a period at the end of a heading." +link: 'https://developers.google.com/style/capitalization#capitalization-in-titles-and-headings' +nonword: true +level: warning +scope: heading +action: + name: edit + params: + - remove + - '.' +tokens: + - '[a-z0-9][.]\s*$' diff --git a/.styles/Google/Headings.yml b/.styles/Google/Headings.yml new file mode 100644 index 000000000..a53301338 --- /dev/null +++ b/.styles/Google/Headings.yml @@ -0,0 +1,29 @@ +extends: capitalization +message: "'%s' should use sentence-style capitalization." +link: 'https://developers.google.com/style/capitalization#capitalization-in-titles-and-headings' +level: warning +scope: heading +match: $sentence +indicators: + - ':' +exceptions: + - Azure + - CLI + - Code + - Cosmos + - Docker + - Emmet + - gRPC + - I + - Kubernetes + - Linux + - macOS + - Marketplace + - MongoDB + - REPL + - Studio + - TypeScript + - URLs + - Visual + - VS + - Windows diff --git a/.styles/Google/Latin.yml b/.styles/Google/Latin.yml new file mode 100644 index 000000000..d91700de3 --- /dev/null +++ b/.styles/Google/Latin.yml @@ -0,0 +1,11 @@ +extends: substitution +message: "Use '%s' instead of '%s'." +link: 'https://developers.google.com/style/abbreviations' +ignorecase: true +level: error +nonword: true +action: + name: replace +swap: + '\b(?:eg|e\.g\.)[\s,]': for example + '\b(?:ie|i\.e\.)[\s,]': that is diff --git a/.styles/Google/LyHyphens.yml b/.styles/Google/LyHyphens.yml new file mode 100644 index 000000000..ac8f557a4 --- /dev/null +++ b/.styles/Google/LyHyphens.yml @@ -0,0 +1,14 @@ +extends: existence +message: "'%s' doesn't need a hyphen." +link: 'https://developers.google.com/style/hyphens' +level: error +ignorecase: false +nonword: true +action: + name: edit + params: + - replace + - '-' + - ' ' +tokens: + - '\s[^\s-]+ly-' diff --git a/.styles/Google/OptionalPlurals.yml b/.styles/Google/OptionalPlurals.yml new file mode 100644 index 000000000..f858ea6fe --- /dev/null +++ b/.styles/Google/OptionalPlurals.yml @@ -0,0 +1,12 @@ +extends: existence +message: "Don't use plurals in parentheses such as in '%s'." +link: 'https://developers.google.com/style/plurals-parentheses' +level: error +nonword: true +action: + name: edit + params: + - remove + - '(s)' +tokens: + - '\b\w+\(s\)' diff --git a/.styles/Google/Ordinal.yml b/.styles/Google/Ordinal.yml new file mode 100644 index 000000000..d1ac7d27e --- /dev/null +++ b/.styles/Google/Ordinal.yml @@ -0,0 +1,7 @@ +extends: existence +message: "Spell out all ordinal numbers ('%s') in text." +link: 'https://developers.google.com/style/numbers' +level: error +nonword: true +tokens: + - \d+(?:st|nd|rd|th) diff --git a/.styles/Google/OxfordComma.yml b/.styles/Google/OxfordComma.yml new file mode 100644 index 000000000..b9ba21ebb --- /dev/null +++ b/.styles/Google/OxfordComma.yml @@ -0,0 +1,7 @@ +extends: existence +message: "Use the Oxford comma in '%s'." +link: 'https://developers.google.com/style/commas' +scope: sentence +level: warning +tokens: + - '(?:[^,]+,){1,}\s\w+\s(?:and|or)' diff --git a/.styles/Google/Parens.yml b/.styles/Google/Parens.yml new file mode 100644 index 000000000..3b8711d0c --- /dev/null +++ b/.styles/Google/Parens.yml @@ -0,0 +1,7 @@ +extends: existence +message: "Use parentheses judiciously." +link: 'https://developers.google.com/style/parentheses' +nonword: true +level: suggestion +tokens: + - '\(.+\)' diff --git a/.styles/Google/Passive.yml b/.styles/Google/Passive.yml new file mode 100644 index 000000000..3265890e5 --- /dev/null +++ b/.styles/Google/Passive.yml @@ -0,0 +1,184 @@ +extends: existence +link: 'https://developers.google.com/style/voice' +message: "In general, use active voice instead of passive voice ('%s')." +ignorecase: true +level: suggestion +raw: + - \b(am|are|were|being|is|been|was|be)\b\s* +tokens: + - '[\w]+ed' + - awoken + - beat + - become + - been + - begun + - bent + - beset + - bet + - bid + - bidden + - bitten + - bled + - blown + - born + - bought + - bound + - bred + - broadcast + - broken + - brought + - built + - burnt + - burst + - cast + - caught + - chosen + - clung + - come + - cost + - crept + - cut + - dealt + - dived + - done + - drawn + - dreamt + - driven + - drunk + - dug + - eaten + - fallen + - fed + - felt + - fit + - fled + - flown + - flung + - forbidden + - foregone + - forgiven + - forgotten + - forsaken + - fought + - found + - frozen + - given + - gone + - gotten + - ground + - grown + - heard + - held + - hidden + - hit + - hung + - hurt + - kept + - knelt + - knit + - known + - laid + - lain + - leapt + - learnt + - led + - left + - lent + - let + - lighted + - lost + - made + - meant + - met + - misspelt + - mistaken + - mown + - overcome + - overdone + - overtaken + - overthrown + - paid + - pled + - proven + - put + - quit + - read + - rid + - ridden + - risen + - run + - rung + - said + - sat + - sawn + - seen + - sent + - set + - sewn + - shaken + - shaven + - shed + - shod + - shone + - shorn + - shot + - shown + - shrunk + - shut + - slain + - slept + - slid + - slit + - slung + - smitten + - sold + - sought + - sown + - sped + - spent + - spilt + - spit + - split + - spoken + - spread + - sprung + - spun + - stolen + - stood + - stridden + - striven + - struck + - strung + - stuck + - stung + - stunk + - sung + - sunk + - swept + - swollen + - sworn + - swum + - swung + - taken + - taught + - thought + - thrived + - thrown + - thrust + - told + - torn + - trodden + - understood + - upheld + - upset + - wed + - wept + - withheld + - withstood + - woken + - won + - worn + - wound + - woven + - written + - wrung diff --git a/.styles/Google/Periods.yml b/.styles/Google/Periods.yml new file mode 100644 index 000000000..d24a6a6c0 --- /dev/null +++ b/.styles/Google/Periods.yml @@ -0,0 +1,7 @@ +extends: existence +message: "Don't use periods with acronyms or initialisms such as '%s'." +link: 'https://developers.google.com/style/abbreviations' +level: error +nonword: true +tokens: + - '\b(?:[A-Z]\.){3,}' diff --git a/.styles/Google/Quotes.yml b/.styles/Google/Quotes.yml new file mode 100644 index 000000000..3cb6f1abd --- /dev/null +++ b/.styles/Google/Quotes.yml @@ -0,0 +1,7 @@ +extends: existence +message: "Commas and periods go inside quotation marks." +link: 'https://developers.google.com/style/quotation-marks' +level: error +nonword: true +tokens: + - '"[^"]+"[.,?]' diff --git a/.styles/Google/Ranges.yml b/.styles/Google/Ranges.yml new file mode 100644 index 000000000..3ec045e77 --- /dev/null +++ b/.styles/Google/Ranges.yml @@ -0,0 +1,7 @@ +extends: existence +message: "Don't add words such as 'from' or 'between' to describe a range of numbers." +link: 'https://developers.google.com/style/hyphens' +nonword: true +level: warning +tokens: + - '(?:from|between)\s\d+\s?-\s?\d+' diff --git a/.styles/Google/Semicolons.yml b/.styles/Google/Semicolons.yml new file mode 100644 index 000000000..bb8b85b42 --- /dev/null +++ b/.styles/Google/Semicolons.yml @@ -0,0 +1,8 @@ +extends: existence +message: "Use semicolons judiciously." +link: 'https://developers.google.com/style/semicolons' +nonword: true +scope: sentence +level: suggestion +tokens: + - ';' diff --git a/.styles/Google/Slang.yml b/.styles/Google/Slang.yml new file mode 100644 index 000000000..63f4c248a --- /dev/null +++ b/.styles/Google/Slang.yml @@ -0,0 +1,11 @@ +extends: existence +message: "Don't use internet slang abbreviations such as '%s'." +link: 'https://developers.google.com/style/abbreviations' +ignorecase: true +level: error +tokens: + - 'tl;dr' + - ymmv + - rtfm + - imo + - fwiw diff --git a/.styles/Google/Spacing.yml b/.styles/Google/Spacing.yml new file mode 100644 index 000000000..27f7ca2bd --- /dev/null +++ b/.styles/Google/Spacing.yml @@ -0,0 +1,8 @@ +extends: existence +message: "'%s' should have one space." +link: 'https://developers.google.com/style/sentence-spacing' +level: error +nonword: true +tokens: + - '[a-z][.?!] {2,}[A-Z]' + - '[a-z][.?!][A-Z]' diff --git a/.styles/Google/Spelling.yml b/.styles/Google/Spelling.yml new file mode 100644 index 000000000..57acb8841 --- /dev/null +++ b/.styles/Google/Spelling.yml @@ -0,0 +1,8 @@ +extends: existence +message: "In general, use American spelling instead of '%s'." +link: 'https://developers.google.com/style/spelling' +ignorecase: true +level: warning +tokens: + - '(?:\w+)nised?' + - '(?:\w+)logue' diff --git a/.styles/Google/Units.yml b/.styles/Google/Units.yml new file mode 100644 index 000000000..379fad6b8 --- /dev/null +++ b/.styles/Google/Units.yml @@ -0,0 +1,8 @@ +extends: existence +message: "Put a nonbreaking space between the number and the unit in '%s'." +link: 'https://developers.google.com/style/units-of-measure' +nonword: true +level: error +tokens: + - \d+(?:B|kB|MB|GB|TB) + - \d+(?:ns|ms|s|min|h|d) diff --git a/.styles/Google/We.yml b/.styles/Google/We.yml new file mode 100644 index 000000000..c7ac7d362 --- /dev/null +++ b/.styles/Google/We.yml @@ -0,0 +1,11 @@ +extends: existence +message: "Try to avoid using first-person plural like '%s'." +link: 'https://developers.google.com/style/pronouns#personal-pronouns' +level: warning +ignorecase: true +tokens: + - we + - we'(?:ve|re) + - ours? + - us + - let's diff --git a/.styles/Google/Will.yml b/.styles/Google/Will.yml new file mode 100644 index 000000000..128a91836 --- /dev/null +++ b/.styles/Google/Will.yml @@ -0,0 +1,7 @@ +extends: existence +message: "Avoid using '%s'." +link: 'https://developers.google.com/style/tense' +ignorecase: true +level: warning +tokens: + - will diff --git a/.styles/Google/WordList.yml b/.styles/Google/WordList.yml new file mode 100644 index 000000000..bb711517e --- /dev/null +++ b/.styles/Google/WordList.yml @@ -0,0 +1,80 @@ +extends: substitution +message: "Use '%s' instead of '%s'." +link: 'https://developers.google.com/style/word-list' +level: warning +ignorecase: false +action: + name: replace +swap: + '(?:API Console|dev|developer) key': API key + '(?:cell ?phone|smart ?phone)': phone|mobile phone + '(?:dev|developer|APIs) console': API console + '(?:e-mail|Email|E-mail)': email + '(?:file ?path|path ?name)': path + '(?:kill|terminate|abort)': stop|exit|cancel|end + '(?:OAuth ?2|Oauth)': OAuth 2.0 + '(?:ok|Okay)': OK|okay + '(?:WiFi|wifi)': Wi-Fi + '[\.]+apk': APK + '3\-D': 3D + 'Google (?:I\-O|IO)': Google I/O + 'tap (?:&|and) hold': touch & hold + 'un(?:check|select)': clear + above: preceding + account name: username + action bar: app bar + admin: administrator + Ajax: AJAX + Android device: Android-powered device + android: Android + API explorer: APIs Explorer + application: app + approx\.: approximately + authN: authentication + authZ: authorization + autoupdate: automatically update + cellular data: mobile data + cellular network: mobile network + chapter: documents|pages|sections + check box: checkbox + check: select + CLI: command-line tool + click on: click|click in + Cloud: Google Cloud Platform|GCP + Container Engine: Kubernetes Engine + content type: media type + curated roles: predefined roles + data are: data is + Developers Console: Google API Console|API Console + disabled?: turn off|off + ephemeral IP address: ephemeral external IP address + fewer data: less data + file name: filename + firewalls: firewall rules + functionality: capability|feature + Google account: Google Account + Google accounts: Google Accounts + Googling: search with Google + grayed-out: unavailable + HTTPs: HTTPS + in order to: to + ingest: import|load + k8s: Kubernetes + long press: touch & hold + network IP address: internal IP address + omnibox: address bar + open-source: open source + overview screen: recents screen + regex: regular expression + SHA1: SHA-1|HAS-SHA1 + sign into: sign in to + sign-?on: single sign-on + static IP address: static external IP address + stylesheet: style sheet + synch: sync + tablename: table name + tablet: device + touch: tap + url: URL + vs\.: versus + World Wide Web: web diff --git a/.styles/Google/meta.json b/.styles/Google/meta.json new file mode 100644 index 000000000..a5da2a848 --- /dev/null +++ b/.styles/Google/meta.json @@ -0,0 +1,4 @@ +{ + "feed": "https://github.com/errata-ai/Google/releases.atom", + "vale_version": ">=1.0.0" +} diff --git a/.styles/Google/vocab.txt b/.styles/Google/vocab.txt new file mode 100644 index 000000000..e69de29bb diff --git a/.styles/Vocab/Base/accept.txt b/.styles/Vocab/Base/accept.txt new file mode 100644 index 000000000..bc7aba922 --- /dev/null +++ b/.styles/Vocab/Base/accept.txt @@ -0,0 +1,15 @@ +API +SDK +Crashlytics +Rollbar +APIs +boolean +Giphy +DM +UI +[Ss]lidable +discoverability +[Ll]ivestream +monorepo +Melos +uploader \ No newline at end of file diff --git a/.styles/Vocab/Base/reject.txt b/.styles/Vocab/Base/reject.txt new file mode 100644 index 000000000..e69de29bb diff --git a/.vale.ini b/.vale.ini new file mode 100644 index 000000000..5e1c46bf7 --- /dev/null +++ b/.vale.ini @@ -0,0 +1,19 @@ +StylesPath = .styles + +MinAlertLevel = error +Vocab = Base + +Packages = Google + +# The "formats" section allows you to associate an "unknown" format +# with one of Vale's supported formats. +[formats] +mdx = md + +# Since we mapped `mdx` to `md` in the `formats`section we have to declare our format to be `md` +[*.md] +BasedOnStyles = Vale, Google +# TokenIgnores = ("integrationguide"), ^<[ ]{0}img(.*)+[ ]{0}/>$, <[ ]{0}img(.*\n)+/> +# BlockIgnores = import \w* from '.*', \w*\.gradle + + From dbbb2f26becdb5a1a92424fbe71b67d57365406b Mon Sep 17 00:00:00 2001 From: Jeroen Leenarts Date: Tue, 6 Dec 2022 15:40:29 +0100 Subject: [PATCH 005/107] Add GitHub Action workflow file --- .github/workflows/vale-doc-lint.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .github/workflows/vale-doc-lint.yml diff --git a/.github/workflows/vale-doc-lint.yml b/.github/workflows/vale-doc-lint.yml new file mode 100644 index 000000000..2ef15f471 --- /dev/null +++ b/.github/workflows/vale-doc-lint.yml @@ -0,0 +1,22 @@ +name: Check Docusaurus docs with Vale linter + +on: [pull_request] + +jobs: + vale: + name: Vale doc linter + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: errata-ai/vale-action@reviewdog + with: + # added, diff_context, file, nofilter + filter_mode: nofilter + # github-pr-check, github-pr-review, github-check + reporter: github-pr-check + fail_on_error: true + files: docusaurus + env: + # Required, set by GitHub actions automatically: + # https://docs.github.com/en/actions/security-guides/automatic-token-authentication#about-the-github_token-secret + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} From a338b9b95f652a37ed3e0933d7f7360f0aebc712 Mon Sep 17 00:00:00 2001 From: Jeroen Leenarts Date: Tue, 6 Dec 2022 15:41:05 +0100 Subject: [PATCH 006/107] Fix a couple Vale linter warnings --- CONTRIBUTING.md | 30 +++++++++---------- README.md | 16 +++++----- .../docs/Flutter/01-basics/choose_package.mdx | 16 +++++----- .../docs/Flutter/01-basics/introduction.mdx | 18 +++++------ .../Flutter/01-basics/versioning_policy.mdx | 2 +- .../03-customize_message_actions.mdx | 2 +- .../04-adding_custom_attachments.mdx | 6 ++-- .../06-autocomplete_triggers.mdx | 2 +- .../07-slidable_channel_list_preview.mdx | 2 +- .../Flutter/03-stream_chat_flutter/setup.mdx | 8 ++--- .../stream_channel_list_header.mdx | 2 +- .../message_list_core.mdx | 2 +- .../stream_chat_core.mdx | 2 +- .../05-guides/01-understanding_filters.mdx | 10 +++---- .../02-adding_local_data_persistence.mdx | 2 +- ...er_token_generation_with_firebase_auth.mdx | 14 ++++----- .../adding_push_notifications.mdx | 18 +++++------ .../adding_push_notifications_v2.mdx | 20 ++++++------- .../06-end_to_end_chat_encryption.mdx | 10 +++---- .../08-migrations/migration_guide_4_0.mdx | 14 ++++----- .../08-migrations/migration_guide_5_0.mdx | 12 ++++---- .../09-initialize_stream_chat_widget_tree.mdx | 10 +++---- .../Flutter/basics/choose_package.mdx | 16 +++++----- .../Flutter/basics/introduction.mdx | 18 +++++------ .../Flutter/basics/versioning_policy.mdx | 2 +- .../guides/adding_custom_attachments.mdx | 6 ++-- .../guides/adding_local_data_persistence.mdx | 2 +- .../guides/adding_push_notifications.mdx | 18 +++++------ .../guides/adding_push_notifications_v2.mdx | 18 +++++------ .../guides/customize_message_actions.mdx | 2 +- .../guides/end_to_end_chat_encryption.mdx | 10 +++---- .../Flutter/guides/migration_guide_2_0.mdx | 26 ++++++++-------- .../Flutter/guides/understanding_filters.mdx | 10 +++---- ...er_token_generation_with_firebase_auth.mdx | 14 ++++----- .../channel_list_header.mdx | 2 +- .../stream_chat_flutter/channel_list_view.mdx | 6 ++-- .../Flutter/stream_chat_flutter/setup.mdx | 4 +-- .../channel_list_core.mdx | 2 +- .../message_list_core.mdx | 2 +- .../message_search_list_core.mdx | 2 +- .../stream_chat_core.mdx | 2 +- .../user_list_core.mdx | 2 +- .../Flutter/basics/choose_package.mdx | 16 +++++----- .../Flutter/basics/introduction.mdx | 18 +++++------ .../Flutter/basics/versioning_policy.mdx | 2 +- .../guides/adding_custom_attachments.mdx | 6 ++-- .../guides/adding_local_data_persistence.mdx | 2 +- .../guides/adding_push_notifications.mdx | 18 +++++------ .../guides/adding_push_notifications_v2.mdx | 20 ++++++------- .../Flutter/guides/autocomplete_triggers.mdx | 2 +- .../guides/customize_message_actions.mdx | 2 +- .../guides/end_to_end_chat_encryption.mdx | 10 +++---- .../Flutter/guides/migration_guide_4_0.mdx | 14 ++++----- .../guides/slidable_channel_list_preview.mdx | 2 +- .../Flutter/guides/understanding_filters.mdx | 10 +++---- ...er_token_generation_with_firebase_auth.mdx | 14 ++++----- .../Flutter/stream_chat_flutter/setup.mdx | 4 +-- .../stream_channel_list_header.mdx | 2 +- .../message_list_core.mdx | 2 +- .../stream_chat_core.mdx | 2 +- packages/stream_chat/.gitignore | 2 +- packages/stream_chat/CHANGELOG.md | 26 ++++++++-------- packages/stream_chat/README.md | 12 ++++---- packages/stream_chat_flutter/.gitignore | 2 +- packages/stream_chat_flutter/CHANGELOG.md | 16 +++++----- packages/stream_chat_flutter/README.md | 18 +++++------ .../example/lib/tutorial_part_1.dart | 2 +- 67 files changed, 303 insertions(+), 303 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 385b6085f..279e3bc4e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,4 +1,4 @@ -Welcome to Stream’s Flutter repository! Thank you for taking the time to contribute to our codebase. 🎉. +Welcome to Stream’s Flutter repository. Thank you for taking the time to contribute to our codebase. 🎉. This document outlines a set of guidelines for contributing to Stream and our packages. These are mostly guidelines, not necessarily a fixed set of rules. Please use your best judgment and feel free to propose changes to this document in a pull request. @@ -26,7 +26,7 @@ Stream's Flutter code is kept in a single mono-repository consisting of multiple ### Project Structure 🧱 -`.github` - GitHub files including issue templates, pull request templates, and Github Action scripts. +`.github` - GitHub files including issue templates, pull request templates, and GitHub Action scripts. `images` - Static images used in our README and elsewhere. @@ -56,11 +56,11 @@ Stream's Flutter code is kept in a single mono-repository consisting of multiple ### Local Setup -Congratulations! 🎉. You've successfully cloned our repo, and you are ready to make your first contribution. Before you can start making code changes, there are a few things to configure. +Congratulations. 🎉. You've successfully cloned our repository, and you are ready to make your first contribution. Before you can start making code changes, there are a few things to configure. **Melos Setup** -Stream uses `melos` to manage our mono-repository. For those unfamiliar, Melos is used to split up large code bases into separate independently versioned packages. To install melos, developers can run the following command: +Stream uses `Melos` to manage our mono-repository. For those unfamiliar, Melos is used to split up large code bases into separate independently versioned packages. To install Melos, developers can run the following command: ```bash pub global activate melos @@ -72,7 +72,7 @@ Once activated, users can now "bootstrap" their local clone by running the follo melos bootstrap ``` -Bootstrap will automatically fetch and link dependencies for all packages in the repo. It is the melos equivalent of running `flutter pub get`. +Bootstrap will automatically fetch and link dependencies for all packages in the repository. It is the Melos equivalent of running `flutter pub get`. Bonus Tip: Did you know it is possible to define and run custom scripts using Melos? Our team uses custom scripts for all sorts of actions like testing, lints, and more. @@ -88,7 +88,7 @@ Are you ready to dive into code? It's pretty easy to get up and running with you Before filing bugs, take a look at our existing backlog. For common bugs, there might be an existing ticket on GitHub. -To quickly narrow down the amount of tickets on Github, try filtering based on the label that best suites the bug. +To quickly narrow down the amount of tickets on GitHub, try filtering based on the label that best suites the bug. ![image](https://user-images.githubusercontent.com/20601437/124240983-9d9f6100-db1b-11eb-952f-3c0cc60a910e.png) @@ -98,17 +98,17 @@ Didn't find an existing issue? Go ahead and file a new bug using one of our pre- Be sure to provide as much information as possible when filing bug reports. A good issue should have steps to reproduce and information on your development environment and expected behavior. -Screenshots and gifs are always welcomed :) +Screenshots and GIFs are always welcomed :) ## Feature Request 💡 -Have an idea for a new feature? We would love to hear about it! +Have an idea for a new feature? We would love to hear about it. Our team uses GitHub discussions to triage and discuss feature requests. Before opening a new topic, please check our existing issues and pull requests to ensure the feature you are suggesting is not already in progress. -To file a feature request, select the "Discussions" tab on our GitHub repo or [visit this link](https://github.com/GetStream/stream-chat-flutter/discussions/new). Once there, change the default category to "**💡 Ideas**", then write a brief description of your feature/change. +To file a feature request, select the "Discussions" tab on our GitHub repository or [visit this link](https://github.com/GetStream/stream-chat-flutter/discussions/new). Once there, change the default category to "**💡 Ideas**", then write a brief description of your feature/change. -Screenshots, sketches, and sample code are all welcomed! +Screenshots, sketches, and sample code are all welcomed. ![image](https://user-images.githubusercontent.com/20601437/124241092-bc055c80-db1b-11eb-9205-7e3d7c157af1.png) @@ -134,13 +134,13 @@ Add any other context or screenshots about the feature request here. ![image](https://user-images.githubusercontent.com/20601437/124241146-c7f11e80-db1b-11eb-9588-d9f578ec004a.png) -Thank you for taking the time to submit a patch and contribute to our codebase. You rock! +Thank you for taking the time to submit a patch and contribute to our codebase. You rock. Before we can land your pull request, please don't forget to [sign Stream's CLA (Contributor License Agreement](https://docs.google.com/forms/d/e/1FAIpQLScFKsKkAJI7mhCr7K9rEIOpqIDThrWxuvxnwUq2XkHyG154vQ/viewform). 📝 ### PR Semantics 🦄 -Our team uses [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) when coding and creating PRs. This standard makes it easy for our team to review and identify commits in our repo quickly. +Our team uses [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) when coding and creating PRs. This standard makes it easy for our team to review and identify commits in our repository quickly. While we don't expect developers to follow the specification down to every commit message, we enforce semantics on PR titles. @@ -162,7 +162,7 @@ PR titles should follow the format below: ### Testing -At Stream, we value testing. Every PR should include passing tests for existing and new features. To run our test suite locally, you can use the following *melos* command: +At Stream, we value testing. Every PR should include passing tests for existing and new features. To run our test suite locally, you can use the following *Melos* command: ```bash > melos run test:dart @@ -173,13 +173,13 @@ At Stream, we value testing. Every PR should include passing tests for existing By default, our development branch is `develop`. Contributors should create new PRs based on `develop` when working on new features. -Develop is merged into master after the team performs various automated and QA tests on the branch. Master can be considered our stable branch — it represents the latest published release on pub.dev. +Develop is merged into master after the team performs various automated and QA tests on the branch. Master can be considered our stable branch, it represents the latest published release on pub.dev. --- # Versioning Policy -All of the Stream Chat packages follow [semantic versioning (semver)](https://semver.org/). +All of the Stream Chat packages follow [semantic versioning](https://semver.org/). See our [versioning policy documentation](https://getstream.io/chat/docs/sdk/flutter/basics/versioning_policy/) for more information. diff --git a/README.md b/README.md index 5d78e7bf4..051b8a4e4 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ ![](https://raw.githubusercontent.com/GetStream/stream-chat-flutter/master/images/sdk_hero_v4.png) ![CI](https://github.com/GetStream/stream-chat-flutter/workflows/stream_flutter_workflow/badge.svg?branch=master) -[![melos](https://img.shields.io/badge/maintained%20with-melos-f700ff.svg?style=flat-square)](https://github.com/invertase/melos) +[![Melos](https://img.shields.io/badge/maintained%20with-melos-f700ff.svg?style=flat-square)](https://github.com/invertase/melos) **Quick Links** @@ -21,7 +21,7 @@ Stream allows developers to rapidly deploy scalable feeds and chat messaging wit For upgrading from V3 to V4, please refer to the [V4 Migration Guide](https://getstream.io/chat/docs/sdk/flutter/guides/migration_guide_4_0/) ## Sample apps and demos -Our team maintains a dedicated repository for fully-fledged sample applications and demos. Consider checking out [GetStream/flutter-samples](https://github.com/GetStream/flutter-samples) to learn more or get started by looking at our latest [Stream Chat demo](https://github.com/GetStream/flutter-samples/tree/main/packages/stream_chat_v1). +Our team maintains a dedicated repository for full fledged sample applications and demos. Consider checking out [GetStream/flutter-samples](https://github.com/GetStream/flutter-samples) to learn more or get started by looking at our latest [Stream Chat demo](https://github.com/GetStream/flutter-samples/tree/main/packages/stream_chat_v1). ## Free for Makers @@ -40,19 +40,19 @@ melos bootstrap ## Packages We provide a variety of packages depending on the level of customization you want to achieve. -### [stream_chat](https://github.com/GetStream/stream-chat-flutter/tree/master/packages/stream_chat) +### [`stream_chat`](https://github.com/GetStream/stream-chat-flutter/tree/master/packages/stream_chat) A pure Dart package that can be used on any Dart project. It provides a low-level client to access the Stream Chat service. -### [stream_chat_persistence](https://github.com/GetStream/stream-chat-flutter/tree/master/packages/stream_chat_persistence) +### [`stream_chat_persistence`](https://github.com/GetStream/stream-chat-flutter/tree/master/packages/stream_chat_persistence) This package provides a persistence client for fetching and saving chat data locally. Stream Chat Persistence uses Moor as a disk cache. -### [stream_chat_flutter_core](https://github.com/GetStream/stream-chat-flutter/tree/master/packages/stream_chat_flutter_core) +### [`stream_chat_flutter_core`](https://github.com/GetStream/stream-chat-flutter/tree/master/packages/stream_chat_flutter_core) This package provides business logic to fetch common things required for integrating Stream Chat into your application. The `core` package allows more customisation and hence provides business logic but no UI components. -### [stream_chat_flutter](https://github.com/GetStream/stream-chat-flutter/tree/master/packages/stream_chat_flutter) +### [`stream_chat_flutter`](https://github.com/GetStream/stream-chat-flutter/tree/master/packages/stream_chat_flutter) This library includes both a low-level chat SDK and a set of reusable and customizable UI components. -### [stream_chat_localizations](https://github.com/GetStream/stream-chat-flutter/tree/master/packages/stream_chat_localizations) +### [`stream_chat_localizations`](https://github.com/GetStream/stream-chat-flutter/tree/master/packages/stream_chat_localizations) This library includes a set of localization files for the Flutter UI components. ## Flutter Chat Tutorial @@ -68,7 +68,7 @@ We also provide a set of sample apps created using the Stream Flutter SDK at [th ## Versioning Policy -All of the Stream Chat packages follow [semantic versioning (semver)](https://semver.org/). +All of the Stream Chat packages follow [semantic versioning](https://semver.org/). See our [versioning policy documentation](https://getstream.io/chat/docs/sdk/flutter/basics/versioning_policy/) for more information. diff --git a/docusaurus/docs/Flutter/01-basics/choose_package.mdx b/docusaurus/docs/Flutter/01-basics/choose_package.mdx index cd311b631..104b9381b 100644 --- a/docusaurus/docs/Flutter/01-basics/choose_package.mdx +++ b/docusaurus/docs/Flutter/01-basics/choose_package.mdx @@ -16,7 +16,7 @@ which allows you persist data locally which works with all packages. ### How do I choose? -#### The case for stream_chat_flutter +#### The case for `stream_chat_flutter` For the quickest way to integrate Stream Chat with your app, the UI SDK (`stream_chat_flutter`) is the way to go. `stream_chat_flutter` contains prebuilt components that manage most operations like data @@ -32,26 +32,26 @@ to request this through our support channels. Summary: -For the quickest and easiest way to add Chat to your app with prebuilt UI components, use stream_chat_flutter +For the quickest and easiest way to add Chat to your app with prebuilt UI components, use `stream_chat_flutter` -#### The case for stream_chat_flutter_core +#### The case for `stream_chat_flutter_core` -If your application involves UI that does not fit in with the stream_chat_flutter components, stream_chat_flutter_core +If your application involves UI that does not fit in with the `stream_chat_flutter` components, `stream_chat_flutter_core` strips away the UI associated with the components and provides the data fetching and manipulation capabilities while supplying builders for UI. This allows you to implement your own UI and themes completely independently while not worrying about writing functions for data and pagination. Summary: -For implementing your own custom UI while not having to worry about lower level API calls, use stream_chat_flutter_core. +For implementing your own custom UI while not having to worry about lower level API calls, use `stream_chat_flutter_core`. -#### The case for stream_chat +#### The case for `stream_chat` -The stream_chat package is the Low-level Client (LLC) of Stream Chat in Flutter. This package wraps +The `stream_chat` package is the Low-level Client (LLC) of Stream Chat in Flutter. This package wraps the underlying functionality of Stream Chat and allows the most customization in terms of UI, data, and architecture. Summary: -For the most control over the SDK and dealing with low level calls to the API, use stream_chat. +For the most control over the SDK and dealing with low level calls to the API, use `stream_chat`. diff --git a/docusaurus/docs/Flutter/01-basics/introduction.mdx b/docusaurus/docs/Flutter/01-basics/introduction.mdx index 93f0572df..02487dabb 100644 --- a/docusaurus/docs/Flutter/01-basics/introduction.mdx +++ b/docusaurus/docs/Flutter/01-basics/introduction.mdx @@ -20,18 +20,18 @@ giving you complete control to ones that give you a rich out-of-the-box chat exp The packages that make up the Stream Chat SDK are: -1. Low Level Client (stream_chat): a pure Dart package that can be used on any Dart project. +1. Low Level Client (`stream_chat`): a pure Dart package that can be used on any Dart project. It provides a low-level client to access the Stream Chat service. -2. Core (stream_chat_flutter_core): provides business logic to fetch common things required +2. Core (`stream_chat_flutter_core`): provides business logic to fetch common things required for integrating Stream Chat into your application. The core package allows more customisation and hence provides business logic but no UI components. -3. UI (stream_chat_flutter): this library includes both a low-level chat SDK and a set of -reusable and customisable UI components. -4. Persistence (stream_chat_persistence): provides a persistence client for fetching and +3. UI (`stream_chat_flutter`): this library includes both a low-level chat SDK and a set of +reusable and customizable UI components. +4. Persistence (`stream_chat_persistence`): provides a persistence client for fetching and saving chat data locally. -5. Localizations (stream_chat_localizations): provides a set of localizations for the SDK. +5. Localizations (`stream_chat_localizations`): provides a set of localizations for the SDK. -We recommend building prototypes using the full UI package, [stream_chat_flutter](https://pub.dev/packages/stream_chat_flutter), +We recommend building prototypes using the full UI package, [`stream_chat_flutter`](https://pub.dev/packages/stream_chat_flutter), since it contains UI widgets already integrated with Stream's API. It is the fastest way to get up and running using Stream chat in your app. @@ -39,7 +39,7 @@ The Flutter SDK enables you to build any type of chat or messaging experience fo and Desktop. If you're building a very custom UI and would prefer a more lean package, -[stream_chat_flutter_core](https://pub.dev/packages/stream_chat_flutter_core) will be suited to this +[`stream_chat_flutter_core`](https://pub.dev/packages/stream_chat_flutter_core) will be suited to this use case. Core allows you to build custom, expressive UIs while retaining the benefits of our full Flutter SDK. APIs for accessing and controlling users, sending messages, and so forth are seamlessly integrated into this package and accessible via providers and builders. @@ -69,7 +69,7 @@ While this is a simplistic overview of the service, the Flutter SDK handles the Before reading the docs, consider trying our [online API tour](https://getstream.io/chat/get_started/), it is a nice way to learn how the API works. -It's in-browser so you'll need to use Javascript but the core conceps are pretty much the same as Dart. +It's in-browser so you'll need to use JavaScript but the core concepts are pretty much the same as Dart. You may also like to look at the [Flutter tutorial](https://getstream.io/chat/flutter/tutorial/) which focuses on using the UI package to get Stream Chat integrated into a Flutter app. diff --git a/docusaurus/docs/Flutter/01-basics/versioning_policy.mdx b/docusaurus/docs/Flutter/01-basics/versioning_policy.mdx index 48f25d66b..99ec8111d 100644 --- a/docusaurus/docs/Flutter/01-basics/versioning_policy.mdx +++ b/docusaurus/docs/Flutter/01-basics/versioning_policy.mdx @@ -4,7 +4,7 @@ sidebar_position: 3 title: Versioning Policy --- -All of the Stream Chat packages follow [semantic versioning (semver)](https://semver.org/). +All of the Stream Chat packages follow [semantic versioning](https://semver.org/). That means that with a version number x.y.z (major.minor.patch): - When releasing bug fixes (backwards compatible), we make a patch release by changing the z number (ex: 3.6.2 to 3.6.3). A bug fix is defined as an internal change that fixes incorrect behavior. diff --git a/docusaurus/docs/Flutter/02-customization/01-custom-widgets/03-customize_message_actions.mdx b/docusaurus/docs/Flutter/02-customization/01-custom-widgets/03-customize_message_actions.mdx index 31e2b9d5a..966a996d4 100644 --- a/docusaurus/docs/Flutter/02-customization/01-custom-widgets/03-customize_message_actions.mdx +++ b/docusaurus/docs/Flutter/02-customization/01-custom-widgets/03-customize_message_actions.mdx @@ -36,7 +36,7 @@ Additionally, pinning a message requires you to add the roles which are allowed ### Partially remove some message actions -For example, if you only want to keep "copy message" and "delete message", +For example, if you only want to keep "copy message" and "delete message": here is how to do it using the `messageBuilder` with our `StreamMessageWidget`. ```dart diff --git a/docusaurus/docs/Flutter/02-customization/01-custom-widgets/04-adding_custom_attachments.mdx b/docusaurus/docs/Flutter/02-customization/01-custom-widgets/04-adding_custom_attachments.mdx index 089dd3e61..03f9f1293 100644 --- a/docusaurus/docs/Flutter/02-customization/01-custom-widgets/04-adding_custom_attachments.mdx +++ b/docusaurus/docs/Flutter/02-customization/01-custom-widgets/04-adding_custom_attachments.mdx @@ -26,7 +26,7 @@ Let's build an example of location sharing option in the app: ![](../../assets/location_sharing_example.jpg) -* Show a "Share Location" button next to StreamMessageInput Textfield. +* Show a "Share Location" button next to StreamMessageInput `Textfield`. * When the user presses this button, it should fetch the current location coordinates of the user, and send a message on the channel as follows: @@ -46,7 +46,7 @@ Message( ) ``` -For our example, we are going to use [geolocator](https://pub.dev/packages/geolocator) library. +For our example, we are going to use [`geolocator`](https://pub.dev/packages/geolocator) library. Please check their [setup instructions](https://pub.dev/packages/geolocator) on their docs. NOTE: If you are testing on iOS simulator, you will need to set some dummy coordinates, as mentioned [here](https://stackoverflow.com/a/31238119/7489541). @@ -54,7 +54,7 @@ Also don't forget to enable "location update" capability in background mode, fro On the receiver end, `location` type attachment should be rendered in map view, in the `StreamMessageListView`. We are going to use [Google Static Maps API](https://developers.google.com/maps/documentation/maps-static/overview) to render the map in the message. -You can use other libraries as well such as [google_maps_flutter](https://pub.dev/packages/google_maps_flutter). +You can use other libraries as well such as [`google_maps_flutter`](https://pub.dev/packages/google_maps_flutter). First, we add a button which when clicked fetches and shares location into the `MessageInput`: diff --git a/docusaurus/docs/Flutter/02-customization/01-custom-widgets/06-autocomplete_triggers.mdx b/docusaurus/docs/Flutter/02-customization/01-custom-widgets/06-autocomplete_triggers.mdx index d9a90f399..ac38087b6 100644 --- a/docusaurus/docs/Flutter/02-customization/01-custom-widgets/06-autocomplete_triggers.mdx +++ b/docusaurus/docs/Flutter/02-customization/01-custom-widgets/06-autocomplete_triggers.mdx @@ -19,7 +19,7 @@ This widget will be used to show the autocomplete options. For this example we're using two external dependencies: - [emojis](https://pub.dev/packages/emojis) -- [substring_highlight](https://pub.dev/packages/substring_highlight) +- [`substring_highlight`](https://pub.dev/packages/substring_highlight) ```dart import 'package:emojis/emoji.dart'; diff --git a/docusaurus/docs/Flutter/02-customization/01-custom-widgets/07-slidable_channel_list_preview.mdx b/docusaurus/docs/Flutter/02-customization/01-custom-widgets/07-slidable_channel_list_preview.mdx index 67372ef59..9e350f902 100644 --- a/docusaurus/docs/Flutter/02-customization/01-custom-widgets/07-slidable_channel_list_preview.mdx +++ b/docusaurus/docs/Flutter/02-customization/01-custom-widgets/07-slidable_channel_list_preview.mdx @@ -38,7 +38,7 @@ In this example, you are doing a few important things in the ChannelListPage wid - Using the **flutter_slidable** package to easily add slide functionality. - Passing in the `itemBuilder` argument for the **StreamChannelListView** widget. This gives access to the current **BuildContext**, **Channel**, and **StreamChannelListTile**, and allows you to create, or customize, the stream channel list tiles. - Returning a Slidable widget with two CustomSlidableAction widgets - to delete a channel and show more options. These widgets come from the flutter_slidable package. -- Adding `onPressed` behaviour to call `showConfirmationBottomSheet` and `showChannelInfoModalBottomSheet`. These methods come from the **stream_chat_flutter** package. They have a few different on-tap callbacks you can supply, for example, `onViewInfoTap`. Alternatively, you can create custom dialogs from scratch. +- Adding `onPressed` behaviour to call `showConfirmationBottomSheet` and `showChannelInfoModalBottomSheet`. These methods come from the **`stream_chat_flutter`** package. They have a few different on-tap callbacks you can supply, for example, `onViewInfoTap`. Alternatively, you can create custom dialog screens from scratch. - Using the **StreamChannelListController** to perform actions, such as, `deleteChannel`. ```dart diff --git a/docusaurus/docs/Flutter/03-stream_chat_flutter/setup.mdx b/docusaurus/docs/Flutter/03-stream_chat_flutter/setup.mdx index dc20a604b..e07e15479 100644 --- a/docusaurus/docs/Flutter/03-stream_chat_flutter/setup.mdx +++ b/docusaurus/docs/Flutter/03-stream_chat_flutter/setup.mdx @@ -39,16 +39,16 @@ This section provides setup instructions for the respective platforms. #### Android -The package uses [photo_manager](https://pub.dev/packages/photo_manager) to access the device's photo library. Follow [this wiki](https://pub.dev/packages/photo_manager#android-10-q-29) to fulfill the Android requirements. +The package uses [`photo_manager`](https://pub.dev/packages/photo_manager) to access the device's photo library. Follow [this wiki](https://pub.dev/packages/photo_manager#android-10-q-29) to fulfill the Android requirements. #### iOS The library uses [flutter file picker plugin](https://github.com/miguelpruivo/flutter_file_picker) to pick files from the os. Follow [this wiki](https://github.com/miguelpruivo/flutter_file_picker/wiki/Setup#ios) to fulfill iOS requirements. -Stream Chat also uses the [video_player](https://pub.dev/packages/video_player) package to play videos. Follow [this guide](https://pub.dev/packages/video_player#installation) to fulfill the requirements. +Stream Chat also uses the [`video_player`](https://pub.dev/packages/video_player) package to play videos. Follow [this guide](https://pub.dev/packages/video_player#installation) to fulfill the requirements. -Stream Chat uses the [image_picker](https://pub.dev/packages/image_picker) plugin. +Stream Chat uses the [`image_picker`](https://pub.dev/packages/image_picker) plugin. Follow [these instructions](https://pub.dev/packages/image_picker#ios) to check the requirements. #### Web @@ -61,7 +61,7 @@ For the web, edit your `index.html` and add the following in the `` tag to #### macOS -For macOS Stream Chat uses the [file_selector](https://pub.dev/packages/file_selector#macos) package. Follow [these instructions](https://pub.dev/packages/file_selector#macos) to check the requirements. +For macOS Stream Chat uses the [`file_selector`](https://pub.dev/packages/file_selector#macos) package. Follow [these instructions](https://pub.dev/packages/file_selector#macos) to check the requirements. You also need to add the following [entitlements](https://docs.flutter.dev/development/platform-integration/desktop#entitlements-and-the-app-sandbox) to `Release.entitlement` and `DebugProfile.entitlement`: diff --git a/docusaurus/docs/Flutter/03-stream_chat_flutter/stream_channel_list_header.mdx b/docusaurus/docs/Flutter/03-stream_chat_flutter/stream_channel_list_header.mdx index 4c8fbc632..e5b548e42 100644 --- a/docusaurus/docs/Flutter/03-stream_chat_flutter/stream_channel_list_header.mdx +++ b/docusaurus/docs/Flutter/03-stream_chat_flutter/stream_channel_list_header.mdx @@ -90,7 +90,7 @@ StreamChannelListHeader( ![](../assets/channel_list_header_custom_subtitle.png) -The `titleBuilder` param helps you build different titles depending on the connection state: +The `titleBuilder` parameter helps you build different titles depending on the connection state: ```dart //... diff --git a/docusaurus/docs/Flutter/04-stream_chat_flutter_core/message_list_core.mdx b/docusaurus/docs/Flutter/04-stream_chat_flutter_core/message_list_core.mdx index 57f06b2a9..2a20db928 100644 --- a/docusaurus/docs/Flutter/04-stream_chat_flutter_core/message_list_core.mdx +++ b/docusaurus/docs/Flutter/04-stream_chat_flutter_core/message_list_core.mdx @@ -15,7 +15,7 @@ according to the filters and sort order given. However, in some cases, implement that cannot be done using the customization approaches given in the widget. To do this, we extracted the logic required for fetching channels into a 'Core' widget - a widget that -fetches channels in the expected way via the usual params but does not supply any UI and instead +fetches channels in the expected way via the usual parameters but does not supply any UI and instead exposes builders to build the UI in situations such as loading, empty data, errors, and on data received. ### Basic Example diff --git a/docusaurus/docs/Flutter/04-stream_chat_flutter_core/stream_chat_core.mdx b/docusaurus/docs/Flutter/04-stream_chat_flutter_core/stream_chat_core.mdx index e3434e7f7..11743abfc 100644 --- a/docusaurus/docs/Flutter/04-stream_chat_flutter_core/stream_chat_core.mdx +++ b/docusaurus/docs/Flutter/04-stream_chat_flutter_core/stream_chat_core.mdx @@ -11,7 +11,7 @@ Find the pub.dev documentation [here](https://pub.dev/documentation/stream_chat_ `StreamChatCore` is used to provide information about the chat client to the widget tree. This Widget is used to react to life cycle changes and system updates. -When the app goes into the background, the websocket connection is automatically closed and when it goes back to foreground the connection is opened again. +When the app goes into the background, the web socket connection is automatically closed and when it goes back to foreground the connection is opened again. Like the `StreamChat` widget in the higher level UI package, the `StreamChatCore` widget should be on the top level before using any Stream functionality: diff --git a/docusaurus/docs/Flutter/05-guides/01-understanding_filters.mdx b/docusaurus/docs/Flutter/05-guides/01-understanding_filters.mdx index 88f5ee616..152a8a8fe 100644 --- a/docusaurus/docs/Flutter/05-guides/01-understanding_filters.mdx +++ b/docusaurus/docs/Flutter/05-guides/01-understanding_filters.mdx @@ -23,7 +23,7 @@ Filter.equal('type', 'messaging'), #### Filter.notEqual -The 'notEqual' filter gets the objects where the given key does not have the specified value. +The `notEqual` filter gets the objects where the given key does not have the specified value. ```dart Filter.notEqual('type', 'messaging'), @@ -63,20 +63,20 @@ Filter.lessOrEqual('count', 5), #### Filter.in_ -The 'in_' filter allows getting objects where the key matches any in a specified array. +The `in_` filter allows getting objects where the key matches any in a specified array. ```dart Filter.in_('members', [user.id]) ``` :::note -Since 'in' is a keyword in Dart, the filter has an underscore added. This does not apply to the 'notIn' +Since 'in' is a keyword in Dart, the filter has an underscore added. This does not apply to the `notIn` keyword. ::: #### Filter.notIn -The 'notIn' filter allows getting objects where the key matches none in a specified array. +The `notIn` filter allows getting objects where the key matches none in a specified array. ```dart Filter.notIn('members', [user.id]) @@ -108,7 +108,7 @@ Filter.exists('name') #### Filter.notExists -The 'notExists' filter checks if the specified key doesn't exist. This is a simplified call to `Filter.exists` +The `notExists` filter checks if the specified key doesn't exist. This is a simplified call to `Filter.exists` with the value set to false. ```dart diff --git a/docusaurus/docs/Flutter/05-guides/02-adding_local_data_persistence.mdx b/docusaurus/docs/Flutter/05-guides/02-adding_local_data_persistence.mdx index dd7ce0c93..3943b1f97 100644 --- a/docusaurus/docs/Flutter/05-guides/02-adding_local_data_persistence.mdx +++ b/docusaurus/docs/Flutter/05-guides/02-adding_local_data_persistence.mdx @@ -27,7 +27,7 @@ final client = StreamChatClient( )..chatPersistenceClient = CustomChatPersistentClient(); ``` -We provide an official persistent client in the [stream_chat_persistence](https://pub.dev/packages/stream_chat_persistence) +We provide an official persistent client in the [`stream_chat_persistence`](https://pub.dev/packages/stream_chat_persistence) package that works using the library [moor](https://moor.simonbinder.eu), an SQLite ORM. Add this to your package's `pubspec.yaml` file, using the latest version. diff --git a/docusaurus/docs/Flutter/05-guides/03-user_token_generation_with_firebase_auth.mdx b/docusaurus/docs/Flutter/05-guides/03-user_token_generation_with_firebase_auth.mdx index 0fbe8b697..85a0250d8 100644 --- a/docusaurus/docs/Flutter/05-guides/03-user_token_generation_with_firebase_auth.mdx +++ b/docusaurus/docs/Flutter/05-guides/03-user_token_generation_with_firebase_auth.mdx @@ -154,7 +154,7 @@ Running the above will give this: ![](../assets/authentication_demo_app.jpg) The `Auth` widget handles all of the authentication logic. It initializes a `FirebaseAuth.instance` and uses that -in the `createAccount`, `signIn` and `signOut` methods. There is a button to envoke each of these methods. +in the `createAccount`, `signIn` and `signOut` methods. There is a button to invoke each of these methods. The `FirebaseFunctions.instance` will be used later in this guide. @@ -288,7 +288,7 @@ firebase deploy --only functions ### Create a Stream User and Get the User's Token In the `createStreamUserAndGetToken` cloud function you create an `onCall` HTTPS handler, which exposes -a cloud function that can be envoked from your Flutter app. +a cloud function that can be invoked from your Flutter app. ```js // Create a Stream user and return auth token. @@ -324,13 +324,13 @@ by ensuring that `context.auth` is not null. If it is null, then it throws an `H message. This error can be caught in your Flutter application. If the caller is authenticated the function proceeds to use the `serverClient` to create a new Stream Chat -user by calling the `upsertUser` method and passing in some user data. It uses the authenticated caller's **uid** as an **id**. +user by calling the `upsertUser` method and passing in some user data. It uses the authenticated caller's **`uid`** as an **id**. After the user is created it generates a token for that user. This token is then returned to the caller. To call this from Flutter, you will need to use the `cloud_functions` package. -Update the **createAccount** method in your Flutter code to the following: +Update the **`createAccount`** method in your Flutter code to the following: ```dart Future createAccount() async { @@ -354,7 +354,7 @@ in the request. Once you have the Stream user token, you can authenticate your Stream Chat user as you normally would. -Please see our [initialization documention](https://getstream.io/chat/docs/flutter-dart/init_and_users/?language=dart) for more information. +Please see our [initialization documentation](https://getstream.io/chat/docs/flutter-dart/init_and_users/?language=dart) for more information. As you can see below, the User ID matches on both Firebase's and Stream's user database. @@ -372,7 +372,7 @@ As you can see below, the User ID matches on both Firebase's and Stream's user d The `getStreamUserToken` cloud function is very similar to the `createStreamUserAndGetToken` function. The only difference is that it only creates a user token and does not create a new user account on Stream. -Update the **signIn** method in your Flutter code to the following: +Update the **`signIn`** method in your Flutter code to the following: ```dart Future signIn() async { @@ -433,7 +433,7 @@ exports.deleteStreamUser = functions.auth.user().onDelete((user, context) => { ``` In this function, you are listening to delete events on Firebase auth. When an account is deleted, this function will be triggered, and you can get the -user's **uid** and call the `deleteUser` method on the `serverClient`. +user's **`uid`** and call the `deleteUser` method on the `serverClient`. This is not an external cloud function; it can only be triggered when an account is deleted. diff --git a/docusaurus/docs/Flutter/05-guides/05-push-notifications/adding_push_notifications.mdx b/docusaurus/docs/Flutter/05-guides/05-push-notifications/adding_push_notifications.mdx index 1926b93c4..7385564ef 100644 --- a/docusaurus/docs/Flutter/05-guides/05-push-notifications/adding_push_notifications.mdx +++ b/docusaurus/docs/Flutter/05-guides/05-push-notifications/adding_push_notifications.mdx @@ -21,7 +21,7 @@ Make sure to check [this section](https://getstream.io/chat/docs/flutter-dart/pu ### Setup FCM -To integrate push notifications in your Flutter app you need to use the package [firebase_messaging](https://pub.dev/packages/firebase_messaging). +To integrate push notifications in your Flutter app you need to use the package [`firebase_messaging`](https://pub.dev/packages/firebase_messaging). Follow the [Firebase documentation](https://firebase.flutter.dev/docs/messaging/overview/) to know how to set up the plugin for both Android and iOS. @@ -61,7 +61,7 @@ Upload the `Server Key` in your chat dashboard :::note -We are setting up the Android section, but this will work for both Android and iOS if you're using Firebase for both of them! +We are setting up the Android section, but this will work for both Android and iOS if you're using Firebase for both of them. ::: #### Step 6 @@ -97,21 +97,21 @@ firebaseMessaging.onTokenRefresh.listen((token) { ### Possible issues -We only send push notifications when the user doesn't have any active websocket connection (which is established when you call `client.connectUser`). If you set the [onBackgroundEventReceived](https://pub.dev/documentation/stream_chat_flutter/latest/stream_chat_flutter/StreamChat/onBackgroundEventReceived.html) property of the StreamChat widget, when your app goes to background, your device will keep the ws connection alive for 1 minute, and so within this period, you won't receive any push notification. +We only send push notifications when the user doesn't have any active web socket connection (which is established when you call `client.connectUser`). If you set the [onBackgroundEventReceived](https://pub.dev/documentation/stream_chat_flutter/latest/stream_chat_flutter/StreamChat/onBackgroundEventReceived.html) property of the StreamChat widget, when your app goes to background, your device will keep the WS connection alive for 1 minute, and so within this period, you won't receive any push notification. Make sure to read the [general push docs](https://getstream.io/chat/docs/flutter-dart/push_introduction/?language=dart) in order to avoid known gotchas that may make your relationship with notifications go bad 😢 ### Testing if Push Notifications are Setup Correctly -If you're not sure if you've set up push notifications correctly (e.g. you don't always receive them, they work unreliably), you can follow these steps to make sure your config is correct and working: +If you're not sure if you've set up push notifications correctly (for example you don't always receive them, they work unreliably), you can follow these steps to make sure your configuration is correct and working: -1. Clone our repo for push testing git clone git@github.com:GetStream/chat-push-test.git +1. Clone our repository for push testing git clone git@github.com:GetStream/chat-push-test.git 2. `cd flutter` 3. In folder run `flutter pub get` -4. Input your api key and secret in `lib/main.dart` +4. Input your API key and secret in `lib/main.dart` 5. Change the bundle identifier/application ID and development team/user so you can run the app in your device (**do not** run on iOS simulator, Android emulator is fine) @@ -137,11 +137,11 @@ You should get a test push notification The [StreamChat](https://pub.dev/documentation/stream_chat_flutter/latest/stream_chat_flutter/StreamChat-class.html) widget lets you define a [onBackgroundEventReceived](https://pub.dev/documentation/stream_chat_flutter/latest/stream_chat_flutter/StreamChat/onBackgroundEventReceived.html) handler in order to handle events while the app is in the background, but the client is still connected. -This is useful because it lets you keep the connection alive in cases in which the app goes in the background just for some seconds (eg: multitasking, picking pictures from the gallery...) +This is useful because it lets you keep the connection alive in cases in which the app goes in the background just for some seconds (for example multitasking, picking pictures from the gallery...) You can even customize the [backgroundKeepAlive](https://pub.dev/documentation/stream_chat_flutter/latest/stream_chat_flutter/StreamChat/backgroundKeepAlive.html) duration. -In order to show notifications in such a case we suggest using the package [flutter_local_notifications](https://pub.dev/packages/flutter_local_notifications); follow the package guide to successfully set up the plugin. +In order to show notifications in such a case we suggest using the package [`flutter_local_notifications`](https://pub.dev/packages/flutter_local_notifications); follow the package guide to successfully set up the plugin. Once that's done you should set the [onBackgroundEventReceived](https://pub.dev/documentation/stream_chat_flutter/latest/stream_chat_flutter/StreamChat/onBackgroundEventReceived.html); here is an example: @@ -234,7 +234,7 @@ To do this we need to update the push notification data payload at Stream Dashbo } ``` -Then we need to integrate the package [stream_chat_persistence](https://pub.dev/packages/stream_chat_persistence) in our app that exports a persistence client, learn [here](https://pub.dev/packages/stream_chat_persistence#usage) how to set it up. +Then we need to integrate the package [`stream_chat_persistence`](https://pub.dev/packages/stream_chat_persistence) in our app that exports a persistence client, learn [here](https://pub.dev/packages/stream_chat_persistence#usage) how to set it up. Then during the call `firebaseMessaging.configure(...)` we need to set the `onBackgroundMessage` parameter using a TOP-LEVEL or STATIC function to handle background messages; here is an example: diff --git a/docusaurus/docs/Flutter/05-guides/05-push-notifications/adding_push_notifications_v2.mdx b/docusaurus/docs/Flutter/05-guides/05-push-notifications/adding_push_notifications_v2.mdx index 351e80214..0c5c3d877 100644 --- a/docusaurus/docs/Flutter/05-guides/05-push-notifications/adding_push_notifications_v2.mdx +++ b/docusaurus/docs/Flutter/05-guides/05-push-notifications/adding_push_notifications_v2.mdx @@ -17,7 +17,7 @@ You can read more about Stream’s [push delivery logic](https://getstream.io/ch ### Setup FCM -To integrate push notifications in your Flutter app, you need to use the package [firebase_messaging](https://pub.dev/packages/firebase_messaging). +To integrate push notifications in your Flutter app, you need to use the package [`firebase_messaging`](https://pub.dev/packages/firebase_messaging). Follow the [Firebase documentation](https://firebase.flutter.dev/docs/messaging/overview/) to set up the plugin for Android and iOS. @@ -55,7 +55,7 @@ You can upload your Firebase credentials using either the dashboard or the app s ![](../../assets/firebase_notifications_toggle-5aeabfcbdc24cb8f1fea7d41d0e845fc.png) -3. Enter your Firebase Credentials and press "Save". +3. Enter your Firebase Credentials and press `"Save"`. ##### Using the API @@ -86,7 +86,7 @@ firebaseMessaging.onTokenRefresh.listen((token) { }); ``` -Push Notifications v2 also supports specifying a name to the push device tokens you register. By setting the optional `pushProviderName` param in the `addDevice` call you can support different configurations between the device and the `PushProvider`. +Push Notifications v2 also supports specifying a name to the push device tokens you register. By setting the optional `pushProviderName` parameter in the `addDevice` call you can support different configurations between the device and the `PushProvider`. ```dart firebaseMessaging.onTokenRefresh.listen((token) { @@ -105,7 +105,7 @@ On iOS we send both a **notification** and a **data** payload. This means you don't need to do anything special to get the notification to show up. However, you might want to handle the data payload to perform some logic when the user taps on the notification. To update the template, you can use a backend SDK. -For example, using the javascript SDK: +For example, using the JavaScript SDK: ```js const client = StreamChat.getInstance(‘api_key’, ‘api_secret’); @@ -181,13 +181,13 @@ void handleNotification( FirebaseMessaging.onBackgroundMessage(onBackgroundMessage); ``` -In the above example, you get the message details using the `getMessage` method and then you use the [flutter_local_notifications](https://pub.dev/packages/flutter_local_notifications) package to show the actual notification. +In the above example, you get the message details using the `getMessage` method and then you use the [`flutter_local_notifications`](https://pub.dev/packages/flutter_local_notifications) package to show the actual notification. ##### Using a Template on Android It's still possible to add a **notification** payload to Android notifications. You can do so by adding a template using a backend SDK. -For example, using the javascript SDK: +For example, using the JavaScript SDK: ```js const client = StreamChat.getInstance(‘api_key’, ‘api_secret’); @@ -211,11 +211,11 @@ Make sure to read the [general push notification docs](https://getstream.io/chat ### Testing if Push Notifications are Setup Correctly -If you're not sure whether you've set up push notifications correctly, for example, you don't always receive them, or they don’t work reliably, then you can follow these steps to make sure your config is correct and working: -1. Clone our repo for push testing: `git clone git@github.com:GetStream/chat-push-test.git` +If you're not sure whether you've set up push notifications correctly, for example, you don't always receive them, or they don’t work reliably, then you can follow these steps to make sure your configuration is correct and working: +1. Clone our repository for push testing: `git clone git@github.com:GetStream/chat-push-test.git` 2. `cd flutter` 3. In that folder run `flutter pub get` -4. Input your api key and secret in `lib/main.dart` +4. Input your API key and secret in `lib/main.dart` 5. Change the bundle identifier/application ID and development team/user so you can run the app on your physical device.**Do not** run on an iOS simulator, as it will not work. Testing on an Android emulator is fine. 6. Add your `google-services.json/GoogleService-Info.plist` 7. Run the app @@ -257,7 +257,7 @@ Take a look at the [Stream Chat v1 sample app](https://github.com/GetStream/flut When the app is closed you may want to save received messages when you receive them via a notification so that later on when you open the app they're already there. -To do this you need to integrate the package [stream_chat_persistence](https://pub.dev/packages/stream_chat_persistence) in our app that exports a persistence client, see [here](https://pub.dev/packages/stream_chat_persistence#usage) how to set it up. +To do this you need to integrate the package [`stream_chat_persistence`](https://pub.dev/packages/stream_chat_persistence) in our app that exports a persistence client, see [here](https://pub.dev/packages/stream_chat_persistence#usage) how to set it up. Then calling `FirebaseMessaging.onBackgroundMessage(...)` you need to use a TOP-LEVEL or STATIC function to handle background messages; here is an example: diff --git a/docusaurus/docs/Flutter/05-guides/06-end_to_end_chat_encryption.mdx b/docusaurus/docs/Flutter/05-guides/06-end_to_end_chat_encryption.mdx index 10699b2df..cf204cfc6 100644 --- a/docusaurus/docs/Flutter/05-guides/06-end_to_end_chat_encryption.mdx +++ b/docusaurus/docs/Flutter/05-guides/06-end_to_end_chat_encryption.mdx @@ -37,7 +37,7 @@ Check out the diagram below for an example: ### Dependencies -Add the [webcrypto](https://pub.dev/packages/webcrypto) package in your `pubspec.yaml` file. +Add the [`webcrypto`](https://pub.dev/packages/webcrypto) package in your `pubspec.yaml` file. ```yaml dependencies: @@ -77,9 +77,9 @@ class JsonWebKeyPair { } ``` -### Generate a Crypto Key +### Generate a Cryptographic Key -Next, create a symmetric **Crypto Key** using the keys generated in the previous step. +Next, create a symmetric **Cryptographic Key** using the keys generated in the previous step. You will use those keys to encrypt and decrypt messages. ```dart @@ -108,7 +108,7 @@ Future> deriveKey(String senderJwk, String receiverJwk) async { ### Encrypting Messages -Once you have generated the **Crypto Key**, you're ready to encrypt the message. +Once you have generated the **Cryptographic Key**, you're ready to encrypt the message. You can use the **AES-GCM** algorithm for its known security and performance balance and good browser availability. ```dart @@ -254,6 +254,6 @@ StreamMessageListView( ), ``` -That's it! That's all you need to implement E2EE in a Stream powered chat app. +That's it. That's all you need to implement E2EE in a Stream powered chat app. For more details, check out our [end-to-end encrypted chat article](https://getstream.io/blog/end-to-end-encrypted-chat-in-flutter/#whats-end-to-end-encryption). diff --git a/docusaurus/docs/Flutter/05-guides/08-migrations/migration_guide_4_0.mdx b/docusaurus/docs/Flutter/05-guides/08-migrations/migration_guide_4_0.mdx index fa2d21b4b..2fc5ace50 100644 --- a/docusaurus/docs/Flutter/05-guides/08-migrations/migration_guide_4_0.mdx +++ b/docusaurus/docs/Flutter/05-guides/08-migrations/migration_guide_4_0.mdx @@ -14,7 +14,7 @@ If you find any bugs or have any questions, please file an [issue on our GitHub Code examples: - See our [Stream Chat Flutter tutorial](https://getstream.io/chat/flutter/tutorial/) for an up-to-date guide using the latest Stream Chat version. -- See the [Stream Flutter Samples repository](https://github.com/GetStream/flutter-samples) with our fully-fledged messaging [sample application](https://github.com/GetStream/flutter-samples/tree/main/packages/stream_chat_v1). +- See the [Stream Flutter Samples repository](https://github.com/GetStream/flutter-samples) with our full fledged messaging [sample application](https://github.com/GetStream/flutter-samples/tree/main/packages/stream_chat_v1). All of our documentation has also been updated to support v4, so all of the guides and examples will have updated code. @@ -209,10 +209,10 @@ Let's explore some examples of the functional differences when using the new `St The **StreamChannelListController** provides various methods, such as: -- **deleteChannel** -- **loadMore** -- **muteChannel** -- **deleteChannel** +- **`deleteChannel`** +- **`loadMore`** +- **`muteChannel`** +- **`deleteChannel`** For a complete list with additional information, see the code documentation. @@ -537,7 +537,7 @@ Creating a separate controller allows easier control over the message input cont The widget is also separated into smaller components: `StreamCountDownButton`, `StreamAttachmentPicker`, etc. -> ❗The `MessageInputController` is exposed by the **stream_chat_flutter_core** package. This allows you to use the controller even if you're not using the UI components. +> ❗The `MessageInputController` is exposed by the **`stream_chat_flutter_core`** package. This allows you to use the controller even if you're not using the UI components. As a result of this extra control, it is no longer needed for the new `StreamMessageInput` widget to expose these `MessageInput` arguments: @@ -734,7 +734,7 @@ The controller makes it much simpler to dynamically modify the message input. ## Stream Chat Flutter Core -Various changes have been made to the Core package, most notably, the indroduction of all of the controllers mentioned above. +Various changes have been made to the Core package, most notably, the introduction of all of the controllers mentioned above. These controllers replace the business logic implementations (Bloc). Please note that this is not related to the well-known Flutter Bloc package, but instead refers to the naming we used for our business logic components. diff --git a/docusaurus/docs/Flutter/05-guides/08-migrations/migration_guide_5_0.mdx b/docusaurus/docs/Flutter/05-guides/08-migrations/migration_guide_5_0.mdx index 3e4d20524..7f243b2a7 100644 --- a/docusaurus/docs/Flutter/05-guides/08-migrations/migration_guide_5_0.mdx +++ b/docusaurus/docs/Flutter/05-guides/08-migrations/migration_guide_5_0.mdx @@ -16,7 +16,7 @@ If you find any bugs or have any questions, please file an [issue on our GitHub Code examples: - See our [Stream Chat Flutter tutorial](https://getstream.io/chat/flutter/tutorial/) for an up-to-date guide using the latest Stream Chat version. -- See the [Stream Flutter Samples repository](https://github.com/GetStream/flutter-samples) with our fully-fledged messaging [sample application](https://github.com/GetStream/flutter-samples/tree/main/packages/stream_chat_v1). +- See the [Stream Flutter Samples repository](https://github.com/GetStream/flutter-samples) with our full fledged messaging [sample application](https://github.com/GetStream/flutter-samples/tree/main/packages/stream_chat_v1). Our documentation has also been updated to support v5, so all guides and examples will have updated code. @@ -59,7 +59,7 @@ The user experience of interacting with a desktop application differs from a mob - Input controls: touch, keyboard, and mouse interactions - Native file system or gallery access (as well as sharing functionality) - Shortcuts -- Dialogs +- Dialog screens By default, Stream Chat Flutter will use the correct input controls and visual elements for the target platform. For example, touch and swipe controls will be the default on mobile, while on web and desktop these will be disabled and interactions with the mouse and keyboard will be preferred. @@ -70,7 +70,7 @@ On desktop and web it's also possible to add attachments by simply dragging them - Right-click context menus for messages and full-screen attachments. - Upload and download attachments using the native desktop file system. - Press the "enter" key to send a message. -- If you are quoting a message and have not yet typed any text, you can press the "esc" key to remove the quoted message. +- If you are quoting a message and have not yet typed any text, you can press the `"esc"` key to remove the quoted message. - A dedicated "X" button for removing a quoted message with your mouse. - Drag and drop attachment files to `StreamMessageInput`. - New `StreamMessageInput.draggingBorder` property to customize the border color of the message input when dropping a file. @@ -81,10 +81,10 @@ On desktop and web it's also possible to add attachments by simply dragging them - Gallery navigation controls with keyboard shortcuts (left and right arrow keys). - Appropriate message sizing for large screens. - Right-click context menu for `StreamMessageListView` items. -- `StreamMessageListView` items not swipeable on desktop & web. +- `StreamMessageListView` items not swipe-able on desktop & web. - Video support for Windows & Linux through `dart_vlc`. - Video support for macOS through `video_player_macos`. -- Replace bottom sheets with dialogs where appropriate. +- Replace bottom sheets with dialog screens where appropriate. ## What's New? @@ -118,7 +118,7 @@ Check out the dedicated [guide](../../02-customization/01-custom-widgets/05-cust The following was also introduced: -- Added support for additional text field params in`StreamMessageInput`: `maxLines`, `minLines`, `textInputAction`, `keyboardType`, and `textCapitalization`. +- Added support for additional text field parameters in`StreamMessageInput`: `maxLines`, `minLines`, `textInputAction`, `keyboardType`, and `textCapitalization`. - Added `showStreamAttachmentPickerModalBottomSheet` to show the attachment picker modal bottom sheet. - Added `onQuotedMessageCleared` to `StreamMessageInput` - `selected` and `selectedTileColor` to `StreamChannelListTile` diff --git a/docusaurus/docs/Flutter/05-guides/09-initialize_stream_chat_widget_tree.mdx b/docusaurus/docs/Flutter/05-guides/09-initialize_stream_chat_widget_tree.mdx index 17476d211..4a6575157 100644 --- a/docusaurus/docs/Flutter/05-guides/09-initialize_stream_chat_widget_tree.mdx +++ b/docusaurus/docs/Flutter/05-guides/09-initialize_stream_chat_widget_tree.mdx @@ -196,7 +196,7 @@ Both of these will ensure the route is disposed of and the user is disconnected Another approach would be to introduce a new [Navigator](https://api.flutter.dev/flutter/widgets/Navigator-class.html). This has the benefit that everything related to Stream chat is contained to a specific part of the widget tree. -### Defining Routes and Subroutes +### Defining Routes and Nested Routes In this example, our application has the following routes. @@ -208,7 +208,7 @@ const routeChatChannels = 'chat_channels'; const routeChatChannel = 'chat_channel'; ``` -For the `/chat/` subroutes (**routePrefixChat**), this approach initializes Stream Chat in our application and introduces a nested navigator. +For the `/chat/` nested routes (**routePrefixChat**), this approach initializes Stream Chat in our application and introduces a nested navigator. Let’s explore the code: @@ -267,7 +267,7 @@ In the above code you’re: 1. Creating a navigator key, passing it to `MaterialApp`, and exposing it to the whole application using Provider (you can expose it however you want). 2. Creating `onGenerateRoute` that specifies what page to show depending on the route. Most importantly, if the route contains the **routePrefixChat,** it navigates to the **ChatSetup** page and passes in the remainder of the route. -For example, `Navigator.pushNamed(context, routeChatHome)` will navigate to the **ChatSetup** page and pass in the subroute **routeChatChannels.** +For example, `Navigator.pushNamed(context, routeChatHome)` will navigate to the **ChatSetup** page and pass in the nested route **routeChatChannels.** ### Stream Chat Initialization, User Connection, and Nested Navigation @@ -456,7 +456,7 @@ This final example will be a combination of the first two options. The following ### Application Routes and Conditional Stream Initialization -For this example we have the following routes and subroutes: +For this example we have the following routes and nested routes: ```dart |_ '/' -> home page @@ -553,7 +553,7 @@ If you’re unfamiliar with GoRouter it will help to first read the documentatio There are a few important things to note in the above code: -- Define our routes and subroutes +- Define our routes and nested routes - Specify the initial route with `initialLocation` - Use the `navigatorBuilder` to wrap certain routes with **StreamChat** and **ChatSetup**. - The `wasPreviousRouteChat` \***\*boolean is used to determine if the previous route was a chat route. This is important because when you press the back button from the `/chat` route and navigate to the `/` route, the **StreamChat** widget still needs to be accessible while the navigation transition occurs. However, if you then navigate to the `/setting` route, you no longer need the **StreamChat\*\* widget and can safely remove it. diff --git a/docusaurus/flutter_versioned_docs/version-3.x.x/Flutter/basics/choose_package.mdx b/docusaurus/flutter_versioned_docs/version-3.x.x/Flutter/basics/choose_package.mdx index 8be73f010..5d1acf796 100644 --- a/docusaurus/flutter_versioned_docs/version-3.x.x/Flutter/basics/choose_package.mdx +++ b/docusaurus/flutter_versioned_docs/version-3.x.x/Flutter/basics/choose_package.mdx @@ -14,7 +14,7 @@ which allows you persist data locally which works with all packages. ### How do I choose? -#### The case for stream_chat_flutter +#### The case for `stream_chat_flutter` For the quickest way to integrate Stream Chat with your app, the UI SDK (`stream_chat_flutter`) is the way to go. `stream_chat_flutter` contains prebuilt components that manage most operations like data @@ -30,26 +30,26 @@ to request this through our support channels. Summary: -For the quickest and easiest way to add Chat to your app with prebuilt UI components, use stream_chat_flutter +For the quickest and easiest way to add Chat to your app with prebuilt UI components, use `stream_chat_flutter` -#### The case for stream_chat_flutter_core +#### The case for `stream_chat_flutter_core` -If your application involves UI that does not fit in with the stream_chat_flutter components, stream_chat_flutter_core +If your application involves UI that does not fit in with the `stream_chat_flutter` components, `stream_chat_flutter_core` strips away the UI associated with the components and provides the data fetching and manipulation capabilities while supplying builders for UI. This allows you to implement your own UI and themes completely independently while not worrying about writing functions for data and pagination. Summary: -For implementing your own custom UI while not having to worry about lower level API calls, use stream_chat_flutter_core. +For implementing your own custom UI while not having to worry about lower level API calls, use `stream_chat_flutter_core`. -#### The case for stream_chat +#### The case for `stream_chat` -The stream_chat package is the Low-level Client (LLC) of Stream Chat in Flutter. This package wraps +The `stream_chat` package is the Low-level Client (LLC) of Stream Chat in Flutter. This package wraps the underlying functionality of Stream Chat and allows the most customization in terms of UI, data, and architecture. Summary: -For the most control over the SDK and dealing with low level calls to the API, use stream_chat. +For the most control over the SDK and dealing with low level calls to the API, use `stream_chat`. diff --git a/docusaurus/flutter_versioned_docs/version-3.x.x/Flutter/basics/introduction.mdx b/docusaurus/flutter_versioned_docs/version-3.x.x/Flutter/basics/introduction.mdx index 99170774e..365c3feca 100644 --- a/docusaurus/flutter_versioned_docs/version-3.x.x/Flutter/basics/introduction.mdx +++ b/docusaurus/flutter_versioned_docs/version-3.x.x/Flutter/basics/introduction.mdx @@ -20,18 +20,18 @@ giving you complete control to ones that give you a rich out-of-the-box chat exp The packages that make up the Stream Chat SDK are: -1. Low Level Client (stream_chat): a pure Dart package that can be used on any Dart project. +1. Low Level Client (`stream_chat`): a pure Dart package that can be used on any Dart project. It provides a low-level client to access the Stream Chat service. -2. Core (stream_chat_flutter_core): provides business logic to fetch common things required +2. Core (`stream_chat_flutter_core`): provides business logic to fetch common things required for integrating Stream Chat into your application. The core package allows more customisation and hence provides business logic but no UI components. -3. UI (stream_chat_flutter): this library includes both a low-level chat SDK and a set of -reusable and customisable UI components. -4. Persistence (stream_chat_persistence): provides a persistence client for fetching and +3. UI (`stream_chat_flutter`): this library includes both a low-level chat SDK and a set of +reusable and customizable UI components. +4. Persistence (`stream_chat_persistence`): provides a persistence client for fetching and saving chat data locally. -5. Localizations (stream_chat_localizations): provides a set of localizations for the SDK. +5. Localizations (`stream_chat_localizations`): provides a set of localizations for the SDK. -We recommend building prototypes using the full UI package, [stream_chat_flutter](https://pub.dev/packages/stream_chat_flutter), +We recommend building prototypes using the full UI package, [`stream_chat_flutter`](https://pub.dev/packages/stream_chat_flutter), since it contains UI widgets already integrated with Stream's API. It is the fastest way to get up and running using Stream chat in your app. @@ -39,7 +39,7 @@ The Flutter SDK enables you to build any type of chat or messaging experience fo and Desktop. If you're building a very custom UI and would prefer a more lean package, -[stream_chat_flutter_core](https://pub.dev/packages/stream_chat_flutter_core) will be suited to this +[`stream_chat_flutter_core`](https://pub.dev/packages/stream_chat_flutter_core) will be suited to this use case. Core allows you to build custom, expressive UIs while retaining the benefits of our full Flutter SDK. APIs for accessing and controlling users, sending messages, and so forth are seamlessly integrated into this package and accessible via providers and builders. @@ -69,7 +69,7 @@ While this is a simplistic overview of the service, the Flutter SDK handles the Before reading the docs, consider trying our [online API tour](https://getstream.io/chat/get_started/), it is a nice way to learn how the API works. -It's in-browser so you'll need to use Javascript but the core conceps are pretty much the same as Dart. +It's in-browser so you'll need to use JavaScript but the core concepts are pretty much the same as Dart. You may also like to look at the [Flutter tutorial](https://getstream.io/chat/flutter/tutorial/) which focuses on using the UI package to get Stream Chat integrated into a Flutter app. diff --git a/docusaurus/flutter_versioned_docs/version-3.x.x/Flutter/basics/versioning_policy.mdx b/docusaurus/flutter_versioned_docs/version-3.x.x/Flutter/basics/versioning_policy.mdx index 48f25d66b..99ec8111d 100644 --- a/docusaurus/flutter_versioned_docs/version-3.x.x/Flutter/basics/versioning_policy.mdx +++ b/docusaurus/flutter_versioned_docs/version-3.x.x/Flutter/basics/versioning_policy.mdx @@ -4,7 +4,7 @@ sidebar_position: 3 title: Versioning Policy --- -All of the Stream Chat packages follow [semantic versioning (semver)](https://semver.org/). +All of the Stream Chat packages follow [semantic versioning](https://semver.org/). That means that with a version number x.y.z (major.minor.patch): - When releasing bug fixes (backwards compatible), we make a patch release by changing the z number (ex: 3.6.2 to 3.6.3). A bug fix is defined as an internal change that fixes incorrect behavior. diff --git a/docusaurus/flutter_versioned_docs/version-3.x.x/Flutter/guides/adding_custom_attachments.mdx b/docusaurus/flutter_versioned_docs/version-3.x.x/Flutter/guides/adding_custom_attachments.mdx index 9fe7f6aad..f8064ca20 100644 --- a/docusaurus/flutter_versioned_docs/version-3.x.x/Flutter/guides/adding_custom_attachments.mdx +++ b/docusaurus/flutter_versioned_docs/version-3.x.x/Flutter/guides/adding_custom_attachments.mdx @@ -27,7 +27,7 @@ Let's build an example of location sharing option in the app: ![](../assets/location_sharing_example.jpg) -* Show a "Share Location" button next to MessageInput Textfield. +* Show a "Share Location" button next to MessageInput `Textfield`. * When the user presses this button, it should fetch the current location coordinates of the user, and send a message on the channel as follows: @@ -47,7 +47,7 @@ Message( ) ``` -For our example, we are going to use [geolocator](https://pub.dev/packages/geolocator) library. +For our example, we are going to use [`geolocator`](https://pub.dev/packages/geolocator) library. Please check their [setup instructions](https://pub.dev/packages/geolocator) on their docs. NOTE: If you are testing on iOS simulator, you will need to set some dummy coordinates, as mentioned [here](https://stackoverflow.com/a/31238119/7489541). @@ -55,7 +55,7 @@ Also don't forget to enable "location update" capability in background mode, fro On the receiver end, `location` type attachment should be rendered in map view, in the `MessageListView`. We are going to use [Google Static Maps API](https://developers.google.com/maps/documentation/maps-static/overview) to render the map in the message. -You can use other libraries as well such as [google_maps_flutter](https://pub.dev/packages/google_maps_flutter). +You can use other libraries as well such as [`google_maps_flutter`](https://pub.dev/packages/google_maps_flutter). First, we add a button which when clicked fetches and shares location into the `MessageInput`: diff --git a/docusaurus/flutter_versioned_docs/version-3.x.x/Flutter/guides/adding_local_data_persistence.mdx b/docusaurus/flutter_versioned_docs/version-3.x.x/Flutter/guides/adding_local_data_persistence.mdx index e6283ca04..452ffcaee 100644 --- a/docusaurus/flutter_versioned_docs/version-3.x.x/Flutter/guides/adding_local_data_persistence.mdx +++ b/docusaurus/flutter_versioned_docs/version-3.x.x/Flutter/guides/adding_local_data_persistence.mdx @@ -28,7 +28,7 @@ final client = StreamChatClient( )..chatPersistenceClient = CustomChatPersistentClient(); ``` -We provide an official persistent client in the [stream_chat_persistence](https://pub.dev/packages/stream_chat_persistence) +We provide an official persistent client in the [`stream_chat_persistence`](https://pub.dev/packages/stream_chat_persistence) package that works using the library [moor](https://moor.simonbinder.eu), an SQLite ORM. Add this to your package's `pubspec.yaml` file, using the latest version. diff --git a/docusaurus/flutter_versioned_docs/version-3.x.x/Flutter/guides/adding_push_notifications.mdx b/docusaurus/flutter_versioned_docs/version-3.x.x/Flutter/guides/adding_push_notifications.mdx index 328ba5462..3ec661aa7 100644 --- a/docusaurus/flutter_versioned_docs/version-3.x.x/Flutter/guides/adding_push_notifications.mdx +++ b/docusaurus/flutter_versioned_docs/version-3.x.x/Flutter/guides/adding_push_notifications.mdx @@ -21,7 +21,7 @@ Make sure to check [this section](https://getstream.io/chat/docs/flutter-dart/pu ### Setup FCM -To integrate push notifications in your Flutter app you need to use the package [firebase_messaging](https://pub.dev/packages/firebase_messaging). +To integrate push notifications in your Flutter app you need to use the package [`firebase_messaging`](https://pub.dev/packages/firebase_messaging). Follow the [Firebase documentation](https://firebase.flutter.dev/docs/messaging/overview/) to know how to set up the plugin for both Android and iOS. @@ -61,7 +61,7 @@ Upload the `Server Key` in your chat dashboard :::note -We are setting up the Android section, but this will work for both Android and iOS if you're using Firebase for both of them! +We are setting up the Android section, but this will work for both Android and iOS if you're using Firebase for both of them. ::: #### Step 6 @@ -97,21 +97,21 @@ firebaseMessaging.onTokenRefresh.listen((token) { ### Possible issues -We only send push notifications when the user doesn't have any active websocket connection (which is established when you call `client.connectUser`). If you set the [onBackgroundEventReceived](https://pub.dev/documentation/stream_chat_flutter/latest/stream_chat_flutter/StreamChat/onBackgroundEventReceived.html) property of the StreamChat widget, when your app goes to background, your device will keep the ws connection alive for 1 minute, and so within this period, you won't receive any push notification. +We only send push notifications when the user doesn't have any active web socket connection (which is established when you call `client.connectUser`). If you set the [onBackgroundEventReceived](https://pub.dev/documentation/stream_chat_flutter/latest/stream_chat_flutter/StreamChat/onBackgroundEventReceived.html) property of the StreamChat widget, when your app goes to background, your device will keep the WS connection alive for 1 minute, and so within this period, you won't receive any push notification. Make sure to read the [general push docs](https://getstream.io/chat/docs/flutter-dart/push_introduction/?language=dart) in order to avoid known gotchas that may make your relationship with notifications go bad 😢 ### Testing if Push Notifications are Setup Correctly -If you're not sure if you've set up push notifications correctly (e.g. you don't always receive them, they work unreliably), you can follow these steps to make sure your config is correct and working: +If you're not sure if you've set up push notifications correctly (for example you don't always receive them, they work unreliably), you can follow these steps to make sure your configuration is correct and working: -1. Clone our repo for push testing git clone git@github.com:GetStream/chat-push-test.git +1. Clone our repository for push testing git clone git@github.com:GetStream/chat-push-test.git 2. `cd flutter` 3. In folder run `flutter pub get` -4. Input your api key and secret in `lib/main.dart` +4. Input your API key and secret in `lib/main.dart` 5. Change the bundle identifier/application ID and development team/user so you can run the app in your device (**do not** run on iOS simulator, Android emulator is fine) @@ -137,11 +137,11 @@ You should get a test push notification The [StreamChat](https://pub.dev/documentation/stream_chat_flutter/latest/stream_chat_flutter/StreamChat-class.html) widget lets you define a [onBackgroundEventReceived](https://pub.dev/documentation/stream_chat_flutter/latest/stream_chat_flutter/StreamChat/onBackgroundEventReceived.html) handler in order to handle events while the app is in the background, but the client is still connected. -This is useful because it lets you keep the connection alive in cases in which the app goes in the background just for some seconds (eg: multitasking, picking pictures from the gallery...) +This is useful because it lets you keep the connection alive in cases in which the app goes in the background just for some seconds (for example multitasking, picking pictures from the gallery...) You can even customize the [backgroundKeepAlive](https://pub.dev/documentation/stream_chat_flutter/latest/stream_chat_flutter/StreamChat/backgroundKeepAlive.html) duration. -In order to show notifications in such a case we suggest using the package [flutter_local_notifications](https://pub.dev/packages/flutter_local_notifications); follow the package guide to successfully set up the plugin. +In order to show notifications in such a case we suggest using the package [`flutter_local_notifications`](https://pub.dev/packages/flutter_local_notifications); follow the package guide to successfully set up the plugin. Once that's done you should set the [onBackgroundEventReceived](https://pub.dev/documentation/stream_chat_flutter/latest/stream_chat_flutter/StreamChat/onBackgroundEventReceived.html); here is an example: @@ -234,7 +234,7 @@ To do this we need to update the push notification data payload at Stream Dashbo } ``` -Then we need to integrate the package [stream_chat_persistence](https://pub.dev/packages/stream_chat_persistence) in our app that exports a persistence client, learn [here](https://pub.dev/packages/stream_chat_persistence#usage) how to set it up. +Then we need to integrate the package [`stream_chat_persistence`](https://pub.dev/packages/stream_chat_persistence) in our app that exports a persistence client, learn [here](https://pub.dev/packages/stream_chat_persistence#usage) how to set it up. Then during the call `firebaseMessaging.configure(...)` we need to set the `onBackgroundMessage` parameter using a TOP-LEVEL or STATIC function to handle background messages; here is an example: diff --git a/docusaurus/flutter_versioned_docs/version-3.x.x/Flutter/guides/adding_push_notifications_v2.mdx b/docusaurus/flutter_versioned_docs/version-3.x.x/Flutter/guides/adding_push_notifications_v2.mdx index 285c2205a..0fe367029 100644 --- a/docusaurus/flutter_versioned_docs/version-3.x.x/Flutter/guides/adding_push_notifications_v2.mdx +++ b/docusaurus/flutter_versioned_docs/version-3.x.x/Flutter/guides/adding_push_notifications_v2.mdx @@ -17,7 +17,7 @@ You can read more about Stream’s [push delivery logic](https://getstream.io/ch ### Setup FCM -To integrate push notifications in your Flutter app, you need to use the package [firebase_messaging](https://pub.dev/packages/firebase_messaging). +To integrate push notifications in your Flutter app, you need to use the package [`firebase_messaging`](https://pub.dev/packages/firebase_messaging). Follow the [Firebase documentation](https://firebase.flutter.dev/docs/messaging/overview/) to set up the plugin for Android and iOS. @@ -55,7 +55,7 @@ You can upload your Firebase credentials using either the dashboard or the app s ![](../assets/firebase_notifications_toggle-5aeabfcbdc24cb8f1fea7d41d0e845fc.png) -3. Enter your Firebase Credentials and press "Save". +3. Enter your Firebase Credentials and press `"Save"`. ##### Using the API @@ -97,7 +97,7 @@ On iOS we send both a **notification** and a **data** payload. This means you don't need to do anything special to get the notification to show up. However, you might want to handle the data payload to perform some logic when the user taps on the notification. To update the template, you can use a backend SDK. -For example, using the javascript SDK: +For example, using the JavaScript SDK: ```js const client = StreamChat.getInstance(‘api_key’, ‘api_secret’); @@ -173,13 +173,13 @@ void handleNotification( FirebaseMessaging.onBackgroundMessage(onBackgroundMessage); ``` -In the above example, you get the message details using the `getMessage` method and then you use the [flutter_local_notifications](https://pub.dev/packages/flutter_local_notifications) package to show the actual notification. +In the above example, you get the message details using the `getMessage` method and then you use the [`flutter_local_notifications`](https://pub.dev/packages/flutter_local_notifications) package to show the actual notification. ##### Using a Template on Android It's still possible to add a **notification** payload to Android notifications. You can do so by adding a template using a backend SDK. -For example, using the javascript SDK: +For example, using the JavaScript SDK: ```js const client = StreamChat.getInstance(‘api_key’, ‘api_secret’); @@ -203,11 +203,11 @@ Make sure to read the [general push notification docs](https://getstream.io/chat ### Testing if Push Notifications are Setup Correctly -If you're not sure whether you've set up push notifications correctly, for example, you don't always receive them, or they don’t work reliably, then you can follow these steps to make sure your config is correct and working: -1. Clone our repo for push testing: `git clone git@github.com:GetStream/chat-push-test.git` +If you're not sure whether you've set up push notifications correctly, for example, you don't always receive them, or they don’t work reliably, then you can follow these steps to make sure your configuration is correct and working: +1. Clone our repository for push testing: `git clone git@github.com:GetStream/chat-push-test.git` 2. `cd flutter` 3. In that folder run `flutter pub get` -4. Input your api key and secret in `lib/main.dart` +4. Input your API key and secret in `lib/main.dart` 5. Change the bundle identifier/application ID and development team/user so you can run the app on your physical device.**Do not** run on an iOS simulator, as it will not work. Testing on an Android emulator is fine. 6. Add your `google-services.json/GoogleService-Info.plist` 7. Run the app @@ -249,7 +249,7 @@ Take a look at the [Stream Chat v1 sample app](https://github.com/GetStream/flut When the app is closed you may want to save received messages when you receive them via a notification so that later on when you open the app they're already there. -To do this you need to integrate the package [stream_chat_persistence](https://pub.dev/packages/stream_chat_persistence) in our app that exports a persistence client, see [here](https://pub.dev/packages/stream_chat_persistence#usage) how to set it up. +To do this you need to integrate the package [`stream_chat_persistence`](https://pub.dev/packages/stream_chat_persistence) in our app that exports a persistence client, see [here](https://pub.dev/packages/stream_chat_persistence#usage) how to set it up. Then calling `FirebaseMessaging.onBackgroundMessage(...)` you need to use a TOP-LEVEL or STATIC function to handle background messages; here is an example: diff --git a/docusaurus/flutter_versioned_docs/version-3.x.x/Flutter/guides/customize_message_actions.mdx b/docusaurus/flutter_versioned_docs/version-3.x.x/Flutter/guides/customize_message_actions.mdx index c3dc2abaa..b21574443 100644 --- a/docusaurus/flutter_versioned_docs/version-3.x.x/Flutter/guides/customize_message_actions.mdx +++ b/docusaurus/flutter_versioned_docs/version-3.x.x/Flutter/guides/customize_message_actions.mdx @@ -37,7 +37,7 @@ Additionally, pinning a message requires you to add the roles which are allowed ### Partially remove some message actions -For example, if you only want to keep "copy message" and "delete message", +For example, if you only want to keep `"copy message"` and `"delete message"`, here is how to do it using the `messageBuilder` with our `MessageWidget`. ```dart diff --git a/docusaurus/flutter_versioned_docs/version-3.x.x/Flutter/guides/end_to_end_chat_encryption.mdx b/docusaurus/flutter_versioned_docs/version-3.x.x/Flutter/guides/end_to_end_chat_encryption.mdx index 8a85c6a50..6c7b4ec04 100644 --- a/docusaurus/flutter_versioned_docs/version-3.x.x/Flutter/guides/end_to_end_chat_encryption.mdx +++ b/docusaurus/flutter_versioned_docs/version-3.x.x/Flutter/guides/end_to_end_chat_encryption.mdx @@ -36,7 +36,7 @@ Check out the diagram below for an example: ### Dependencies -Add the [webcrypto](https://pub.dev/packages/webcrypto) package in your `pubspec.yaml` file. +Add the [`webcrypto`](https://pub.dev/packages/webcrypto) package in your `pubspec.yaml` file. ```yaml dependencies: @@ -76,9 +76,9 @@ class JsonWebKeyPair { } ``` -### Generate a Crypto Key +### Generate a Cryptographic Key -Next, create a symmetric **Crypto Key** using the keys generated in the previous step. +Next, create a symmetric **Cryptographic Key** using the keys generated in the previous step. You will use those keys to encrypt and decrypt messages. ```dart @@ -107,7 +107,7 @@ Future> deriveKey(String senderJwk, String receiverJwk) async { ### Encrypting Messages -Once you have generated the **Crypto Key**, you're ready to encrypt the message. +Once you have generated the **Cryptographic Key**, you're ready to encrypt the message. You can use the **AES-GCM** algorithm for its known security and performance balance and good browser availability. ```dart @@ -253,6 +253,6 @@ MessageListView( ), ``` -That's it! That's all you need to implement E2EE in a Stream powered chat app. +That's it. That's all you need to implement E2EE in a Stream powered chat app. For more details, check out our [end-to-end encrypted chat article](https://getstream.io/blog/end-to-end-encrypted-chat-in-flutter/#whats-end-to-end-encryption). diff --git a/docusaurus/flutter_versioned_docs/version-3.x.x/Flutter/guides/migration_guide_2_0.mdx b/docusaurus/flutter_versioned_docs/version-3.x.x/Flutter/guides/migration_guide_2_0.mdx index 89b6dacc8..296194338 100644 --- a/docusaurus/flutter_versioned_docs/version-3.x.x/Flutter/guides/migration_guide_2_0.mdx +++ b/docusaurus/flutter_versioned_docs/version-3.x.x/Flutter/guides/migration_guide_2_0.mdx @@ -75,7 +75,7 @@ Added video compress options (frame and quality) to MessageInput `TypingIndicator` now has a property called `parentId` to show typing indicator specific to threads #493: add support for `MessageListView` header/footer `MessageWidget` accepts a `userAvatarBuilder` -Added `pinMessage` ui support +Added `pinMessage` UI support Added `MessageListView.threadSeparatorBuilder` property Added `MessageInput.onError` property to allow error handling Added `GalleryHeader`/`GalleryFooter` theme classes @@ -202,20 +202,20 @@ in the constructor) #### 🛑️ Breaking Changes from 1.5.3 * Migrate this package to null safety -* `ConnectUserWithProvider` now requires `tokenProvider` as a required param. (Removed from the constructor) +* `ConnectUserWithProvider` now requires `tokenProvider` as a required parameter. (Removed from the constructor) * `client.disconnect()` is now divided into two different functions - * `client.closeConnection()` -> for closing user websocket connection. + * `client.closeConnection()` -> for closing user web socket connection. * `client.disconnectUser()` -> for disconnecting user and resetting client state. * `client.devToken()` now returns a Token model instead of String. * `ApiError` is removed in favor of `StreamChatError` * `StreamChatError` -> parent type for all the stream errors. - * `StreamWebSocketError` -> for user websocket related errors. + * `StreamWebSocketError` -> for user web socket related errors. * `StreamChatNetworkError` -> for network related errors. -* `client.queryChannels()`, `channel.query()` options param is removed in favor of individual params +* `client.queryChannels()`, `channel.query()` options parameter is removed in favor of individual parameters * `option.state` -> `bool state` * `option.watch` -> `bool watch` * `option.presence` -> `bool presence` -* `client.queryUsers()` options param is removed in favor of individual params +* `client.queryUsers()` options parameter is removed in favor of individual parameters * `option.presence` -> `bool presence` * Added typed filters @@ -227,8 +227,8 @@ in the constructor) #### ✅ Added -* New Location enum is introduced for easily changing the client location/baseUrl. -* New `client.openConnection()` and `client.closeConnection()` is introduced to connect/disconnect user ws connection. +* New Location `enum` is introduced for easily changing the client location/baseUrl. +* New `client.openConnection()` and `client.closeConnection()` is introduced to connect/disconnect user WS connection. * New `client.partialUpdateMessage` and `channel.partialUpdateMessage` methods * `connectWebSocket` parameter in connect user calls to use the client in "connection-less" mode. @@ -253,29 +253,29 @@ dependencies: Upon doing this, all breaking changes from the package will take immediate effect. Here are steps to remedy the issues: -1) Change over the constructor of `connectUserWithProvider()` to the new format which has `tokenProvider` as a required param. +1) Change over the constructor of `connectUserWithProvider()` to the new format which has `tokenProvider` as a required parameter. 2) We added more nuance to `disconnectUser()` by adding two new methods - one to close the connection and the other to disconnect the user. This allows more fine-grained control of disconnection. - * `client.closeConnection()` -> for closing user websocket connection. + * `client.closeConnection()` -> for closing user web socket connection. * `client.disconnectUser()` -> for disconnecting user and resetting client state. 3) We refactored how we handle errors - new error types are now introduced that replace ApiError. * `StreamChatError` -> parent type for all the stream errors. - * `StreamWebSocketError` -> for user websocket related errors. + * `StreamWebSocketError` -> for user web socket related errors. * `StreamChatNetworkError` -> for network related errors. 4) We changed over from a map full of options to a more type-safe and sound approach by changing over to explicit parameters. Use these explicit parameters in the query parameters instead of the option keys: -* `client.queryChannels()`, `channel.query()` options param is removed in favor of individual params +* `client.queryChannels()`, `channel.query()` options parameter is removed in favor of individual parameters * `option.state` -> `bool state` * `option.watch` -> `bool watch` * `option.presence` -> `bool presence` -* `client.queryUsers()` options param is removed in favor of individual params +* `client.queryUsers()` options parameter is removed in favor of individual parameters * `option.presence` -> `bool presence` 5) We added type-safe filters to make filtering in the app easier. Change over the filters to the diff --git a/docusaurus/flutter_versioned_docs/version-3.x.x/Flutter/guides/understanding_filters.mdx b/docusaurus/flutter_versioned_docs/version-3.x.x/Flutter/guides/understanding_filters.mdx index 292afd072..45810913e 100644 --- a/docusaurus/flutter_versioned_docs/version-3.x.x/Flutter/guides/understanding_filters.mdx +++ b/docusaurus/flutter_versioned_docs/version-3.x.x/Flutter/guides/understanding_filters.mdx @@ -24,7 +24,7 @@ Filter.equal('type', 'messaging'), #### Filter.notEqual -The 'notEqual' filter gets the objects where the given key does not have the specified value. +The `notEqual` filter gets the objects where the given key does not have the specified value. ```dart Filter.notEqual('type', 'messaging'), @@ -64,20 +64,20 @@ Filter.lessOrEqual('count', 5), #### Filter.in_ -The 'in_' filter allows getting objects where the key matches any in a specified array. +The ``in_` filter allows getting objects where the key matches any in a specified array. ```dart Filter.in_('members', [user.id]) ``` :::note -Since 'in' is a keyword in Dart, the filter has an underscore added. This does not apply to the 'notIn' +Since `in` is a keyword in Dart, the filter has an underscore added. This does not apply to the `notIn` keyword. ::: #### Filter.notIn -The 'notIn' filter allows getting objects where the key matches none in a specified array. +The `notIn` filter allows getting objects where the key matches none in a specified array. ```dart Filter.notIn('members', [user.id]) @@ -109,7 +109,7 @@ Filter.exists('name') #### Filter.notExists -The 'notExists' filter checks if the specified key doesn't exist. This is a simplified call to `Filter.exists` +The `notExists` filter checks if the specified key doesn't exist. This is a simplified call to `Filter.exists` with the value set to false. ```dart diff --git a/docusaurus/flutter_versioned_docs/version-3.x.x/Flutter/guides/user_token_generation_with_firebase_auth.mdx b/docusaurus/flutter_versioned_docs/version-3.x.x/Flutter/guides/user_token_generation_with_firebase_auth.mdx index 56192f537..988684001 100644 --- a/docusaurus/flutter_versioned_docs/version-3.x.x/Flutter/guides/user_token_generation_with_firebase_auth.mdx +++ b/docusaurus/flutter_versioned_docs/version-3.x.x/Flutter/guides/user_token_generation_with_firebase_auth.mdx @@ -155,7 +155,7 @@ Running the above will give this: ![](../assets/authentication_demo_app.jpg) The `Auth` widget handles all of the authentication logic. It initializes a `FirebaseAuth.instance` and uses that -in the `createAccount`, `signIn` and `signOut` methods. There is a button to envoke each of these methods. +in the `createAccount`, `signIn` and `signOut` methods. There is a button to invoke each of these methods. The `FirebaseFunctions.instance` will be used later in this guide. @@ -289,7 +289,7 @@ firebase deploy --only functions ### Create a Stream User and Get the User's Token In the `createStreamUserAndGetToken` cloud function you create an `onCall` HTTPS handler, which exposes -a cloud function that can be envoked from your Flutter app. +a cloud function that can be invoked from your Flutter app. ```js // Create a Stream user and return auth token. @@ -325,13 +325,13 @@ by ensuring that `context.auth` is not null. If it is null, then it throws an `H message. This error can be caught in your Flutter application. If the caller is authenticated the function proceeds to use the `serverClient` to create a new Stream Chat -user by calling the `upsertUser` method and passing in some user data. It uses the authenticated caller's **uid** as an **id**. +user by calling the `upsertUser` method and passing in some user data. It uses the authenticated caller's **`uid`** as an **id**. After the user is created it generates a token for that user. This token is then returned to the caller. To call this from Flutter, you will need to use the `cloud_functions` package. -Update the **createAccount** method in your Flutter code to the following: +Update the **`createAccount`** method in your Flutter code to the following: ```dart Future createAccount() async { @@ -355,7 +355,7 @@ in the request. Once you have the Stream user token, you can authenticate your Stream Chat user as you normally would. -Please see our [initialization documention](https://getstream.io/chat/docs/flutter-dart/init_and_users/?language=dart) for more information. +Please see our [initialization documentation](https://getstream.io/chat/docs/flutter-dart/init_and_users/?language=dart) for more information. As you can see below, the User ID matches on both Firebase's and Stream's user database. @@ -373,7 +373,7 @@ As you can see below, the User ID matches on both Firebase's and Stream's user d The `getStreamUserToken` cloud function is very similar to the `createStreamUserAndGetToken` function. The only difference is that it only creates a user token and does not create a new user account on Stream. -Update the **signIn** method in your Flutter code to the following: +Update the **`signIn`** method in your Flutter code to the following: ```dart Future signIn() async { @@ -434,7 +434,7 @@ exports.deleteStreamUser = functions.auth.user().onDelete((user, context) => { ``` In this function, you are listening to delete events on Firebase auth. When an account is deleted, this function will be triggered, and you can get the -user's **uid** and call the `deleteUser` method on the `serverClient`. +user's **`uid`** and call the `deleteUser` method on the `serverClient`. This is not an external cloud function; it can only be triggered when an account is deleted. diff --git a/docusaurus/flutter_versioned_docs/version-3.x.x/Flutter/stream_chat_flutter/channel_list_header.mdx b/docusaurus/flutter_versioned_docs/version-3.x.x/Flutter/stream_chat_flutter/channel_list_header.mdx index d6930cb45..8979d3781 100644 --- a/docusaurus/flutter_versioned_docs/version-3.x.x/Flutter/stream_chat_flutter/channel_list_header.mdx +++ b/docusaurus/flutter_versioned_docs/version-3.x.x/Flutter/stream_chat_flutter/channel_list_header.mdx @@ -60,7 +60,7 @@ ChannelListHeader( ![](../assets/channel_list_header_custom_subtitle.png) -The `titleBuilder` param helps you build different titles depending on the connection state: +The `titleBuilder` parameter helps you build different titles depending on the connection state: ```dart //... diff --git a/docusaurus/flutter_versioned_docs/version-3.x.x/Flutter/stream_chat_flutter/channel_list_view.mdx b/docusaurus/flutter_versioned_docs/version-3.x.x/Flutter/stream_chat_flutter/channel_list_view.mdx index eb7baf207..547e47b99 100644 --- a/docusaurus/flutter_versioned_docs/version-3.x.x/Flutter/stream_chat_flutter/channel_list_view.mdx +++ b/docusaurus/flutter_versioned_docs/version-3.x.x/Flutter/stream_chat_flutter/channel_list_view.mdx @@ -25,7 +25,7 @@ widget. ### Basic Example Here is a basic example of the `ChannelListView` widget. It consists of the main widget itself, a `Filter` -to filter only the channels that the user is a part of, sorting by last message time, pagination params, +to filter only the channels that the user is a part of, sorting by last message time, pagination parameters, and the widget to use when a particular channel is clicked. ```dart @@ -54,7 +54,7 @@ the widget. ### Customizing the Channel Preview A common aspect of the widget needed to be tweaked according to each app is the Channel Preview (the -Channel tile in the list). To do this, we use the `channelPreviewBuilder` param like this: +Channel tile in the list). To do this, we use the `channelPreviewBuilder` parameter like this: ```dart ChannelListView( @@ -90,7 +90,7 @@ This adds two basic actions - info and delete: ![](../assets/swipe_channel.png) -To add custom actions of your own, use the `swipeActions` param: +To add custom actions of your own, use the `swipeActions` parameter: ```dart ChannelListView( diff --git a/docusaurus/flutter_versioned_docs/version-3.x.x/Flutter/stream_chat_flutter/setup.mdx b/docusaurus/flutter_versioned_docs/version-3.x.x/Flutter/stream_chat_flutter/setup.mdx index 22e5c6c54..6b33e612f 100644 --- a/docusaurus/flutter_versioned_docs/version-3.x.x/Flutter/stream_chat_flutter/setup.mdx +++ b/docusaurus/flutter_versioned_docs/version-3.x.x/Flutter/stream_chat_flutter/setup.mdx @@ -41,8 +41,8 @@ which will be addressed by the respective plugin creators over time. The library uses [flutter file picker plugin](https://github.com/miguelpruivo/flutter_file_picker) to pick files from the os. Follow [this wiki](https://github.com/miguelpruivo/flutter_file_picker/wiki/Setup#ios) to fulfill iOS requirements. -We also use [video_player](https://pub.dev/packages/video_player) to reproduce videos. +We also use [`video_player`](https://pub.dev/packages/video_player) to reproduce videos. Follow [this guide](https://pub.dev/packages/video_player#installation) to fulfill the requirements. -To pick images from the camera, we use the [image_picker](https://pub.dev/packages/image_picker) plugin. +To pick images from the camera, we use the [`image_picker`](https://pub.dev/packages/image_picker) plugin. Follow [these instructions](https://pub.dev/packages/image_picker#ios) to check the requirements. diff --git a/docusaurus/flutter_versioned_docs/version-3.x.x/Flutter/stream_chat_flutter_core/channel_list_core.mdx b/docusaurus/flutter_versioned_docs/version-3.x.x/Flutter/stream_chat_flutter_core/channel_list_core.mdx index 4196a14c9..aa1490f2d 100644 --- a/docusaurus/flutter_versioned_docs/version-3.x.x/Flutter/stream_chat_flutter_core/channel_list_core.mdx +++ b/docusaurus/flutter_versioned_docs/version-3.x.x/Flutter/stream_chat_flutter_core/channel_list_core.mdx @@ -13,7 +13,7 @@ according to the filters and sort order given. However, in some cases, implement that cannot be done using the customization approaches given in the widget. To do this, we extracted the logic required for fetching channels into a 'Core' widget - a widget that -fetches channels in the expected way via the usual params but does not supply any UI and instead +fetches channels in the expected way via the usual parameters but does not supply any UI and instead exposes builders to build the UI in situations such as loading, empty data, errors, and on data received. ### Basic Example diff --git a/docusaurus/flutter_versioned_docs/version-3.x.x/Flutter/stream_chat_flutter_core/message_list_core.mdx b/docusaurus/flutter_versioned_docs/version-3.x.x/Flutter/stream_chat_flutter_core/message_list_core.mdx index 5fd5877ad..7302ead63 100644 --- a/docusaurus/flutter_versioned_docs/version-3.x.x/Flutter/stream_chat_flutter_core/message_list_core.mdx +++ b/docusaurus/flutter_versioned_docs/version-3.x.x/Flutter/stream_chat_flutter_core/message_list_core.mdx @@ -13,7 +13,7 @@ according to the filters and sort order given. However, in some cases, implement that cannot be done using the customization approaches given in the widget. To do this, we extracted the logic required for fetching channels into a 'Core' widget - a widget that -fetches channels in the expected way via the usual params but does not supply any UI and instead +fetches channels in the expected way via the usual parameters but does not supply any UI and instead exposes builders to build the UI in situations such as loading, empty data, errors, and on data received. ### Basic Example diff --git a/docusaurus/flutter_versioned_docs/version-3.x.x/Flutter/stream_chat_flutter_core/message_search_list_core.mdx b/docusaurus/flutter_versioned_docs/version-3.x.x/Flutter/stream_chat_flutter_core/message_search_list_core.mdx index f3be5e85d..bd4ad95d8 100644 --- a/docusaurus/flutter_versioned_docs/version-3.x.x/Flutter/stream_chat_flutter_core/message_search_list_core.mdx +++ b/docusaurus/flutter_versioned_docs/version-3.x.x/Flutter/stream_chat_flutter_core/message_search_list_core.mdx @@ -13,7 +13,7 @@ according to the filters and sort order given. However, in some cases, implement that cannot be done using the customization approaches given in the widget. To do this, we extracted the logic required for fetching channels into a 'Core' widget - a widget that -fetches channels in the expected way via the usual params but does not supply any UI and instead +fetches channels in the expected way via the usual parameters but does not supply any UI and instead exposes builders to build the UI in situations such as loading, empty data, errors, and on data received. ### Basic Example diff --git a/docusaurus/flutter_versioned_docs/version-3.x.x/Flutter/stream_chat_flutter_core/stream_chat_core.mdx b/docusaurus/flutter_versioned_docs/version-3.x.x/Flutter/stream_chat_flutter_core/stream_chat_core.mdx index 2a43ae522..cc342ebf7 100644 --- a/docusaurus/flutter_versioned_docs/version-3.x.x/Flutter/stream_chat_flutter_core/stream_chat_core.mdx +++ b/docusaurus/flutter_versioned_docs/version-3.x.x/Flutter/stream_chat_flutter_core/stream_chat_core.mdx @@ -9,7 +9,7 @@ theme and initialisations. `StreamChatCore` is used to provide information about the chat client to the widget tree. This Widget is used to react to life cycle changes and system updates. -When the app goes into the background, the websocket connection is automatically closed and when it goes back to foreground the connection is opened again. +When the app goes into the background, the web socket connection is automatically closed and when it goes back to foreground the connection is opened again. Like the `StreamChat` widget in the higher level UI package, the `StreamChatCore` widget should be on the top level before using any Stream functionality: diff --git a/docusaurus/flutter_versioned_docs/version-3.x.x/Flutter/stream_chat_flutter_core/user_list_core.mdx b/docusaurus/flutter_versioned_docs/version-3.x.x/Flutter/stream_chat_flutter_core/user_list_core.mdx index 622d00255..130155cd3 100644 --- a/docusaurus/flutter_versioned_docs/version-3.x.x/Flutter/stream_chat_flutter_core/user_list_core.mdx +++ b/docusaurus/flutter_versioned_docs/version-3.x.x/Flutter/stream_chat_flutter_core/user_list_core.mdx @@ -13,7 +13,7 @@ according to the filters and sort order given. However, in some cases, implement that cannot be done using the customization approaches given in the widget. To do this, we extracted the logic required for fetching channels into a 'Core' widget - a widget that -fetches channels in the expected way via the usual params but does not supply any UI and instead +fetches channels in the expected way via the usual parameters but does not supply any UI and instead exposes builders to build the UI in situations such as loading, empty data, errors, and on data received. ### Basic Example diff --git a/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/basics/choose_package.mdx b/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/basics/choose_package.mdx index 8be73f010..5d1acf796 100644 --- a/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/basics/choose_package.mdx +++ b/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/basics/choose_package.mdx @@ -14,7 +14,7 @@ which allows you persist data locally which works with all packages. ### How do I choose? -#### The case for stream_chat_flutter +#### The case for `stream_chat_flutter` For the quickest way to integrate Stream Chat with your app, the UI SDK (`stream_chat_flutter`) is the way to go. `stream_chat_flutter` contains prebuilt components that manage most operations like data @@ -30,26 +30,26 @@ to request this through our support channels. Summary: -For the quickest and easiest way to add Chat to your app with prebuilt UI components, use stream_chat_flutter +For the quickest and easiest way to add Chat to your app with prebuilt UI components, use `stream_chat_flutter` -#### The case for stream_chat_flutter_core +#### The case for `stream_chat_flutter_core` -If your application involves UI that does not fit in with the stream_chat_flutter components, stream_chat_flutter_core +If your application involves UI that does not fit in with the `stream_chat_flutter` components, `stream_chat_flutter_core` strips away the UI associated with the components and provides the data fetching and manipulation capabilities while supplying builders for UI. This allows you to implement your own UI and themes completely independently while not worrying about writing functions for data and pagination. Summary: -For implementing your own custom UI while not having to worry about lower level API calls, use stream_chat_flutter_core. +For implementing your own custom UI while not having to worry about lower level API calls, use `stream_chat_flutter_core`. -#### The case for stream_chat +#### The case for `stream_chat` -The stream_chat package is the Low-level Client (LLC) of Stream Chat in Flutter. This package wraps +The `stream_chat` package is the Low-level Client (LLC) of Stream Chat in Flutter. This package wraps the underlying functionality of Stream Chat and allows the most customization in terms of UI, data, and architecture. Summary: -For the most control over the SDK and dealing with low level calls to the API, use stream_chat. +For the most control over the SDK and dealing with low level calls to the API, use `stream_chat`. diff --git a/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/basics/introduction.mdx b/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/basics/introduction.mdx index 99170774e..c98aa34fa 100644 --- a/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/basics/introduction.mdx +++ b/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/basics/introduction.mdx @@ -20,18 +20,18 @@ giving you complete control to ones that give you a rich out-of-the-box chat exp The packages that make up the Stream Chat SDK are: -1. Low Level Client (stream_chat): a pure Dart package that can be used on any Dart project. +1. Low Level Client (stre`am_chat): a pure Dart package that can be used on any Dart project. It provides a low-level client to access the Stream Chat service. -2. Core (stream_chat_flutter_core): provides business logic to fetch common things required +2. Core (`stream_chat_flutter_core`): provides business logic to fetch common things required for integrating Stream Chat into your application. The core package allows more customisation and hence provides business logic but no UI components. -3. UI (stream_chat_flutter): this library includes both a low-level chat SDK and a set of -reusable and customisable UI components. -4. Persistence (stream_chat_persistence): provides a persistence client for fetching and +3. UI (`stream_chat_flutter`): this library includes both a low-level chat SDK and a set of +reusable and customizable UI components. +4. Persistence (`stream_chat_persistence`): provides a persistence client for fetching and saving chat data locally. -5. Localizations (stream_chat_localizations): provides a set of localizations for the SDK. +5. Localizations (`stream_chat_localizations`): provides a set of localizations for the SDK. -We recommend building prototypes using the full UI package, [stream_chat_flutter](https://pub.dev/packages/stream_chat_flutter), +We recommend building prototypes using the full UI package, [`stream_chat_flutter`](https://pub.dev/packages/stream_chat_flutter), since it contains UI widgets already integrated with Stream's API. It is the fastest way to get up and running using Stream chat in your app. @@ -39,7 +39,7 @@ The Flutter SDK enables you to build any type of chat or messaging experience fo and Desktop. If you're building a very custom UI and would prefer a more lean package, -[stream_chat_flutter_core](https://pub.dev/packages/stream_chat_flutter_core) will be suited to this +[`stream_chat_flutter_core`](https://pub.dev/packages/stream_chat_flutter_core) will be suited to this use case. Core allows you to build custom, expressive UIs while retaining the benefits of our full Flutter SDK. APIs for accessing and controlling users, sending messages, and so forth are seamlessly integrated into this package and accessible via providers and builders. @@ -69,7 +69,7 @@ While this is a simplistic overview of the service, the Flutter SDK handles the Before reading the docs, consider trying our [online API tour](https://getstream.io/chat/get_started/), it is a nice way to learn how the API works. -It's in-browser so you'll need to use Javascript but the core conceps are pretty much the same as Dart. +It's in-browser so you'll need to use JavaScript but the core concepts are pretty much the same as Dart. You may also like to look at the [Flutter tutorial](https://getstream.io/chat/flutter/tutorial/) which focuses on using the UI package to get Stream Chat integrated into a Flutter app. diff --git a/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/basics/versioning_policy.mdx b/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/basics/versioning_policy.mdx index 48f25d66b..99ec8111d 100644 --- a/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/basics/versioning_policy.mdx +++ b/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/basics/versioning_policy.mdx @@ -4,7 +4,7 @@ sidebar_position: 3 title: Versioning Policy --- -All of the Stream Chat packages follow [semantic versioning (semver)](https://semver.org/). +All of the Stream Chat packages follow [semantic versioning](https://semver.org/). That means that with a version number x.y.z (major.minor.patch): - When releasing bug fixes (backwards compatible), we make a patch release by changing the z number (ex: 3.6.2 to 3.6.3). A bug fix is defined as an internal change that fixes incorrect behavior. diff --git a/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/guides/adding_custom_attachments.mdx b/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/guides/adding_custom_attachments.mdx index 510e8c22a..2d38cab11 100644 --- a/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/guides/adding_custom_attachments.mdx +++ b/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/guides/adding_custom_attachments.mdx @@ -27,7 +27,7 @@ Let's build an example of location sharing option in the app: ![](../assets/location_sharing_example.jpg) -* Show a "Share Location" button next to StreamMessageInput Textfield. +* Show a "Share Location" button next to StreamMessageInput `Textfield`. * When the user presses this button, it should fetch the current location coordinates of the user, and send a message on the channel as follows: @@ -47,7 +47,7 @@ Message( ) ``` -For our example, we are going to use [geolocator](https://pub.dev/packages/geolocator) library. +For our example, we are going to use [`geolocator`](https://pub.dev/packages/geolocator) library. Please check their [setup instructions](https://pub.dev/packages/geolocator) on their docs. NOTE: If you are testing on iOS simulator, you will need to set some dummy coordinates, as mentioned [here](https://stackoverflow.com/a/31238119/7489541). @@ -55,7 +55,7 @@ Also don't forget to enable "location update" capability in background mode, fro On the receiver end, `location` type attachment should be rendered in map view, in the `StreamMessageListView`. We are going to use [Google Static Maps API](https://developers.google.com/maps/documentation/maps-static/overview) to render the map in the message. -You can use other libraries as well such as [google_maps_flutter](https://pub.dev/packages/google_maps_flutter). +You can use other libraries as well such as [`google_maps_flutter`](https://pub.dev/packages/google_maps_flutter). First, we add a button which when clicked fetches and shares location into the `MessageInput`: diff --git a/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/guides/adding_local_data_persistence.mdx b/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/guides/adding_local_data_persistence.mdx index e6283ca04..452ffcaee 100644 --- a/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/guides/adding_local_data_persistence.mdx +++ b/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/guides/adding_local_data_persistence.mdx @@ -28,7 +28,7 @@ final client = StreamChatClient( )..chatPersistenceClient = CustomChatPersistentClient(); ``` -We provide an official persistent client in the [stream_chat_persistence](https://pub.dev/packages/stream_chat_persistence) +We provide an official persistent client in the [`stream_chat_persistence`](https://pub.dev/packages/stream_chat_persistence) package that works using the library [moor](https://moor.simonbinder.eu), an SQLite ORM. Add this to your package's `pubspec.yaml` file, using the latest version. diff --git a/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/guides/adding_push_notifications.mdx b/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/guides/adding_push_notifications.mdx index 328ba5462..3ec661aa7 100644 --- a/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/guides/adding_push_notifications.mdx +++ b/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/guides/adding_push_notifications.mdx @@ -21,7 +21,7 @@ Make sure to check [this section](https://getstream.io/chat/docs/flutter-dart/pu ### Setup FCM -To integrate push notifications in your Flutter app you need to use the package [firebase_messaging](https://pub.dev/packages/firebase_messaging). +To integrate push notifications in your Flutter app you need to use the package [`firebase_messaging`](https://pub.dev/packages/firebase_messaging). Follow the [Firebase documentation](https://firebase.flutter.dev/docs/messaging/overview/) to know how to set up the plugin for both Android and iOS. @@ -61,7 +61,7 @@ Upload the `Server Key` in your chat dashboard :::note -We are setting up the Android section, but this will work for both Android and iOS if you're using Firebase for both of them! +We are setting up the Android section, but this will work for both Android and iOS if you're using Firebase for both of them. ::: #### Step 6 @@ -97,21 +97,21 @@ firebaseMessaging.onTokenRefresh.listen((token) { ### Possible issues -We only send push notifications when the user doesn't have any active websocket connection (which is established when you call `client.connectUser`). If you set the [onBackgroundEventReceived](https://pub.dev/documentation/stream_chat_flutter/latest/stream_chat_flutter/StreamChat/onBackgroundEventReceived.html) property of the StreamChat widget, when your app goes to background, your device will keep the ws connection alive for 1 minute, and so within this period, you won't receive any push notification. +We only send push notifications when the user doesn't have any active web socket connection (which is established when you call `client.connectUser`). If you set the [onBackgroundEventReceived](https://pub.dev/documentation/stream_chat_flutter/latest/stream_chat_flutter/StreamChat/onBackgroundEventReceived.html) property of the StreamChat widget, when your app goes to background, your device will keep the WS connection alive for 1 minute, and so within this period, you won't receive any push notification. Make sure to read the [general push docs](https://getstream.io/chat/docs/flutter-dart/push_introduction/?language=dart) in order to avoid known gotchas that may make your relationship with notifications go bad 😢 ### Testing if Push Notifications are Setup Correctly -If you're not sure if you've set up push notifications correctly (e.g. you don't always receive them, they work unreliably), you can follow these steps to make sure your config is correct and working: +If you're not sure if you've set up push notifications correctly (for example you don't always receive them, they work unreliably), you can follow these steps to make sure your configuration is correct and working: -1. Clone our repo for push testing git clone git@github.com:GetStream/chat-push-test.git +1. Clone our repository for push testing git clone git@github.com:GetStream/chat-push-test.git 2. `cd flutter` 3. In folder run `flutter pub get` -4. Input your api key and secret in `lib/main.dart` +4. Input your API key and secret in `lib/main.dart` 5. Change the bundle identifier/application ID and development team/user so you can run the app in your device (**do not** run on iOS simulator, Android emulator is fine) @@ -137,11 +137,11 @@ You should get a test push notification The [StreamChat](https://pub.dev/documentation/stream_chat_flutter/latest/stream_chat_flutter/StreamChat-class.html) widget lets you define a [onBackgroundEventReceived](https://pub.dev/documentation/stream_chat_flutter/latest/stream_chat_flutter/StreamChat/onBackgroundEventReceived.html) handler in order to handle events while the app is in the background, but the client is still connected. -This is useful because it lets you keep the connection alive in cases in which the app goes in the background just for some seconds (eg: multitasking, picking pictures from the gallery...) +This is useful because it lets you keep the connection alive in cases in which the app goes in the background just for some seconds (for example multitasking, picking pictures from the gallery...) You can even customize the [backgroundKeepAlive](https://pub.dev/documentation/stream_chat_flutter/latest/stream_chat_flutter/StreamChat/backgroundKeepAlive.html) duration. -In order to show notifications in such a case we suggest using the package [flutter_local_notifications](https://pub.dev/packages/flutter_local_notifications); follow the package guide to successfully set up the plugin. +In order to show notifications in such a case we suggest using the package [`flutter_local_notifications`](https://pub.dev/packages/flutter_local_notifications); follow the package guide to successfully set up the plugin. Once that's done you should set the [onBackgroundEventReceived](https://pub.dev/documentation/stream_chat_flutter/latest/stream_chat_flutter/StreamChat/onBackgroundEventReceived.html); here is an example: @@ -234,7 +234,7 @@ To do this we need to update the push notification data payload at Stream Dashbo } ``` -Then we need to integrate the package [stream_chat_persistence](https://pub.dev/packages/stream_chat_persistence) in our app that exports a persistence client, learn [here](https://pub.dev/packages/stream_chat_persistence#usage) how to set it up. +Then we need to integrate the package [`stream_chat_persistence`](https://pub.dev/packages/stream_chat_persistence) in our app that exports a persistence client, learn [here](https://pub.dev/packages/stream_chat_persistence#usage) how to set it up. Then during the call `firebaseMessaging.configure(...)` we need to set the `onBackgroundMessage` parameter using a TOP-LEVEL or STATIC function to handle background messages; here is an example: diff --git a/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/guides/adding_push_notifications_v2.mdx b/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/guides/adding_push_notifications_v2.mdx index 917d92165..85933e97f 100644 --- a/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/guides/adding_push_notifications_v2.mdx +++ b/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/guides/adding_push_notifications_v2.mdx @@ -17,7 +17,7 @@ You can read more about Stream’s [push delivery logic](https://getstream.io/ch ### Setup FCM -To integrate push notifications in your Flutter app, you need to use the package [firebase_messaging](https://pub.dev/packages/firebase_messaging). +To integrate push notifications in your Flutter app, you need to use the package [`firebase_messaging`](https://pub.dev/packages/firebase_messaging). Follow the [Firebase documentation](https://firebase.flutter.dev/docs/messaging/overview/) to set up the plugin for Android and iOS. @@ -55,7 +55,7 @@ You can upload your Firebase credentials using either the dashboard or the app s ![](../assets/firebase_notifications_toggle-5aeabfcbdc24cb8f1fea7d41d0e845fc.png) -3. Enter your Firebase Credentials and press "Save". +3. Enter your Firebase Credentials and press `"Save"`. ##### Using the API @@ -86,7 +86,7 @@ firebaseMessaging.onTokenRefresh.listen((token) { }); ``` -Push Notifications v2 also supports specifying a name to the push device tokens you register. By setting the optional `pushProviderName` param in the `addDevice` call you can support different configurations between the device and the `PushProvider`. +Push Notifications v2 also supports specifying a name to the push device tokens you register. By setting the optional `pushProviderName` parameter in the `addDevice` call you can support different configurations between the device and the `PushProvider`. ```dart firebaseMessaging.onTokenRefresh.listen((token) { @@ -105,7 +105,7 @@ On iOS we send both a **notification** and a **data** payload. This means you don't need to do anything special to get the notification to show up. However, you might want to handle the data payload to perform some logic when the user taps on the notification. To update the template, you can use a backend SDK. -For example, using the javascript SDK: +For example, using the JavaScript SDK: ```js const client = StreamChat.getInstance(‘api_key’, ‘api_secret’); @@ -181,13 +181,13 @@ void handleNotification( FirebaseMessaging.onBackgroundMessage(onBackgroundMessage); ``` -In the above example, you get the message details using the `getMessage` method and then you use the [flutter_local_notifications](https://pub.dev/packages/flutter_local_notifications) package to show the actual notification. +In the above example, you get the message details using the `getMessage` method and then you use the [`flutter_local_notifications`](https://pub.dev/packages/flutter_local_notifications) package to show the actual notification. ##### Using a Template on Android It's still possible to add a **notification** payload to Android notifications. You can do so by adding a template using a backend SDK. -For example, using the javascript SDK: +For example, using the JavaScript SDK: ```js const client = StreamChat.getInstance(‘api_key’, ‘api_secret’); @@ -211,11 +211,11 @@ Make sure to read the [general push notification docs](https://getstream.io/chat ### Testing if Push Notifications are Setup Correctly -If you're not sure whether you've set up push notifications correctly, for example, you don't always receive them, or they don’t work reliably, then you can follow these steps to make sure your config is correct and working: -1. Clone our repo for push testing: `git clone git@github.com:GetStream/chat-push-test.git` +If you're not sure whether you've set up push notifications correctly, for example, you don't always receive them, or they don’t work reliably, then you can follow these steps to make sure your configuration is correct and working: +1. Clone our repository for push testing: `git clone git@github.com:GetStream/chat-push-test.git` 2. `cd flutter` 3. In that folder run `flutter pub get` -4. Input your api key and secret in `lib/main.dart` +4. Input your API key and secret in `lib/main.dart` 5. Change the bundle identifier/application ID and development team/user so you can run the app on your physical device.**Do not** run on an iOS simulator, as it will not work. Testing on an Android emulator is fine. 6. Add your `google-services.json/GoogleService-Info.plist` 7. Run the app @@ -257,7 +257,7 @@ Take a look at the [Stream Chat v1 sample app](https://github.com/GetStream/flut When the app is closed you may want to save received messages when you receive them via a notification so that later on when you open the app they're already there. -To do this you need to integrate the package [stream_chat_persistence](https://pub.dev/packages/stream_chat_persistence) in our app that exports a persistence client, see [here](https://pub.dev/packages/stream_chat_persistence#usage) how to set it up. +To do this you need to integrate the package [`stream_chat_persistence`](https://pub.dev/packages/stream_chat_persistence) in our app that exports a persistence client, see [here](https://pub.dev/packages/stream_chat_persistence#usage) how to set it up. Then calling `FirebaseMessaging.onBackgroundMessage(...)` you need to use a TOP-LEVEL or STATIC function to handle background messages; here is an example: diff --git a/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/guides/autocomplete_triggers.mdx b/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/guides/autocomplete_triggers.mdx index 50bfb6a07..b2c94be51 100644 --- a/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/guides/autocomplete_triggers.mdx +++ b/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/guides/autocomplete_triggers.mdx @@ -19,7 +19,7 @@ This widget will be used to show the autocomplete options. For this example we're using two external dependencies: - [emojis](https://pub.dev/packages/emojis) -- [substring_highlight](https://pub.dev/packages/substring_highlight) +- [`substring_highlight`](https://pub.dev/packages/substring_highlight) ```dart import 'package:emojis/emoji.dart'; diff --git a/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/guides/customize_message_actions.mdx b/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/guides/customize_message_actions.mdx index 12cc77157..f390bb4cd 100644 --- a/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/guides/customize_message_actions.mdx +++ b/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/guides/customize_message_actions.mdx @@ -37,7 +37,7 @@ Additionally, pinning a message requires you to add the roles which are allowed ### Partially remove some message actions -For example, if you only want to keep "copy message" and "delete message", +For example, if you only want to keep `"copy message"` and `"delete message"` here is how to do it using the `messageBuilder` with our `StreamMessageWidget`. ```dart diff --git a/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/guides/end_to_end_chat_encryption.mdx b/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/guides/end_to_end_chat_encryption.mdx index 8a463af49..fd8ed102a 100644 --- a/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/guides/end_to_end_chat_encryption.mdx +++ b/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/guides/end_to_end_chat_encryption.mdx @@ -36,7 +36,7 @@ Check out the diagram below for an example: ### Dependencies -Add the [webcrypto](https://pub.dev/packages/webcrypto) package in your `pubspec.yaml` file. +Add the [web cryptographic](https://pub.dev/packages/webcrypto) package in your `pubspec.yaml` file. ```yaml dependencies: @@ -76,9 +76,9 @@ class JsonWebKeyPair { } ``` -### Generate a Crypto Key +### Generate a Cryptographic Key -Next, create a symmetric **Crypto Key** using the keys generated in the previous step. +Next, create a symmetric **Cryptographic Key** using the keys generated in the previous step. You will use those keys to encrypt and decrypt messages. ```dart @@ -107,7 +107,7 @@ Future> deriveKey(String senderJwk, String receiverJwk) async { ### Encrypting Messages -Once you have generated the **Crypto Key**, you're ready to encrypt the message. +Once you have generated the **Cryptographic Key**, you're ready to encrypt the message. You can use the **AES-GCM** algorithm for its known security and performance balance and good browser availability. ```dart @@ -253,6 +253,6 @@ StreamMessageListView( ), ``` -That's it! That's all you need to implement E2EE in a Stream powered chat app. +That's it. That's all you need to implement E2EE in a Stream powered chat app. For more details, check out our [end-to-end encrypted chat article](https://getstream.io/blog/end-to-end-encrypted-chat-in-flutter/#whats-end-to-end-encryption). diff --git a/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/guides/migration_guide_4_0.mdx b/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/guides/migration_guide_4_0.mdx index 887cef3ae..80bb44269 100644 --- a/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/guides/migration_guide_4_0.mdx +++ b/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/guides/migration_guide_4_0.mdx @@ -13,7 +13,7 @@ If you find any bugs or have any questions, please file an [issue on our GitHub Code examples: - See our [Stream Chat Flutter tutorial](https://getstream.io/chat/flutter/tutorial/) for an up-to-date guide using the latest Stream Chat version. -- See the [Stream Flutter Samples repository](https://github.com/GetStream/flutter-samples) with our fully-fledged messaging [sample application](https://github.com/GetStream/flutter-samples/tree/main/packages/stream_chat_v1). +- See the [Stream Flutter Samples repository](https://github.com/GetStream/flutter-samples) with our full fledged messaging [sample application](https://github.com/GetStream/flutter-samples/tree/main/packages/stream_chat_v1). All of our documentation has also been updated to support v4, so all of the guides and examples will have updated code. @@ -208,10 +208,10 @@ Let's explore some examples of the functional differences when using the new `St The **StreamChannelListController** provides various methods, such as: -- **deleteChannel** -- **loadMore** -- **muteChannel** -- **deleteChannel** +- **`deleteChannel`** +- **`loadMore`** +- **`muteChannel`** +- **`deleteChannel`** For a complete list with additional information, see the code documentation. @@ -536,7 +536,7 @@ Creating a separate controller allows easier control over the message input cont The widget is also separated into smaller components: `StreamCountDownButton`, `StreamAttachmentPicker`, etc. -> ❗The `MessageInputController` is exposed by the **stream_chat_flutter_core** package. This allows you to use the controller even if you're not using the UI components. +> ❗The `MessageInputController` is exposed by the **`stream_chat_flutter_core`** package. This allows you to use the controller even if you're not using the UI components. As a result of this extra control, it is no longer needed for the new `StreamMessageInput` widget to expose these `MessageInput` arguments: @@ -733,7 +733,7 @@ The controller makes it much simpler to dynamically modify the message input. ## Stream Chat Flutter Core -Various changes have been made to the Core package, most notably, the indroduction of all of the controllers mentioned above. +Various changes have been made to the Core package, most notably, the introduction of all of the controllers mentioned above. These controllers replace the business logic implementations (Bloc). Please note that this is not related to the well-known Flutter Bloc package, but instead refers to the naming we used for our business logic components. diff --git a/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/guides/slidable_channel_list_preview.mdx b/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/guides/slidable_channel_list_preview.mdx index 9d57e7092..a7ae55756 100644 --- a/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/guides/slidable_channel_list_preview.mdx +++ b/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/guides/slidable_channel_list_preview.mdx @@ -39,7 +39,7 @@ In this example, you are doing a few important things in the ChannelListPage wid - Using the **flutter_slidable** package to easily add slide functionality. - Passing in the `itemBuilder` argument for the **StreamChannelListView** widget. This gives access to the current **BuildContext**, **Channel**, and **StreamChannelListTile**, and allows you to create, or customize, the stream channel list tiles. - Returning a Slidable widget with two CustomSlidableAction widgets - to delete a channel and show more options. These widgets come from the flutter_slidable package. -- Adding `onPressed` behaviour to call `showConfirmationDialog` and `showChannelInfoModalBottomSheet`. These methods come from the **stream_chat_flutter** package. They have a few different on-tap callbacks you can supply, for example, `onViewInfoTap`. Alternatively, you can create custom dialogs from scratch. +- Adding `onPressed` behaviour to call `showConfirmationDialog` and `showChannelInfoModalBottomSheet`. These methods come from the **`stream_chat_flutter`** package. They have a few different on-tap callbacks you can supply, for example, `onViewInfoTap`. Alternatively, you can create custom dialog screens from scratch. - Using the **StreamChannelListController** to perform actions, such as, `deleteChannel`. ```dart diff --git a/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/guides/understanding_filters.mdx b/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/guides/understanding_filters.mdx index 292afd072..347ad17fa 100644 --- a/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/guides/understanding_filters.mdx +++ b/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/guides/understanding_filters.mdx @@ -24,7 +24,7 @@ Filter.equal('type', 'messaging'), #### Filter.notEqual -The 'notEqual' filter gets the objects where the given key does not have the specified value. +The `notEqual` filter gets the objects where the given key does not have the specified value. ```dart Filter.notEqual('type', 'messaging'), @@ -64,20 +64,20 @@ Filter.lessOrEqual('count', 5), #### Filter.in_ -The 'in_' filter allows getting objects where the key matches any in a specified array. +The `in_` filter allows getting objects where the key matches any in a specified array. ```dart Filter.in_('members', [user.id]) ``` :::note -Since 'in' is a keyword in Dart, the filter has an underscore added. This does not apply to the 'notIn' +Since `in` is a keyword in Dart, the filter has an underscore added. This does not apply to the `notIn` keyword. ::: #### Filter.notIn -The 'notIn' filter allows getting objects where the key matches none in a specified array. +The `notIn` filter allows getting objects where the key matches none in a specified array. ```dart Filter.notIn('members', [user.id]) @@ -109,7 +109,7 @@ Filter.exists('name') #### Filter.notExists -The 'notExists' filter checks if the specified key doesn't exist. This is a simplified call to `Filter.exists` +The `notExists` filter checks if the specified key doesn't exist. This is a simplified call to `Filter.exists` with the value set to false. ```dart diff --git a/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/guides/user_token_generation_with_firebase_auth.mdx b/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/guides/user_token_generation_with_firebase_auth.mdx index 56192f537..988684001 100644 --- a/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/guides/user_token_generation_with_firebase_auth.mdx +++ b/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/guides/user_token_generation_with_firebase_auth.mdx @@ -155,7 +155,7 @@ Running the above will give this: ![](../assets/authentication_demo_app.jpg) The `Auth` widget handles all of the authentication logic. It initializes a `FirebaseAuth.instance` and uses that -in the `createAccount`, `signIn` and `signOut` methods. There is a button to envoke each of these methods. +in the `createAccount`, `signIn` and `signOut` methods. There is a button to invoke each of these methods. The `FirebaseFunctions.instance` will be used later in this guide. @@ -289,7 +289,7 @@ firebase deploy --only functions ### Create a Stream User and Get the User's Token In the `createStreamUserAndGetToken` cloud function you create an `onCall` HTTPS handler, which exposes -a cloud function that can be envoked from your Flutter app. +a cloud function that can be invoked from your Flutter app. ```js // Create a Stream user and return auth token. @@ -325,13 +325,13 @@ by ensuring that `context.auth` is not null. If it is null, then it throws an `H message. This error can be caught in your Flutter application. If the caller is authenticated the function proceeds to use the `serverClient` to create a new Stream Chat -user by calling the `upsertUser` method and passing in some user data. It uses the authenticated caller's **uid** as an **id**. +user by calling the `upsertUser` method and passing in some user data. It uses the authenticated caller's **`uid`** as an **id**. After the user is created it generates a token for that user. This token is then returned to the caller. To call this from Flutter, you will need to use the `cloud_functions` package. -Update the **createAccount** method in your Flutter code to the following: +Update the **`createAccount`** method in your Flutter code to the following: ```dart Future createAccount() async { @@ -355,7 +355,7 @@ in the request. Once you have the Stream user token, you can authenticate your Stream Chat user as you normally would. -Please see our [initialization documention](https://getstream.io/chat/docs/flutter-dart/init_and_users/?language=dart) for more information. +Please see our [initialization documentation](https://getstream.io/chat/docs/flutter-dart/init_and_users/?language=dart) for more information. As you can see below, the User ID matches on both Firebase's and Stream's user database. @@ -373,7 +373,7 @@ As you can see below, the User ID matches on both Firebase's and Stream's user d The `getStreamUserToken` cloud function is very similar to the `createStreamUserAndGetToken` function. The only difference is that it only creates a user token and does not create a new user account on Stream. -Update the **signIn** method in your Flutter code to the following: +Update the **`signIn`** method in your Flutter code to the following: ```dart Future signIn() async { @@ -434,7 +434,7 @@ exports.deleteStreamUser = functions.auth.user().onDelete((user, context) => { ``` In this function, you are listening to delete events on Firebase auth. When an account is deleted, this function will be triggered, and you can get the -user's **uid** and call the `deleteUser` method on the `serverClient`. +user's **`uid`** and call the `deleteUser` method on the `serverClient`. This is not an external cloud function; it can only be triggered when an account is deleted. diff --git a/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/stream_chat_flutter/setup.mdx b/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/stream_chat_flutter/setup.mdx index 22e5c6c54..6b33e612f 100644 --- a/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/stream_chat_flutter/setup.mdx +++ b/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/stream_chat_flutter/setup.mdx @@ -41,8 +41,8 @@ which will be addressed by the respective plugin creators over time. The library uses [flutter file picker plugin](https://github.com/miguelpruivo/flutter_file_picker) to pick files from the os. Follow [this wiki](https://github.com/miguelpruivo/flutter_file_picker/wiki/Setup#ios) to fulfill iOS requirements. -We also use [video_player](https://pub.dev/packages/video_player) to reproduce videos. +We also use [`video_player`](https://pub.dev/packages/video_player) to reproduce videos. Follow [this guide](https://pub.dev/packages/video_player#installation) to fulfill the requirements. -To pick images from the camera, we use the [image_picker](https://pub.dev/packages/image_picker) plugin. +To pick images from the camera, we use the [`image_picker`](https://pub.dev/packages/image_picker) plugin. Follow [these instructions](https://pub.dev/packages/image_picker#ios) to check the requirements. diff --git a/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/stream_chat_flutter/stream_channel_list_header.mdx b/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/stream_chat_flutter/stream_channel_list_header.mdx index 4c8fbc632..e5b548e42 100644 --- a/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/stream_chat_flutter/stream_channel_list_header.mdx +++ b/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/stream_chat_flutter/stream_channel_list_header.mdx @@ -90,7 +90,7 @@ StreamChannelListHeader( ![](../assets/channel_list_header_custom_subtitle.png) -The `titleBuilder` param helps you build different titles depending on the connection state: +The `titleBuilder` parameter helps you build different titles depending on the connection state: ```dart //... diff --git a/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/stream_chat_flutter_core/message_list_core.mdx b/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/stream_chat_flutter_core/message_list_core.mdx index 57f06b2a9..2a20db928 100644 --- a/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/stream_chat_flutter_core/message_list_core.mdx +++ b/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/stream_chat_flutter_core/message_list_core.mdx @@ -15,7 +15,7 @@ according to the filters and sort order given. However, in some cases, implement that cannot be done using the customization approaches given in the widget. To do this, we extracted the logic required for fetching channels into a 'Core' widget - a widget that -fetches channels in the expected way via the usual params but does not supply any UI and instead +fetches channels in the expected way via the usual parameters but does not supply any UI and instead exposes builders to build the UI in situations such as loading, empty data, errors, and on data received. ### Basic Example diff --git a/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/stream_chat_flutter_core/stream_chat_core.mdx b/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/stream_chat_flutter_core/stream_chat_core.mdx index e3434e7f7..11743abfc 100644 --- a/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/stream_chat_flutter_core/stream_chat_core.mdx +++ b/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/stream_chat_flutter_core/stream_chat_core.mdx @@ -11,7 +11,7 @@ Find the pub.dev documentation [here](https://pub.dev/documentation/stream_chat_ `StreamChatCore` is used to provide information about the chat client to the widget tree. This Widget is used to react to life cycle changes and system updates. -When the app goes into the background, the websocket connection is automatically closed and when it goes back to foreground the connection is opened again. +When the app goes into the background, the web socket connection is automatically closed and when it goes back to foreground the connection is opened again. Like the `StreamChat` widget in the higher level UI package, the `StreamChatCore` widget should be on the top level before using any Stream functionality: diff --git a/packages/stream_chat/.gitignore b/packages/stream_chat/.gitignore index 2ea557c4f..3e9aac7c5 100644 --- a/packages/stream_chat/.gitignore +++ b/packages/stream_chat/.gitignore @@ -50,7 +50,7 @@ pubspec.lock # If you don't generate documentation locally you can remove this line. doc/api/ -# Avoid committing generated Javascript files: +# Avoid committing generated JavaScript files: *.dart.js *.info.json # Produced by the --dump-info flag. *.js # When generated by dart2js. Don't specify *.js if your diff --git a/packages/stream_chat/CHANGELOG.md b/packages/stream_chat/CHANGELOG.md index 2937a2c98..db5cf2abc 100644 --- a/packages/stream_chat/CHANGELOG.md +++ b/packages/stream_chat/CHANGELOG.md @@ -17,7 +17,7 @@ 🛑️ Breaking Changes from `5.0.0-beta.2` - `Channel.addMembers`, `Channel.removeMembers`, `Channel.inviteMembers` and `Channel.update` - positional params are now optional params. + positional parameters are now optional parameters. ```dart // previous @@ -390,21 +390,21 @@ the [V4 Migration Guide](https://getstream.io/chat/docs/sdk/flutter/guides/migra 🛑️ Breaking Changes from `1.5.3` - migrate this package to null safety -- `ConnectUserWithProvider` now requires `tokenProvider` as a required param. (Removed from the +- `ConnectUserWithProvider` now requires `tokenProvider` as a required parameter. (Removed from the constructor) - `client.disconnect()` is now divided into two different functions - - `client.closeConnection()` -> for closing user websocket connection. + - `client.closeConnection()` -> for closing user web socket connection. - `client.disconnectUser()` -> for disconnecting user and resetting client state. - `client.devToken()` now returns a `Token` model instead of `String`. - `ApiError` is removed in favor of `StreamChatError` - `StreamChatError` -> parent type for all the stream errors. - - `StreamWebSocketError` -> for user websocket related errors. + - `StreamWebSocketError` -> for user web socket related errors. - `StreamChatNetworkError` -> for network related errors. -- `client.queryChannels()`, `channel.query()` options param is removed in favor of individual params +- `client.queryChannels()`, `channel.query()` options parameter is removed in favor of individual parameters - `option.state` -> bool state - `option.watch` -> bool watch - `option.presence` -> bool presence -- `client.queryUsers()` options param is removed in favor of individual params +- `client.queryUsers()` options parameter is removed in favor of individual parameters - `option.presence` -> bool presence - Migrate this package to null safety - Added typed filters @@ -438,28 +438,28 @@ the [V4 Migration Guide](https://getstream.io/chat/docs/sdk/flutter/guides/migra 🛑️ Breaking Changes from `2.0.0-nullsafety.6` -- `ConnectUserWithProvider` now requires `tokenProvider` as a required param. (Removed from the +- `ConnectUserWithProvider` now requires `tokenProvider` as a required parameter. (Removed from the constructor) - `client.disconnect()` is now divided into two different functions - - `client.closeConnection()` -> for closing user websocket connection. + - `client.closeConnection()` -> for closing user web socket connection. - `client.disconnectUser()` -> for disconnecting user and resetting client state. - `client.devToken()` now returns a `Token` model instead of `String`. - `ApiError` is removed in favor of `StreamChatError` - `StreamChatError` -> parent type for all the stream errors. - - `StreamWebSocketError` -> for user websocket related errors. + - `StreamWebSocketError` -> for user web socket related errors. - `StreamChatNetworkError` -> for network related errors. -- `client.queryChannels()`, `channel.query()` options param is removed in favor of individual params +- `client.queryChannels()`, `channel.query()` options parameter is removed in favor of individual parameters - `option.state` -> bool state - `option.watch` -> bool watch - `option.presence` -> bool presence -- `client.queryUsers()` options param is removed in favor of individual params +- `client.queryUsers()` options parameter is removed in favor of individual parameters - `option.presence` -> bool presence ✅ Added - New `Location` enum is introduced for easily changing the client location/baseUrl. - New `client.openConnection()` and `client.closeConnection()` is introduced to connect/disconnect - user ws connection. + user WS connection. 🔄 Changed @@ -562,7 +562,7 @@ the [V4 Migration Guide](https://getstream.io/chat/docs/sdk/flutter/guides/migra - 🛑 **BREAKING** Renamed `Client` to less generic `StreamChatClient` - 🛑 **BREAKING** Segregated the persistence layer into separate - package [stream_chat_persistence](https://pub.dev/packages/stream_chat_persistence) + package [`stream_chat_persistence`](https://pub.dev/packages/stream_chat_persistence) - 🛑 **BREAKING** Moved `Client.backgroundKeepAlive` to [core package](https://pub.dev/packages/stream_chat_core) - 🛑 **BREAKING** Moved `Client.showLocalNotification` diff --git a/packages/stream_chat/README.md b/packages/stream_chat/README.md index bb1eab751..4ec58e035 100644 --- a/packages/stream_chat/README.md +++ b/packages/stream_chat/README.md @@ -39,7 +39,7 @@ There is a detailed Flutter example project in the `example` folder. You can dir ## Setup API Client -First you need to instantiate a chat client. The Chat client will manage API call, event handling and manage the websocket connection to Stream Chat servers. You should only create the client once and re-use it across your application. +First you need to instantiate a chat client. The Chat client will manage API call, event handling and manage the web socket connection to Stream Chat servers. You should only create the client once and re-use it across your application. ```dart final client = StreamChatClient("stream-chat-api-key"); @@ -47,7 +47,7 @@ final client = StreamChatClient("stream-chat-api-key"); ### Logging -By default the Chat Client will write all messages with level Warn or Error to stdout. +By default the Chat Client will write all messages with level Warn or Error to `stdout`. #### Change Logging Level @@ -59,7 +59,7 @@ final client = StreamChatClient("stream-chat-api-key", logLevel: Level.INFO); #### Custom Logger -You can handle the log messages directly instead of have them written to stdout, this is very convenient if you use an error tracking tool or if you want to centralize your logs into one facility. +You can handle the log messages directly instead of have them written to `stdout`, this is very convenient if you use an error tracking tool or if you want to centralize your logs into one facility. ```dart myLogHandlerFunction = (LogRecord record) { @@ -71,7 +71,7 @@ final client = StreamChatClient("stream-chat-api-key", logHandlerFunction: myLog ### Offline storage -To add data persistance you can extend the class `ChatPersistenceClient` and pass an instance to the `StreamChatClient`. +To add data persistence, you can extend the class `ChatPersistenceClient` and pass an instance to the `StreamChatClient`. ```dart class CustomChatPersistentClient extends ChatPersistenceClient { @@ -84,7 +84,7 @@ final client = StreamChatClient( )..chatPersistenceClient = CustomChatPersistentClient(); ``` -We provide an official persistent client in the [stream_chat_persistence](https://pub.dev/packages/stream_chat_persistence) package. +We provide an official persistent client in the [`stream_chat_persistence`](https://pub.dev/packages/stream_chat_persistence) package. ```dart import 'package:stream_chat_persistence/stream_chat_persistence.dart'; @@ -104,7 +104,7 @@ final client = StreamChatClient( ### Code conventions -- Make sure that you run `dartfmt` before commiting your code +- Make sure that you run `dartfmt` before you commit your code - Make sure all public methods and functions are well documented ### Running tests diff --git a/packages/stream_chat_flutter/.gitignore b/packages/stream_chat_flutter/.gitignore index fe82edc9e..69e234515 100644 --- a/packages/stream_chat_flutter/.gitignore +++ b/packages/stream_chat_flutter/.gitignore @@ -50,7 +50,7 @@ pubspec.lock # If you don't generate documentation locally you can remove this line. doc/api/ -# Avoid committing generated Javascript files: +# Avoid committing generated JavaScript files: *.dart.js *.info.json # Produced by the --dump-info flag. *.js # When generated by dart2js. Don't specify *.js if your diff --git a/packages/stream_chat_flutter/CHANGELOG.md b/packages/stream_chat_flutter/CHANGELOG.md index 6c3980d24..2d4604d8d 100644 --- a/packages/stream_chat_flutter/CHANGELOG.md +++ b/packages/stream_chat_flutter/CHANGELOG.md @@ -1,4 +1,4 @@ -## Upcomming +## Upcoming 🔄 Changed @@ -43,7 +43,7 @@ ✅ Added - Added `StreamMemberGridView` and `StreamMemberListView`. -- Added support for additional text field params in `StreamMessageInput` +- Added support for additional text field parameters in `StreamMessageInput` * `maxLines` * `minLines` * `textInputAction` @@ -228,7 +228,7 @@ - Fix commands resetting the `StreamMessageInputController.value`. - [[#996]](https://github.com/GetStream/stream-chat-flutter/issues/996) Videos break bottom photo carousal. -- Fix: URLs with path and/or query params are not enriched. +- Fix: URLs with path and/or query parameters are not enriched. - [[#1194]](https://github.com/GetStream/stream-chat-flutter/issues/1194) Request permission to access gallery when opening the file picker. @@ -892,11 +892,11 @@ typedef MessageBuilder = Widget Function( ## 1.0.0-beta - **Refreshed widgets design** -- Improved api documentation +- Improved API documentation - Updated `stream_chat` dependency to `^1.0.0-beta` -- Extracted sample app into dedicated [repo](https://github.com/GetStream/flutter-samples) -- Reimplemented existing widgets - using [stream_chat_flutter_core](https://pub.dev/packages/stream_chat_flutter_core) +- Extracted sample app into dedicated [repository](https://github.com/GetStream/flutter-samples) +- Re-implemented existing widgets + using [`stream_chat_flutter_core`](https://pub.dev/packages/stream_chat_flutter_core) ## 0.2.21 @@ -905,7 +905,7 @@ typedef MessageBuilder = Widget Function( ## 0.2.20+4 -- Fix channelPreview when the message list is empty +- Fix `channelPreview` when the message list is empty ## 0.2.20+3 diff --git a/packages/stream_chat_flutter/README.md b/packages/stream_chat_flutter/README.md index aedafb1d6..8fd09fa09 100644 --- a/packages/stream_chat_flutter/README.md +++ b/packages/stream_chat_flutter/README.md @@ -32,7 +32,7 @@ It teaches you how to use this SDK and also shows how to make frequently require ## Example App -This repo includes a fully functional example app with setup instructions. +This repository includes a fully functional example app with setup instructions. The example is available under the [example](https://github.com/GetStream/stream-chat-flutter/tree/master/packages/stream_chat_flutter/example) folder. ## Add dependency @@ -46,7 +46,7 @@ You should then run `flutter packages get` ### Android -The package uses [photo_manager](https://pub.dev/packages/photo_manager) to access the device's photo library. +The package uses [`photo_manager`](https://pub.dev/packages/photo_manager) to access the device's photo library. Follow [this wiki](https://pub.dev/packages/photo_manager#android-10-q-29) to fulfil the Android requirements. ### iOS @@ -55,9 +55,9 @@ The library uses [flutter file picker plugin](https://github.com/miguelpruivo/fl files from the os. Follow [this wiki](https://github.com/miguelpruivo/flutter_file_picker/wiki/Setup#ios) to fulfill iOS requirements. -We also use [video_player](https://pub.dev/packages/video_player) to reproduce videos. Follow [this guide](https://pub.dev/packages/video_player#installation) to fulfill the requirements. +We also use [`video_player`](https://pub.dev/packages/video_player) to reproduce videos. Follow [this guide](https://pub.dev/packages/video_player#installation) to fulfill the requirements. -To pick images from the camera, we use the [image_picker](https://pub.dev/packages/image_picker) plugin. +To pick images from the camera, we use the [`image_picker`](https://pub.dev/packages/image_picker) plugin. Follow [these instructions](https://pub.dev/packages/image_picker#ios) to check the requirements. ### Web @@ -70,7 +70,7 @@ For the web, edit your `index.html` and add the following in the `` tag in ### MacOS -For MacOS use the [file_selector](https://pub.dev/packages/file_selector#macos) package. +For MacOS use the [`file_selector`](https://pub.dev/packages/file_selector#macos) package. Follow [these instructions](https://pub.dev/packages/file_selector#macos) to check the requirements. You also need to add the following [entitlement](https://docs.flutter.dev/development/platform-integration/desktop#entitlements-and-the-app-sandbox): @@ -88,8 +88,8 @@ If it seems related to the [flutter file picker plugin](https://github.com/migue ## Docs This package provides UI components required for integrating Stream Chat into your application. -Alternatively, you may use the core package [stream_chat_flutter_core](https://github.com/GetStream/stream-chat-flutter/tree/master/packages/stream_chat_flutter_core) which allows more customisation and provides business logic but no UI components. -If you require the maximum amount of control over the API, please use the low level client package: [stream_chat](https://github.com/GetStream/stream-chat-flutter/tree/master/packages/stream_chat). +Alternatively, you may use the core package [`stream_chat_flutter_core`](https://github.com/GetStream/stream-chat-flutter/tree/master/packages/stream_chat_flutter_core) which allows more customisation and provides business logic but no UI components. +If you require the maximum amount of control over the API, please use the low level client package: [`stream_chat`](https://github.com/GetStream/stream-chat-flutter/tree/master/packages/stream_chat). ### UI Components @@ -175,7 +175,7 @@ Out of the box, all chat widgets use their default styling, and there are two wa ### Offline storage -To add data persistance you can extend the class `ChatPersistenceClient` and pass an instance to the `StreamChatClient`. +To add data persistence you can extend the class `ChatPersistenceClient` and pass an instance to the `StreamChatClient`. ```dart class CustomChatPersistentClient extends ChatPersistenceClient { @@ -207,7 +207,7 @@ final client = StreamChatClient( ## Contributing We welcome code changes that improve this library or fix a problem, -please make sure to follow all best practices and add tests if applicable before submitting a Pull Request on Github. +please make sure to follow all best practices and add tests if applicable before submitting a Pull Request on GitHub. We are pleased to merge your code into the official repository. Make sure to sign our [Contributor License Agreement (CLA)](https://docs.google.com/forms/d/e/1FAIpQLScFKsKkAJI7mhCr7K9rEIOpqIDThrWxuvxnwUq2XkHyG154vQ/viewform) first. See our license file for more details. diff --git a/packages/stream_chat_flutter/example/lib/tutorial_part_1.dart b/packages/stream_chat_flutter/example/lib/tutorial_part_1.dart index b25311d59..d847fa3a7 100644 --- a/packages/stream_chat_flutter/example/lib/tutorial_part_1.dart +++ b/packages/stream_chat_flutter/example/lib/tutorial_part_1.dart @@ -21,7 +21,7 @@ import 'package:stream_chat_flutter/stream_chat_flutter.dart'; /// /// - We set up the Chat [StreamChatClient] with the API key /// -/// - We set the the current user for Chat with [StreamChatClient.connectUser] +/// - We set the current user for Chat with [StreamChatClient.connectUser] /// and a pre-generated user token /// /// - We make [StreamChat] the root Widget of our application From f94430b2022bdd021f834c433c9f01cdc902cbcf Mon Sep 17 00:00:00 2001 From: Leandro Borges Ferreira Date: Fri, 27 Jan 2023 12:32:03 +0100 Subject: [PATCH 007/107] Changing new messages separator text --- .../lib/src/localization/translations.dart | 9 ++------- .../src/message_list_view/unread_messages_separator.dart | 4 +--- .../example/lib/add_new_lang.dart | 7 +------ .../lib/src/stream_chat_localizations_ca.dart | 7 +------ .../lib/src/stream_chat_localizations_de.dart | 9 ++------- .../lib/src/stream_chat_localizations_en.dart | 7 +------ .../lib/src/stream_chat_localizations_es.dart | 7 +------ .../lib/src/stream_chat_localizations_fr.dart | 7 +------ .../lib/src/stream_chat_localizations_hi.dart | 7 +------ .../lib/src/stream_chat_localizations_it.dart | 7 +------ .../lib/src/stream_chat_localizations_ja.dart | 7 +------ .../lib/src/stream_chat_localizations_ko.dart | 7 +------ .../lib/src/stream_chat_localizations_no.dart | 7 +------ .../lib/src/stream_chat_localizations_pt.dart | 7 +------ .../test/translations_test.dart | 2 +- 15 files changed, 17 insertions(+), 84 deletions(-) diff --git a/packages/stream_chat_flutter/lib/src/localization/translations.dart b/packages/stream_chat_flutter/lib/src/localization/translations.dart index b7436d4b9..ac7f85734 100644 --- a/packages/stream_chat_flutter/lib/src/localization/translations.dart +++ b/packages/stream_chat_flutter/lib/src/localization/translations.dart @@ -81,7 +81,7 @@ abstract class Translations { /// The text for showing the unread messages count /// in the [StreamMessageListView] - String unreadMessagesSeparatorText(int unreadCount); + String unreadMessagesSeparatorText(); /// The label for "connected" in [StreamConnectionStatusBuilder] String get connectedLabel; @@ -797,12 +797,7 @@ Attachment limit exceeded: it's not possible to add more than $limit attachments String get linkDisabledError => 'Links are disabled'; @override - String unreadMessagesSeparatorText(int unreadCount) { - if (unreadCount == 1) { - return '1 unread message'; - } - return '$unreadCount unread messages'; - } + String unreadMessagesSeparatorText() => 'New messages'; @override String get enableFileAccessMessage => 'Please enable access to files' diff --git a/packages/stream_chat_flutter/lib/src/message_list_view/unread_messages_separator.dart b/packages/stream_chat_flutter/lib/src/message_list_view/unread_messages_separator.dart index 5449cdc9a..b32c36d8e 100644 --- a/packages/stream_chat_flutter/lib/src/message_list_view/unread_messages_separator.dart +++ b/packages/stream_chat_flutter/lib/src/message_list_view/unread_messages_separator.dart @@ -24,9 +24,7 @@ class UnreadMessagesSeparator extends StatelessWidget { child: Padding( padding: const EdgeInsets.all(8), child: Text( - context.translations.unreadMessagesSeparatorText( - unreadCount, - ), + context.translations.unreadMessagesSeparatorText(), textAlign: TextAlign.center, style: StreamChannelHeaderTheme.of(context).subtitleStyle, ), diff --git a/packages/stream_chat_localizations/example/lib/add_new_lang.dart b/packages/stream_chat_localizations/example/lib/add_new_lang.dart index f71d4e1b4..0bb3a217a 100644 --- a/packages/stream_chat_localizations/example/lib/add_new_lang.dart +++ b/packages/stream_chat_localizations/example/lib/add_new_lang.dart @@ -459,12 +459,7 @@ class NnStreamChatLocalizations extends GlobalStreamChatLocalizations { String get viewLibrary => 'View library'; @override - String unreadMessagesSeparatorText(int unreadCount) { - if (unreadCount == 1) { - return '1 unread message'; - } - return '$unreadCount unread messages'; - } + String unreadMessagesSeparatorText() => 'New messages'; @override String get enableFileAccessMessage => 'Enable file access to continue'; diff --git a/packages/stream_chat_localizations/lib/src/stream_chat_localizations_ca.dart b/packages/stream_chat_localizations/lib/src/stream_chat_localizations_ca.dart index 589700906..1b36e4def 100644 --- a/packages/stream_chat_localizations/lib/src/stream_chat_localizations_ca.dart +++ b/packages/stream_chat_localizations/lib/src/stream_chat_localizations_ca.dart @@ -438,12 +438,7 @@ class StreamChatLocalizationsCa extends GlobalStreamChatLocalizations { String get linkDisabledError => 'Els enllaços estan deshabilitats'; @override - String unreadMessagesSeparatorText(int unreadCount) { - if (unreadCount == 1) { - return '1 missatge no llegit'; - } - return '$unreadCount missatges no llegits'; - } + String unreadMessagesSeparatorText() => 'Missatges nous'; @override String get enableFileAccessMessage => "Habilita l'accés als fitxers" diff --git a/packages/stream_chat_localizations/lib/src/stream_chat_localizations_de.dart b/packages/stream_chat_localizations/lib/src/stream_chat_localizations_de.dart index 88d7c5965..336714ee7 100644 --- a/packages/stream_chat_localizations/lib/src/stream_chat_localizations_de.dart +++ b/packages/stream_chat_localizations/lib/src/stream_chat_localizations_de.dart @@ -15,7 +15,7 @@ class StreamChatLocalizationsDe extends GlobalStreamChatLocalizations { String get noUsersLabel => 'Derzeit gibt es keine User'; @override - String get noPhotoOrVideoLabel => 'Es gibt keine Foto oder Video'; + String get noPhotoOrVideoLabel => 'Es gibt kein Foto oder Video'; @override String get retryLabel => 'Erneut versuchen'; @@ -431,12 +431,7 @@ class StreamChatLocalizationsDe extends GlobalStreamChatLocalizations { String get viewLibrary => 'Bibliothek öffnen'; @override - String unreadMessagesSeparatorText(int unreadCount) { - if (unreadCount == 1) { - return '1 ungelesene Nachricht'; - } - return '$unreadCount ungelesene Nachrichten'; - } + String unreadMessagesSeparatorText() => 'Neue Nachrichten'; @override String get enableFileAccessMessage => diff --git a/packages/stream_chat_localizations/lib/src/stream_chat_localizations_en.dart b/packages/stream_chat_localizations/lib/src/stream_chat_localizations_en.dart index 70bab06d9..a90246f25 100644 --- a/packages/stream_chat_localizations/lib/src/stream_chat_localizations_en.dart +++ b/packages/stream_chat_localizations/lib/src/stream_chat_localizations_en.dart @@ -435,12 +435,7 @@ class StreamChatLocalizationsEn extends GlobalStreamChatLocalizations { String get viewLibrary => 'View library'; @override - String unreadMessagesSeparatorText(int unreadCount) { - if (unreadCount == 1) { - return '1 unread message'; - } - return '$unreadCount unread messages'; - } + String unreadMessagesSeparatorText() => 'New messages'; @override String get enableFileAccessMessage => 'Please enable access to files' diff --git a/packages/stream_chat_localizations/lib/src/stream_chat_localizations_es.dart b/packages/stream_chat_localizations/lib/src/stream_chat_localizations_es.dart index 1e77071e2..73df2c5c5 100644 --- a/packages/stream_chat_localizations/lib/src/stream_chat_localizations_es.dart +++ b/packages/stream_chat_localizations/lib/src/stream_chat_localizations_es.dart @@ -440,12 +440,7 @@ No es posible añadir más de $limit archivos adjuntos String get linkDisabledError => 'Los enlaces están deshabilitados'; @override - String unreadMessagesSeparatorText(int unreadCount) { - if (unreadCount == 1) { - return '1 mensaje no leído'; - } - return '$unreadCount mensajes no leídos'; - } + String unreadMessagesSeparatorText() => 'Nuevos mensajes'; @override String get enableFileAccessMessage => 'Habilite el acceso a los archivos' diff --git a/packages/stream_chat_localizations/lib/src/stream_chat_localizations_fr.dart b/packages/stream_chat_localizations/lib/src/stream_chat_localizations_fr.dart index 75f5cd4f4..3b58b794e 100644 --- a/packages/stream_chat_localizations/lib/src/stream_chat_localizations_fr.dart +++ b/packages/stream_chat_localizations/lib/src/stream_chat_localizations_fr.dart @@ -439,12 +439,7 @@ Limite de pièces jointes dépassée : il n'est pas possible d'ajouter plus de $ String get linkDisabledError => 'Les liens sont désactivés'; @override - String unreadMessagesSeparatorText(int unreadCount) { - if (unreadCount == 1) { - return '1 message non lu'; - } - return '$unreadCount messages non lus'; - } + String unreadMessagesSeparatorText() => "Nouveaux messages"; @override String get enableFileAccessMessage => diff --git a/packages/stream_chat_localizations/lib/src/stream_chat_localizations_hi.dart b/packages/stream_chat_localizations/lib/src/stream_chat_localizations_hi.dart index c00ab2699..f27172c24 100644 --- a/packages/stream_chat_localizations/lib/src/stream_chat_localizations_hi.dart +++ b/packages/stream_chat_localizations/lib/src/stream_chat_localizations_hi.dart @@ -433,12 +433,7 @@ class StreamChatLocalizationsHi extends GlobalStreamChatLocalizations { String get linkDisabledError => 'लिंक भेजना प्रतिबंधित'; @override - String unreadMessagesSeparatorText(int unreadCount) { - if (unreadCount == 1) { - return '1 अपठित संदेश'; - } - return '$unreadCount अपठित संदेश'; - } + String unreadMessagesSeparatorText() => 'नए संदेश।'; @override String get enableFileAccessMessage => 'कृपया फ़ाइलों तक पहुंच सक्षम करें ताकि' diff --git a/packages/stream_chat_localizations/lib/src/stream_chat_localizations_it.dart b/packages/stream_chat_localizations/lib/src/stream_chat_localizations_it.dart index b79e2a6d7..bebb58e90 100644 --- a/packages/stream_chat_localizations/lib/src/stream_chat_localizations_it.dart +++ b/packages/stream_chat_localizations/lib/src/stream_chat_localizations_it.dart @@ -442,12 +442,7 @@ Attenzione: il limite massimo di $limit file è stato superato. String get linkDisabledError => 'I links sono disattivati'; @override - String unreadMessagesSeparatorText(int unreadCount) { - if (unreadCount == 1) { - return '1 messaggio non letto'; - } - return '$unreadCount messaggi non letti'; - } + String unreadMessagesSeparatorText() => "Nouveaux messages"; @override String get enableFileAccessMessage => "Per favore attiva l'accesso ai file" diff --git a/packages/stream_chat_localizations/lib/src/stream_chat_localizations_ja.dart b/packages/stream_chat_localizations/lib/src/stream_chat_localizations_ja.dart index f26d8f85a..8aa070e51 100644 --- a/packages/stream_chat_localizations/lib/src/stream_chat_localizations_ja.dart +++ b/packages/stream_chat_localizations/lib/src/stream_chat_localizations_ja.dart @@ -418,12 +418,7 @@ class StreamChatLocalizationsJa extends GlobalStreamChatLocalizations { String get linkDisabledError => 'リンクが無効になっています'; @override - String unreadMessagesSeparatorText(int unreadCount) { - if (unreadCount == 1) { - return '未読メッセージ1通'; - } - return '$unreadCountつの未読メッセージ'; - } + String unreadMessagesSeparatorText() => '新しいメッセージ。'; @override String get enableFileAccessMessage => diff --git a/packages/stream_chat_localizations/lib/src/stream_chat_localizations_ko.dart b/packages/stream_chat_localizations/lib/src/stream_chat_localizations_ko.dart index 7dac84a56..a34903674 100644 --- a/packages/stream_chat_localizations/lib/src/stream_chat_localizations_ko.dart +++ b/packages/stream_chat_localizations/lib/src/stream_chat_localizations_ko.dart @@ -419,12 +419,7 @@ class StreamChatLocalizationsKo extends GlobalStreamChatLocalizations { String get linkDisabledError => '링크가 비활성화되었습니다.'; @override - String unreadMessagesSeparatorText(int unreadCount) { - if (unreadCount == 1) { - return '읽지 않은 메시지 1개'; - } - return '읽지 않은 메시지 $unreadCount개'; - } + String unreadMessagesSeparatorText() => '새 메시지.'; @override String get enableFileAccessMessage => '친구와 공유할 수 있도록 파일에 대한 액세스를 허용하세요.'; diff --git a/packages/stream_chat_localizations/lib/src/stream_chat_localizations_no.dart b/packages/stream_chat_localizations/lib/src/stream_chat_localizations_no.dart index 4a18fd6be..b2fdd4984 100644 --- a/packages/stream_chat_localizations/lib/src/stream_chat_localizations_no.dart +++ b/packages/stream_chat_localizations/lib/src/stream_chat_localizations_no.dart @@ -383,12 +383,7 @@ class StreamChatLocalizationsNo extends GlobalStreamChatLocalizations { String get viewLibrary => 'Se bibliotek'; @override - String unreadMessagesSeparatorText(int unreadCount) { - if (unreadCount == 1) { - return '1 ulest melding'; - } - return '$unreadCount uleste meldinger'; - } + String unreadMessagesSeparatorText() => 'Nye meldinger.'; @override String get couldNotReadBytesFromFileError => diff --git a/packages/stream_chat_localizations/lib/src/stream_chat_localizations_pt.dart b/packages/stream_chat_localizations/lib/src/stream_chat_localizations_pt.dart index 3613e91cc..aa5fc3f36 100644 --- a/packages/stream_chat_localizations/lib/src/stream_chat_localizations_pt.dart +++ b/packages/stream_chat_localizations/lib/src/stream_chat_localizations_pt.dart @@ -438,12 +438,7 @@ Não é possível adicionar mais de $limit arquivos de uma vez String get viewLibrary => 'Ver biblioteca'; @override - String unreadMessagesSeparatorText(int unreadCount) { - if (unreadCount == 1) { - return '1 mensagem não lida'; - } - return '$unreadCount mensagens não lidas'; - } + String unreadMessagesSeparatorText() => "Novas mensagens"; @override String get enableFileAccessMessage => diff --git a/packages/stream_chat_localizations/test/translations_test.dart b/packages/stream_chat_localizations/test/translations_test.dart index 4004994a3..02c36dfc6 100644 --- a/packages/stream_chat_localizations/test/translations_test.dart +++ b/packages/stream_chat_localizations/test/translations_test.dart @@ -195,7 +195,7 @@ void main() { localizations.toggleMuteUnmuteUserQuestion(isMuted: true), isNotNull); expect(localizations.toggleMuteUnmuteUserText(isMuted: true), isNotNull); expect(localizations.viewLibrary, isNotNull); - expect(localizations.unreadMessagesSeparatorText(2), isNotNull); + expect(localizations.unreadMessagesSeparatorText(), isNotNull); expect(localizations.enableFileAccessMessage, isNotNull); expect(localizations.allowFileAccessMessage, isNotNull); }); From e4b9ec34c011661edff9b94f79a69451bf66e542 Mon Sep 17 00:00:00 2001 From: Leandro Borges Ferreira Date: Fri, 27 Jan 2023 13:31:13 +0100 Subject: [PATCH 008/107] Only deprecating unreadCount, but not deleting it --- .../lib/src/localization/translations.dart | 7 +++++-- .../src/message_list_view/unread_messages_separator.dart | 2 +- .../example/lib/add_new_lang.dart | 2 +- .../lib/src/stream_chat_localizations_ca.dart | 2 +- .../lib/src/stream_chat_localizations_de.dart | 2 +- .../lib/src/stream_chat_localizations_en.dart | 2 +- .../lib/src/stream_chat_localizations_es.dart | 2 +- .../lib/src/stream_chat_localizations_fr.dart | 2 +- .../lib/src/stream_chat_localizations_hi.dart | 2 +- .../lib/src/stream_chat_localizations_it.dart | 2 +- .../lib/src/stream_chat_localizations_ja.dart | 2 +- .../lib/src/stream_chat_localizations_ko.dart | 2 +- .../lib/src/stream_chat_localizations_no.dart | 2 +- .../lib/src/stream_chat_localizations_pt.dart | 2 +- 14 files changed, 18 insertions(+), 15 deletions(-) diff --git a/packages/stream_chat_flutter/lib/src/localization/translations.dart b/packages/stream_chat_flutter/lib/src/localization/translations.dart index ac7f85734..71254e734 100644 --- a/packages/stream_chat_flutter/lib/src/localization/translations.dart +++ b/packages/stream_chat_flutter/lib/src/localization/translations.dart @@ -81,7 +81,10 @@ abstract class Translations { /// The text for showing the unread messages count /// in the [StreamMessageListView] - String unreadMessagesSeparatorText(); + String unreadMessagesSeparatorText( + @Deprecated('unreadCount is not used anymore and will be removed ') + int unreadCount, + ); /// The label for "connected" in [StreamConnectionStatusBuilder] String get connectedLabel; @@ -797,7 +800,7 @@ Attachment limit exceeded: it's not possible to add more than $limit attachments String get linkDisabledError => 'Links are disabled'; @override - String unreadMessagesSeparatorText() => 'New messages'; + String unreadMessagesSeparatorText(int unreadCount) => 'New messages'; @override String get enableFileAccessMessage => 'Please enable access to files' diff --git a/packages/stream_chat_flutter/lib/src/message_list_view/unread_messages_separator.dart b/packages/stream_chat_flutter/lib/src/message_list_view/unread_messages_separator.dart index b32c36d8e..57e9257ca 100644 --- a/packages/stream_chat_flutter/lib/src/message_list_view/unread_messages_separator.dart +++ b/packages/stream_chat_flutter/lib/src/message_list_view/unread_messages_separator.dart @@ -24,7 +24,7 @@ class UnreadMessagesSeparator extends StatelessWidget { child: Padding( padding: const EdgeInsets.all(8), child: Text( - context.translations.unreadMessagesSeparatorText(), + context.translations.unreadMessagesSeparatorText(unreadCount), textAlign: TextAlign.center, style: StreamChannelHeaderTheme.of(context).subtitleStyle, ), diff --git a/packages/stream_chat_localizations/example/lib/add_new_lang.dart b/packages/stream_chat_localizations/example/lib/add_new_lang.dart index 0bb3a217a..3f3b5bdbb 100644 --- a/packages/stream_chat_localizations/example/lib/add_new_lang.dart +++ b/packages/stream_chat_localizations/example/lib/add_new_lang.dart @@ -459,7 +459,7 @@ class NnStreamChatLocalizations extends GlobalStreamChatLocalizations { String get viewLibrary => 'View library'; @override - String unreadMessagesSeparatorText() => 'New messages'; + String unreadMessagesSeparatorText(int unreadCount) => 'New messages'; @override String get enableFileAccessMessage => 'Enable file access to continue'; diff --git a/packages/stream_chat_localizations/lib/src/stream_chat_localizations_ca.dart b/packages/stream_chat_localizations/lib/src/stream_chat_localizations_ca.dart index 1b36e4def..3c471e051 100644 --- a/packages/stream_chat_localizations/lib/src/stream_chat_localizations_ca.dart +++ b/packages/stream_chat_localizations/lib/src/stream_chat_localizations_ca.dart @@ -438,7 +438,7 @@ class StreamChatLocalizationsCa extends GlobalStreamChatLocalizations { String get linkDisabledError => 'Els enllaços estan deshabilitats'; @override - String unreadMessagesSeparatorText() => 'Missatges nous'; + String unreadMessagesSeparatorText(int unreadCount) => 'Missatges nous'; @override String get enableFileAccessMessage => "Habilita l'accés als fitxers" diff --git a/packages/stream_chat_localizations/lib/src/stream_chat_localizations_de.dart b/packages/stream_chat_localizations/lib/src/stream_chat_localizations_de.dart index 336714ee7..df2a7766b 100644 --- a/packages/stream_chat_localizations/lib/src/stream_chat_localizations_de.dart +++ b/packages/stream_chat_localizations/lib/src/stream_chat_localizations_de.dart @@ -431,7 +431,7 @@ class StreamChatLocalizationsDe extends GlobalStreamChatLocalizations { String get viewLibrary => 'Bibliothek öffnen'; @override - String unreadMessagesSeparatorText() => 'Neue Nachrichten'; + String unreadMessagesSeparatorText(int unreadCount) => 'Neue Nachrichten'; @override String get enableFileAccessMessage => diff --git a/packages/stream_chat_localizations/lib/src/stream_chat_localizations_en.dart b/packages/stream_chat_localizations/lib/src/stream_chat_localizations_en.dart index a90246f25..c55bbf49d 100644 --- a/packages/stream_chat_localizations/lib/src/stream_chat_localizations_en.dart +++ b/packages/stream_chat_localizations/lib/src/stream_chat_localizations_en.dart @@ -435,7 +435,7 @@ class StreamChatLocalizationsEn extends GlobalStreamChatLocalizations { String get viewLibrary => 'View library'; @override - String unreadMessagesSeparatorText() => 'New messages'; + String unreadMessagesSeparatorText(int unreadCount) => 'New messages'; @override String get enableFileAccessMessage => 'Please enable access to files' diff --git a/packages/stream_chat_localizations/lib/src/stream_chat_localizations_es.dart b/packages/stream_chat_localizations/lib/src/stream_chat_localizations_es.dart index 73df2c5c5..107e26166 100644 --- a/packages/stream_chat_localizations/lib/src/stream_chat_localizations_es.dart +++ b/packages/stream_chat_localizations/lib/src/stream_chat_localizations_es.dart @@ -440,7 +440,7 @@ No es posible añadir más de $limit archivos adjuntos String get linkDisabledError => 'Los enlaces están deshabilitados'; @override - String unreadMessagesSeparatorText() => 'Nuevos mensajes'; + String unreadMessagesSeparatorText(int unreadCount) => 'Nuevos mensajes'; @override String get enableFileAccessMessage => 'Habilite el acceso a los archivos' diff --git a/packages/stream_chat_localizations/lib/src/stream_chat_localizations_fr.dart b/packages/stream_chat_localizations/lib/src/stream_chat_localizations_fr.dart index 3b58b794e..887b484e9 100644 --- a/packages/stream_chat_localizations/lib/src/stream_chat_localizations_fr.dart +++ b/packages/stream_chat_localizations/lib/src/stream_chat_localizations_fr.dart @@ -439,7 +439,7 @@ Limite de pièces jointes dépassée : il n'est pas possible d'ajouter plus de $ String get linkDisabledError => 'Les liens sont désactivés'; @override - String unreadMessagesSeparatorText() => "Nouveaux messages"; + String unreadMessagesSeparatorText(int unreadCount) => "Nouveaux messages"; @override String get enableFileAccessMessage => diff --git a/packages/stream_chat_localizations/lib/src/stream_chat_localizations_hi.dart b/packages/stream_chat_localizations/lib/src/stream_chat_localizations_hi.dart index f27172c24..4f27717a7 100644 --- a/packages/stream_chat_localizations/lib/src/stream_chat_localizations_hi.dart +++ b/packages/stream_chat_localizations/lib/src/stream_chat_localizations_hi.dart @@ -433,7 +433,7 @@ class StreamChatLocalizationsHi extends GlobalStreamChatLocalizations { String get linkDisabledError => 'लिंक भेजना प्रतिबंधित'; @override - String unreadMessagesSeparatorText() => 'नए संदेश।'; + String unreadMessagesSeparatorText(int unreadCount) => 'नए संदेश।'; @override String get enableFileAccessMessage => 'कृपया फ़ाइलों तक पहुंच सक्षम करें ताकि' diff --git a/packages/stream_chat_localizations/lib/src/stream_chat_localizations_it.dart b/packages/stream_chat_localizations/lib/src/stream_chat_localizations_it.dart index bebb58e90..177854a30 100644 --- a/packages/stream_chat_localizations/lib/src/stream_chat_localizations_it.dart +++ b/packages/stream_chat_localizations/lib/src/stream_chat_localizations_it.dart @@ -442,7 +442,7 @@ Attenzione: il limite massimo di $limit file è stato superato. String get linkDisabledError => 'I links sono disattivati'; @override - String unreadMessagesSeparatorText() => "Nouveaux messages"; + String unreadMessagesSeparatorText(int unreadCount) => "Nouveaux messages"; @override String get enableFileAccessMessage => "Per favore attiva l'accesso ai file" diff --git a/packages/stream_chat_localizations/lib/src/stream_chat_localizations_ja.dart b/packages/stream_chat_localizations/lib/src/stream_chat_localizations_ja.dart index 8aa070e51..26a5e8b3e 100644 --- a/packages/stream_chat_localizations/lib/src/stream_chat_localizations_ja.dart +++ b/packages/stream_chat_localizations/lib/src/stream_chat_localizations_ja.dart @@ -418,7 +418,7 @@ class StreamChatLocalizationsJa extends GlobalStreamChatLocalizations { String get linkDisabledError => 'リンクが無効になっています'; @override - String unreadMessagesSeparatorText() => '新しいメッセージ。'; + String unreadMessagesSeparatorText(int unreadCount) => '新しいメッセージ。'; @override String get enableFileAccessMessage => diff --git a/packages/stream_chat_localizations/lib/src/stream_chat_localizations_ko.dart b/packages/stream_chat_localizations/lib/src/stream_chat_localizations_ko.dart index a34903674..7b907584e 100644 --- a/packages/stream_chat_localizations/lib/src/stream_chat_localizations_ko.dart +++ b/packages/stream_chat_localizations/lib/src/stream_chat_localizations_ko.dart @@ -419,7 +419,7 @@ class StreamChatLocalizationsKo extends GlobalStreamChatLocalizations { String get linkDisabledError => '링크가 비활성화되었습니다.'; @override - String unreadMessagesSeparatorText() => '새 메시지.'; + String unreadMessagesSeparatorText(int unreadCount) => '새 메시지.'; @override String get enableFileAccessMessage => '친구와 공유할 수 있도록 파일에 대한 액세스를 허용하세요.'; diff --git a/packages/stream_chat_localizations/lib/src/stream_chat_localizations_no.dart b/packages/stream_chat_localizations/lib/src/stream_chat_localizations_no.dart index b2fdd4984..88350979e 100644 --- a/packages/stream_chat_localizations/lib/src/stream_chat_localizations_no.dart +++ b/packages/stream_chat_localizations/lib/src/stream_chat_localizations_no.dart @@ -383,7 +383,7 @@ class StreamChatLocalizationsNo extends GlobalStreamChatLocalizations { String get viewLibrary => 'Se bibliotek'; @override - String unreadMessagesSeparatorText() => 'Nye meldinger.'; + String unreadMessagesSeparatorText(int unreadCount) => 'Nye meldinger.'; @override String get couldNotReadBytesFromFileError => diff --git a/packages/stream_chat_localizations/lib/src/stream_chat_localizations_pt.dart b/packages/stream_chat_localizations/lib/src/stream_chat_localizations_pt.dart index aa5fc3f36..9464e90d8 100644 --- a/packages/stream_chat_localizations/lib/src/stream_chat_localizations_pt.dart +++ b/packages/stream_chat_localizations/lib/src/stream_chat_localizations_pt.dart @@ -438,7 +438,7 @@ Não é possível adicionar mais de $limit arquivos de uma vez String get viewLibrary => 'Ver biblioteca'; @override - String unreadMessagesSeparatorText() => "Novas mensagens"; + String unreadMessagesSeparatorText(int unreadCount) => "Novas mensagens"; @override String get enableFileAccessMessage => From 42540ce5fbfa2db3abcf00fdd53bcf74e27a5396 Mon Sep 17 00:00:00 2001 From: Leandro Borges Ferreira Date: Fri, 27 Jan 2023 13:38:36 +0100 Subject: [PATCH 009/107] Update translations_test.dart --- packages/stream_chat_localizations/test/translations_test.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/stream_chat_localizations/test/translations_test.dart b/packages/stream_chat_localizations/test/translations_test.dart index 02c36dfc6..4004994a3 100644 --- a/packages/stream_chat_localizations/test/translations_test.dart +++ b/packages/stream_chat_localizations/test/translations_test.dart @@ -195,7 +195,7 @@ void main() { localizations.toggleMuteUnmuteUserQuestion(isMuted: true), isNotNull); expect(localizations.toggleMuteUnmuteUserText(isMuted: true), isNotNull); expect(localizations.viewLibrary, isNotNull); - expect(localizations.unreadMessagesSeparatorText(), isNotNull); + expect(localizations.unreadMessagesSeparatorText(2), isNotNull); expect(localizations.enableFileAccessMessage, isNotNull); expect(localizations.allowFileAccessMessage, isNotNull); }); From 91b36fb6f77e2d4e3801ca541c50155148089e13 Mon Sep 17 00:00:00 2001 From: Leandro Borges Ferreira Date: Fri, 27 Jan 2023 13:47:13 +0100 Subject: [PATCH 010/107] Fixing single quotes --- .../lib/src/stream_chat_localizations_fr.dart | 2 +- .../lib/src/stream_chat_localizations_it.dart | 2 +- .../lib/src/stream_chat_localizations_pt.dart | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/stream_chat_localizations/lib/src/stream_chat_localizations_fr.dart b/packages/stream_chat_localizations/lib/src/stream_chat_localizations_fr.dart index 887b484e9..8b501184e 100644 --- a/packages/stream_chat_localizations/lib/src/stream_chat_localizations_fr.dart +++ b/packages/stream_chat_localizations/lib/src/stream_chat_localizations_fr.dart @@ -439,7 +439,7 @@ Limite de pièces jointes dépassée : il n'est pas possible d'ajouter plus de $ String get linkDisabledError => 'Les liens sont désactivés'; @override - String unreadMessagesSeparatorText(int unreadCount) => "Nouveaux messages"; + String unreadMessagesSeparatorText(int unreadCount) => 'Nouveaux messages'; @override String get enableFileAccessMessage => diff --git a/packages/stream_chat_localizations/lib/src/stream_chat_localizations_it.dart b/packages/stream_chat_localizations/lib/src/stream_chat_localizations_it.dart index 177854a30..b407629d1 100644 --- a/packages/stream_chat_localizations/lib/src/stream_chat_localizations_it.dart +++ b/packages/stream_chat_localizations/lib/src/stream_chat_localizations_it.dart @@ -442,7 +442,7 @@ Attenzione: il limite massimo di $limit file è stato superato. String get linkDisabledError => 'I links sono disattivati'; @override - String unreadMessagesSeparatorText(int unreadCount) => "Nouveaux messages"; + String unreadMessagesSeparatorText(int unreadCount) => 'Nouveaux messages'; @override String get enableFileAccessMessage => "Per favore attiva l'accesso ai file" diff --git a/packages/stream_chat_localizations/lib/src/stream_chat_localizations_pt.dart b/packages/stream_chat_localizations/lib/src/stream_chat_localizations_pt.dart index 9464e90d8..874eb1189 100644 --- a/packages/stream_chat_localizations/lib/src/stream_chat_localizations_pt.dart +++ b/packages/stream_chat_localizations/lib/src/stream_chat_localizations_pt.dart @@ -438,7 +438,7 @@ Não é possível adicionar mais de $limit arquivos de uma vez String get viewLibrary => 'Ver biblioteca'; @override - String unreadMessagesSeparatorText(int unreadCount) => "Novas mensagens"; + String unreadMessagesSeparatorText(int unreadCount) => 'Novas mensagens'; @override String get enableFileAccessMessage => From 409367a5ad4e2895935a0682a28b024497b22aed Mon Sep 17 00:00:00 2001 From: Leandro Borges Ferreira Date: Fri, 27 Jan 2023 13:52:15 +0100 Subject: [PATCH 011/107] Update CHANGELOG.md --- packages/stream_chat_localizations/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/stream_chat_localizations/CHANGELOG.md b/packages/stream_chat_localizations/CHANGELOG.md index 87947c785..20fd8458a 100644 --- a/packages/stream_chat_localizations/CHANGELOG.md +++ b/packages/stream_chat_localizations/CHANGELOG.md @@ -4,6 +4,7 @@ * Added support for [Catalan](https://github.com/GetStream/stream-chat-flutter/blob/master/packages/stream_chat_localizations/lib/src/stream_chat_localizations_ca.dart) locale. * Added translations for new `noPhotoOrVideoLabel` label. +* Changed text in New messages separator. Now is doesn't count the new messages and only shows "New messages". All the translations were updated. 🔄 Changed From 1782eb3bea8311c0820667ae61d7e653db7c29d1 Mon Sep 17 00:00:00 2001 From: Leandro Borges Ferreira Date: Mon, 30 Jan 2023 12:55:12 +0100 Subject: [PATCH 012/107] Adding start/stop watching event --- .../stream_chat/lib/src/client/channel.dart | 33 +++++++++++++++++++ packages/stream_chat/lib/src/event_type.dart | 6 ++++ 2 files changed, 39 insertions(+) diff --git a/packages/stream_chat/lib/src/client/channel.dart b/packages/stream_chat/lib/src/client/channel.dart index bfaae76a3..8b132f025 100644 --- a/packages/stream_chat/lib/src/client/channel.dart +++ b/packages/stream_chat/lib/src/client/channel.dart @@ -1754,6 +1754,26 @@ class ChannelClientState { )); } + void _listenUserStartWatching() { + _subscriptions.add( + _channel.on(EventType.userWatchingStart).listen((event) { + if (event.user != null) { + _incrementWatcher(event.user!); + } + }), + ); + } + + void _listenUserStopWatching() { + _subscriptions.add( + _channel.on(EventType.userWatchingStop).listen((event) { + if (event.user != null) { + channelState.watchers?.remove(event.user); + } + }), + ); + } + void _listenMemberUnbanned() { _subscriptions.add(_channel .on(EventType.userUnbanned) @@ -1770,6 +1790,19 @@ class ChannelClientState { )); } + void _incrementWatcher(User user) { + List newWatchers; + + if (channelState.watchers == null) { + channelState.watchers!.add(user); + newWatchers = channelState.watchers!; + } else { + newWatchers = [user]; + } + + channelState.copyWith(watchers: newWatchers); + } + void _updateMember(Member member) { final currentMembers = [...members]; final memberIndex = currentMembers.indexWhere( diff --git a/packages/stream_chat/lib/src/event_type.dart b/packages/stream_chat/lib/src/event_type.dart index b553943e1..f8fb7ed7b 100644 --- a/packages/stream_chat/lib/src/event_type.dart +++ b/packages/stream_chat/lib/src/event_type.dart @@ -36,6 +36,12 @@ class EventType { /// Event sent when updating a message static const String messageUpdated = 'message.updated'; + /// Event sent when a user starts watching a channel + static const String userWatchingStart = 'user.watching.start'; + + /// Event sent when a user stops watching a channel + static const String userWatchingStop = 'user.watching.stop'; + /// Event sent when reading a message static const String messageRead = 'message.read'; From 46f09e706703254988229e5d04538361e937a602 Mon Sep 17 00:00:00 2001 From: Leandro Borges Ferreira Date: Mon, 30 Jan 2023 17:41:09 +0100 Subject: [PATCH 013/107] Listening for watchers --- packages/stream_chat/lib/src/client/channel.dart | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/packages/stream_chat/lib/src/client/channel.dart b/packages/stream_chat/lib/src/client/channel.dart index 8b132f025..15f093e54 100644 --- a/packages/stream_chat/lib/src/client/channel.dart +++ b/packages/stream_chat/lib/src/client/channel.dart @@ -1613,6 +1613,10 @@ class ChannelClientState { _listenMemberUnbanned(); + _listenUserStartWatching(); + + _listenUserStopWatching(); + _startCleaningStaleTypingEvents(); _startCleaningStalePinnedMessages(); @@ -1793,7 +1797,7 @@ class ChannelClientState { void _incrementWatcher(User user) { List newWatchers; - if (channelState.watchers == null) { + if (channelState.watchers != null) { channelState.watchers!.add(user); newWatchers = channelState.watchers!; } else { @@ -2113,9 +2117,13 @@ class ChannelClientState { /// Channel watchers list as a stream. Stream> get watchersStream => CombineLatestStream.combine2< List?, Map, List>( - channelStateStream.map((cs) => cs.watchers), + channelStateStream + .map((cs) => cs.watchers) + .where((watchers) => watchers != null), _channel.client.state.usersStream, - (watchers, users) => watchers!.map((e) => users[e.id] ?? e).toList(), + (watchers, users) { + return watchers!.map((e) => users[e.id] ?? e).toList(); + } , ); /// Channel member for the current user. From 1b9110a03442cbd6c2eedc3a2ad16efcc049c997 Mon Sep 17 00:00:00 2001 From: Leandro Borges Ferreira Date: Mon, 30 Jan 2023 17:58:30 +0100 Subject: [PATCH 014/107] Simply watchers logic --- packages/stream_chat/lib/src/client/channel.dart | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/packages/stream_chat/lib/src/client/channel.dart b/packages/stream_chat/lib/src/client/channel.dart index 15f093e54..a05f99225 100644 --- a/packages/stream_chat/lib/src/client/channel.dart +++ b/packages/stream_chat/lib/src/client/channel.dart @@ -2115,16 +2115,9 @@ class ChannelClientState { .toList(); /// Channel watchers list as a stream. - Stream> get watchersStream => CombineLatestStream.combine2< - List?, Map, List>( - channelStateStream - .map((cs) => cs.watchers) - .where((watchers) => watchers != null), - _channel.client.state.usersStream, - (watchers, users) { - return watchers!.map((e) => users[e.id] ?? e).toList(); - } , - ); + Stream?> get watchersStream => channelStateStream + .map((cs) => cs.watchers) + .where((watchers) => watchers != null); /// Channel member for the current user. Member? get currentUserMember => members.firstWhereOrNull( From c37c2827418e9e0c1f368fabed04c44833dcfbd8 Mon Sep 17 00:00:00 2001 From: Leandro Borges Ferreira Date: Mon, 30 Jan 2023 18:16:41 +0100 Subject: [PATCH 015/107] Update CHANGELOG.md --- packages/stream_chat/CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/stream_chat/CHANGELOG.md b/packages/stream_chat/CHANGELOG.md index 15a9a9b2f..b394f1eb6 100644 --- a/packages/stream_chat/CHANGELOG.md +++ b/packages/stream_chat/CHANGELOG.md @@ -1,3 +1,9 @@ +## To come + +🐞 Fixed + +- Fixed streamWatchers. Before it was always new, now it is possible to follow the watchers of a channel. + ## 5.3.0 🔄 Changed From a34ac516528ac899086b96bb2c9bd3bf76480f5a Mon Sep 17 00:00:00 2001 From: Leandro Borges Ferreira Date: Tue, 31 Jan 2023 14:16:58 +0100 Subject: [PATCH 016/107] Emmiting changes instead of applying on place --- .../stream_chat/lib/src/client/channel.dart | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/packages/stream_chat/lib/src/client/channel.dart b/packages/stream_chat/lib/src/client/channel.dart index a05f99225..e9635caa8 100644 --- a/packages/stream_chat/lib/src/client/channel.dart +++ b/packages/stream_chat/lib/src/client/channel.dart @@ -1762,7 +1762,14 @@ class ChannelClientState { _subscriptions.add( _channel.on(EventType.userWatchingStart).listen((event) { if (event.user != null) { - _incrementWatcher(event.user!); + final watcher = event.user; + final existingWatchers = channelState.watchers ?? []; + updateChannelState(channelState.copyWith( + watchers: [ + ...existingWatchers, + watcher!, + ], + )); } }), ); @@ -1772,7 +1779,14 @@ class ChannelClientState { _subscriptions.add( _channel.on(EventType.userWatchingStop).listen((event) { if (event.user != null) { - channelState.watchers?.remove(event.user); + final watcher = event.user; + final existingWatchers = channelState.watchers ?? []; + + updateChannelState(channelState.copyWith( + watchers: existingWatchers + .where((user) => user.id != watcher!.id) + .toList(growable: false), + )); } }), ); From 41391dd3373e9788933e3c7d49de985c1121a4fb Mon Sep 17 00:00:00 2001 From: Leandro Borges Ferreira Date: Tue, 31 Jan 2023 14:22:11 +0100 Subject: [PATCH 017/107] Removing unused code --- packages/stream_chat/lib/src/client/channel.dart | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/packages/stream_chat/lib/src/client/channel.dart b/packages/stream_chat/lib/src/client/channel.dart index e9635caa8..68ce97173 100644 --- a/packages/stream_chat/lib/src/client/channel.dart +++ b/packages/stream_chat/lib/src/client/channel.dart @@ -1808,19 +1808,6 @@ class ChannelClientState { )); } - void _incrementWatcher(User user) { - List newWatchers; - - if (channelState.watchers != null) { - channelState.watchers!.add(user); - newWatchers = channelState.watchers!; - } else { - newWatchers = [user]; - } - - channelState.copyWith(watchers: newWatchers); - } - void _updateMember(Member member) { final currentMembers = [...members]; final memberIndex = currentMembers.indexWhere( From 8cc6fa941cbde0ed42a4653fffbf31277a67d612 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Adasiewicz?= Date: Thu, 2 Feb 2023 10:30:49 +0100 Subject: [PATCH 018/107] chore(ui): update share_plus dependency --- packages/stream_chat_flutter/CHANGELOG.md | 4 ++++ packages/stream_chat_flutter/pubspec.yaml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/stream_chat_flutter/CHANGELOG.md b/packages/stream_chat_flutter/CHANGELOG.md index 20c9cd513..7d7b14988 100644 --- a/packages/stream_chat_flutter/CHANGELOG.md +++ b/packages/stream_chat_flutter/CHANGELOG.md @@ -1,3 +1,7 @@ +## Upcoming + +- Updated `share_plus` dependency to `^6.3.0` + ## 5.3.0 🔄 Changed diff --git a/packages/stream_chat_flutter/pubspec.yaml b/packages/stream_chat_flutter/pubspec.yaml index ae24dbe50..8bc6e544e 100644 --- a/packages/stream_chat_flutter/pubspec.yaml +++ b/packages/stream_chat_flutter/pubspec.yaml @@ -37,7 +37,7 @@ dependencies: photo_manager: ^2.5.2 photo_view: ^0.14.0 rxdart: ^0.27.0 - share_plus: ^4.5.0 + share_plus: ^6.3.0 shimmer: ^2.0.0 stream_chat_flutter_core: ^5.3.0 synchronized: ^3.0.0 From cf45b4476fb7688a5bc455983593e975a18e799d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Adasiewicz?= Date: Thu, 2 Feb 2023 10:37:56 +0100 Subject: [PATCH 019/107] remove import --- packages/stream_chat_flutter/lib/src/gallery/gallery_footer.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/stream_chat_flutter/lib/src/gallery/gallery_footer.dart b/packages/stream_chat_flutter/lib/src/gallery/gallery_footer.dart index e46ec3bcd..c5cfad788 100644 --- a/packages/stream_chat_flutter/lib/src/gallery/gallery_footer.dart +++ b/packages/stream_chat_flutter/lib/src/gallery/gallery_footer.dart @@ -1,7 +1,6 @@ import 'dart:io'; import 'package:cached_network_image/cached_network_image.dart'; -import 'package:file_selector/file_selector.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:path_provider/path_provider.dart'; From 02ab95404815825c003101a7c33c9055f6643f5d Mon Sep 17 00:00:00 2001 From: Leandro Borges Ferreira Date: Thu, 2 Feb 2023 17:42:49 +0100 Subject: [PATCH 020/107] Adding custom line for url attachment --- .../example/lib/tutorial_part_6.dart | 4 ++++ .../lib/src/attachment/url_attachment.dart | 2 +- .../lib/src/theme/message_theme.dart | 16 +++++++++++++--- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/packages/stream_chat_flutter/example/lib/tutorial_part_6.dart b/packages/stream_chat_flutter/example/lib/tutorial_part_6.dart index cd80af444..28f061ff7 100644 --- a/packages/stream_chat_flutter/example/lib/tutorial_part_6.dart +++ b/packages/stream_chat_flutter/example/lib/tutorial_part_6.dart @@ -74,6 +74,9 @@ class MyApp extends StatelessWidget { fit: BoxFit.cover, ), ), + ownMessageTheme: const StreamMessageThemeData( + urlLinkTitleMaxLine: 1, + ), otherMessageTheme: StreamMessageThemeData( messageBackgroundColor: colorTheme.textHighEmphasis, messageTextStyle: TextStyle( @@ -82,6 +85,7 @@ class MyApp extends StatelessWidget { avatarTheme: StreamAvatarThemeData( borderRadius: BorderRadius.circular(8), ), + urlLinkTitleMaxLine: 1, ), ).merge(defaultTheme); diff --git a/packages/stream_chat_flutter/lib/src/attachment/url_attachment.dart b/packages/stream_chat_flutter/lib/src/attachment/url_attachment.dart index ce166195d..11cf49142 100644 --- a/packages/stream_chat_flutter/lib/src/attachment/url_attachment.dart +++ b/packages/stream_chat_flutter/lib/src/attachment/url_attachment.dart @@ -107,7 +107,7 @@ class StreamUrlAttachment extends StatelessWidget { if (urlAttachment.title != null) Text( urlAttachment.title!.trim(), - maxLines: 1, + maxLines: messageTheme.urlLinkTitleMaxLine ?? 1, overflow: TextOverflow.ellipsis, style: chatThemeData.textTheme.body .copyWith(fontWeight: FontWeight.w700), diff --git a/packages/stream_chat_flutter/lib/src/theme/message_theme.dart b/packages/stream_chat_flutter/lib/src/theme/message_theme.dart index f83971f23..999d2fe1c 100644 --- a/packages/stream_chat_flutter/lib/src/theme/message_theme.dart +++ b/packages/stream_chat_flutter/lib/src/theme/message_theme.dart @@ -21,6 +21,7 @@ class StreamMessageThemeData with Diagnosticable { this.avatarTheme, this.createdAtStyle, this.linkBackgroundColor, + this.urlLinkTitleMaxLine, }); /// Text style for message text @@ -59,6 +60,9 @@ class StreamMessageThemeData with Diagnosticable { /// Background color for messages with url attachments. final Color? linkBackgroundColor; + /// Max number of lines in Url link title + final int? urlLinkTitleMaxLine; + /// Copy with a theme StreamMessageThemeData copyWith({ TextStyle? messageTextStyle, @@ -73,6 +77,7 @@ class StreamMessageThemeData with Diagnosticable { Color? reactionsBorderColor, Color? reactionsMaskColor, Color? linkBackgroundColor, + int? urlLinkTitleMaxLine, }) { return StreamMessageThemeData( messageTextStyle: messageTextStyle ?? this.messageTextStyle, @@ -89,6 +94,7 @@ class StreamMessageThemeData with Diagnosticable { reactionsBorderColor: reactionsBorderColor ?? this.reactionsBorderColor, reactionsMaskColor: reactionsMaskColor ?? this.reactionsMaskColor, linkBackgroundColor: linkBackgroundColor ?? this.linkBackgroundColor, + urlLinkTitleMaxLine: urlLinkTitleMaxLine ?? this.urlLinkTitleMaxLine, ); } @@ -148,6 +154,7 @@ class StreamMessageThemeData with Diagnosticable { reactionsBorderColor: other.reactionsBorderColor, reactionsMaskColor: other.reactionsMaskColor, linkBackgroundColor: other.linkBackgroundColor, + urlLinkTitleMaxLine: other.urlLinkTitleMaxLine, ); } @@ -167,7 +174,8 @@ class StreamMessageThemeData with Diagnosticable { reactionsBorderColor == other.reactionsBorderColor && reactionsMaskColor == other.reactionsMaskColor && avatarTheme == other.avatarTheme && - linkBackgroundColor == other.linkBackgroundColor; + linkBackgroundColor == other.linkBackgroundColor && + urlLinkTitleMaxLine == other.urlLinkTitleMaxLine; @override int get hashCode => @@ -182,7 +190,8 @@ class StreamMessageThemeData with Diagnosticable { reactionsBorderColor.hashCode ^ reactionsMaskColor.hashCode ^ avatarTheme.hashCode ^ - linkBackgroundColor.hashCode; + linkBackgroundColor.hashCode ^ + urlLinkTitleMaxLine.hashCode; @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { @@ -199,6 +208,7 @@ class StreamMessageThemeData with Diagnosticable { ..add(ColorProperty('reactionsBackgroundColor', reactionsBackgroundColor)) ..add(ColorProperty('reactionsBorderColor', reactionsBorderColor)) ..add(ColorProperty('reactionsMaskColor', reactionsMaskColor)) - ..add(ColorProperty('linkBackgroundColor', linkBackgroundColor)); + ..add(ColorProperty('linkBackgroundColor', linkBackgroundColor)) + ..add(DiagnosticsProperty('urlLinkTitleMaxLine', urlLinkTitleMaxLine)); } } From c09d0fc20e4001c348170a0c66d922f419dc6b9d Mon Sep 17 00:00:00 2001 From: Leandro Borges Ferreira Date: Thu, 2 Feb 2023 17:57:37 +0100 Subject: [PATCH 021/107] Update CHANGELOG.md --- packages/stream_chat_flutter/CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/stream_chat_flutter/CHANGELOG.md b/packages/stream_chat_flutter/CHANGELOG.md index 20c9cd513..10b3fa6cb 100644 --- a/packages/stream_chat_flutter/CHANGELOG.md +++ b/packages/stream_chat_flutter/CHANGELOG.md @@ -1,3 +1,8 @@ +## 5.4.0 + +✅ Added +- Now it is possible to customize the max lines of the title of a url attachment. Before it was always 1 line. + ## 5.3.0 🔄 Changed From b656c8b7d8082fb95c42506d32af38cfd87b2e28 Mon Sep 17 00:00:00 2001 From: Sahil Kumar Date: Wed, 8 Feb 2023 19:08:21 +0530 Subject: [PATCH 022/107] fix(llc): cancelling attachments now removes it from the message. Signed-off-by: xsahil03x --- .../stream_chat/lib/src/client/channel.dart | 19 +++++++++++++++++-- .../lib/src/core/error/stream_chat_error.dart | 6 ++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/packages/stream_chat/lib/src/client/channel.dart b/packages/stream_chat/lib/src/client/channel.dart index bfaae76a3..888780f33 100644 --- a/packages/stream_chat/lib/src/client/channel.dart +++ b/packages/stream_chat/lib/src/client/channel.dart @@ -463,12 +463,19 @@ class Channel { client.logger.info('Found ${attachments.length} attachments'); - void updateAttachment(Attachment attachment) { + void updateAttachment(Attachment attachment, {bool remove = false}) { final index = message!.attachments.indexWhere( (it) => it.id == attachment.id, ); if (index != -1) { - final newAttachments = [...message!.attachments]..[index] = attachment; + // update or remove attachment from message. + final List newAttachments; + if (remove) { + newAttachments = [...message!.attachments]..removeAt(index); + } else { + newAttachments = [...message!.attachments]..[index] = attachment; + } + final updatedMessage = message!.copyWith(attachments: newAttachments); state?.updateMessage(updatedMessage); // updating original message for next iteration @@ -533,6 +540,14 @@ class Channel { ); } }).catchError((e, stk) { + if (e is StreamChatNetworkError && e.isRequestCancelledError) { + client.logger.info('Attachment ${it.id} upload cancelled'); + + // remove attachment from message if cancelled. + updateAttachment(it, remove: true); + return; + } + client.logger.severe('error uploading the attachment', e, stk); updateAttachment( it.copyWith(uploadState: UploadState.failed(error: e.toString())), diff --git a/packages/stream_chat/lib/src/core/error/stream_chat_error.dart b/packages/stream_chat/lib/src/core/error/stream_chat_error.dart index 80e83079b..fc069a90d 100644 --- a/packages/stream_chat/lib/src/core/error/stream_chat_error.dart +++ b/packages/stream_chat/lib/src/core/error/stream_chat_error.dart @@ -74,6 +74,7 @@ class StreamChatNetworkError extends StreamChatError { ChatErrorCode errorCode, { int? statusCode, this.data, + this.isRequestCancelledError = false, }) : code = errorCode.code, statusCode = statusCode ?? data?.statusCode, super(errorCode.message); @@ -84,6 +85,7 @@ class StreamChatNetworkError extends StreamChatError { required String message, this.statusCode, this.data, + this.isRequestCancelledError = false, }) : super(message); /// @@ -100,6 +102,7 @@ class StreamChatNetworkError extends StreamChatError { errorResponse?.message ?? response?.statusMessage ?? error.message, statusCode: errorResponse?.statusCode ?? response?.statusCode, data: errorResponse, + isRequestCancelledError: error.type == DioErrorType.cancel, )..stackTrace = error.stackTrace; } @@ -112,6 +115,9 @@ class StreamChatNetworkError extends StreamChatError { /// Response body. please refer to [ErrorResponse]. final ErrorResponse? data; + /// True, in case the error is due to a cancelled network request. + final bool isRequestCancelledError; + StackTrace? _stackTrace; /// From 065bbbc8f320a5e3c9d3ae34f6d763eee4f4b560 Mon Sep 17 00:00:00 2001 From: Sahil Kumar Date: Wed, 8 Feb 2023 19:09:32 +0530 Subject: [PATCH 023/107] chore(llc): update CHANGELOG.md Signed-off-by: xsahil03x --- packages/stream_chat/CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/stream_chat/CHANGELOG.md b/packages/stream_chat/CHANGELOG.md index 15a9a9b2f..f11ba8c1b 100644 --- a/packages/stream_chat/CHANGELOG.md +++ b/packages/stream_chat/CHANGELOG.md @@ -1,3 +1,9 @@ +## Upcoming + +🔄 Changed + +- Cancelling a attachment upload now removes the attachment from the message. + ## 5.3.0 🔄 Changed From e6e311bfcb5e3dbcc9071ed556ab55def6ffb911 Mon Sep 17 00:00:00 2001 From: Enzo Conty Date: Wed, 8 Feb 2023 14:44:14 +0100 Subject: [PATCH 024/107] replacing sort by channelStateSort since it's deprecated --- .../01-custom-widgets/07-slidable_channel_list_preview.mdx | 2 +- .../03-stream_chat_flutter/stream_channel_grid_view.mdx | 2 +- .../03-stream_chat_flutter/stream_channel_list_header.mdx | 2 +- .../03-stream_chat_flutter/stream_channel_list_view.mdx | 2 +- .../Flutter/05-guides/08-migrations/migration_guide_4_0.mdx | 2 +- .../05-guides/09-initialize_stream_chat_widget_tree.mdx | 4 ++-- .../version-4.x.x/Flutter/guides/migration_guide_4_0.mdx | 2 +- .../Flutter/guides/slidable_channel_list_preview.mdx | 2 +- .../Flutter/stream_chat_flutter/stream_channel_grid_view.mdx | 2 +- .../stream_chat_flutter/stream_channel_list_header.mdx | 2 +- .../Flutter/stream_chat_flutter/stream_channel_list_view.mdx | 2 +- 11 files changed, 12 insertions(+), 12 deletions(-) diff --git a/docusaurus/docs/Flutter/02-customization/01-custom-widgets/07-slidable_channel_list_preview.mdx b/docusaurus/docs/Flutter/02-customization/01-custom-widgets/07-slidable_channel_list_preview.mdx index 67372ef59..35593ba69 100644 --- a/docusaurus/docs/Flutter/02-customization/01-custom-widgets/07-slidable_channel_list_preview.mdx +++ b/docusaurus/docs/Flutter/02-customization/01-custom-widgets/07-slidable_channel_list_preview.mdx @@ -104,7 +104,7 @@ class _ChannelListPageState extends State { 'members', [StreamChat.of(context).currentUser!.id], ), - sort: const [SortOption('last_message_at')], + channelStateSort: const [SortOption('last_message_at')], ); @override diff --git a/docusaurus/docs/Flutter/03-stream_chat_flutter/stream_channel_grid_view.mdx b/docusaurus/docs/Flutter/03-stream_chat_flutter/stream_channel_grid_view.mdx index 16bad7dc1..0fcde5c10 100644 --- a/docusaurus/docs/Flutter/03-stream_chat_flutter/stream_channel_grid_view.mdx +++ b/docusaurus/docs/Flutter/03-stream_chat_flutter/stream_channel_grid_view.mdx @@ -40,7 +40,7 @@ class _ChannelGridPageState extends State { 'members', [StreamChat.of(context).currentUser!.id], ), - sort: const [SortOption('last_message_at')], + channelStateSort: const [SortOption('last_message_at')], ); @override diff --git a/docusaurus/docs/Flutter/03-stream_chat_flutter/stream_channel_list_header.mdx b/docusaurus/docs/Flutter/03-stream_chat_flutter/stream_channel_list_header.mdx index 4c8fbc632..f05c8863a 100644 --- a/docusaurus/docs/Flutter/03-stream_chat_flutter/stream_channel_list_header.mdx +++ b/docusaurus/docs/Flutter/03-stream_chat_flutter/stream_channel_list_header.mdx @@ -44,7 +44,7 @@ class _ChannelListPageState extends State { 'members', [StreamChat.of(context).currentUser!.id], ), - sort: const [SortOption('last_message_at')], + channelStateSort: const [SortOption('last_message_at')], ); @override diff --git a/docusaurus/docs/Flutter/03-stream_chat_flutter/stream_channel_list_view.mdx b/docusaurus/docs/Flutter/03-stream_chat_flutter/stream_channel_list_view.mdx index e87062904..33376fcf3 100644 --- a/docusaurus/docs/Flutter/03-stream_chat_flutter/stream_channel_list_view.mdx +++ b/docusaurus/docs/Flutter/03-stream_chat_flutter/stream_channel_list_view.mdx @@ -50,7 +50,7 @@ class _ChannelListPageState extends State { 'members', [StreamChat.of(context).currentUser!.id], ), - sort: const [SortOption('last_message_at')], + channelStateSort: const [SortOption('last_message_at')], ); @override diff --git a/docusaurus/docs/Flutter/05-guides/08-migrations/migration_guide_4_0.mdx b/docusaurus/docs/Flutter/05-guides/08-migrations/migration_guide_4_0.mdx index fa2d21b4b..14fa46eb1 100644 --- a/docusaurus/docs/Flutter/05-guides/08-migrations/migration_guide_4_0.mdx +++ b/docusaurus/docs/Flutter/05-guides/08-migrations/migration_guide_4_0.mdx @@ -268,7 +268,7 @@ class _ChannelListPageState extends State { 'members', [StreamChat.of(context).currentUser!.id], ), - sort: const [SortOption('last_message_at')], + channelStateSort: const [SortOption('last_message_at')], ); @override diff --git a/docusaurus/docs/Flutter/05-guides/09-initialize_stream_chat_widget_tree.mdx b/docusaurus/docs/Flutter/05-guides/09-initialize_stream_chat_widget_tree.mdx index 17476d211..5443c51fa 100644 --- a/docusaurus/docs/Flutter/05-guides/09-initialize_stream_chat_widget_tree.mdx +++ b/docusaurus/docs/Flutter/05-guides/09-initialize_stream_chat_widget_tree.mdx @@ -396,7 +396,7 @@ class _ChannelListPageState extends State { 'members', [StreamChat.of(context).currentUser!.id], ), - sort: const [SortOption('last_message_at')], + channelStateSort: const [SortOption('last_message_at')], ); @override @@ -654,7 +654,7 @@ class _ChannelListPageState extends State { 'members', [StreamChat.of(context).currentUser!.id], ), - sort: const [SortOption('last_message_at')], + channelStateSort: const [SortOption('last_message_at')], ); @override diff --git a/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/guides/migration_guide_4_0.mdx b/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/guides/migration_guide_4_0.mdx index 887cef3ae..1e27ec6a8 100644 --- a/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/guides/migration_guide_4_0.mdx +++ b/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/guides/migration_guide_4_0.mdx @@ -267,7 +267,7 @@ class _ChannelListPageState extends State { 'members', [StreamChat.of(context).currentUser!.id], ), - sort: const [SortOption('last_message_at')], + channelStateSort: const [SortOption('last_message_at')], ); @override diff --git a/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/guides/slidable_channel_list_preview.mdx b/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/guides/slidable_channel_list_preview.mdx index 9d57e7092..35dc6a750 100644 --- a/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/guides/slidable_channel_list_preview.mdx +++ b/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/guides/slidable_channel_list_preview.mdx @@ -105,7 +105,7 @@ class _ChannelListPageState extends State { 'members', [StreamChat.of(context).currentUser!.id], ), - sort: const [SortOption('last_message_at')], + channelStateSort: const [SortOption('last_message_at')], ); @override diff --git a/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/stream_chat_flutter/stream_channel_grid_view.mdx b/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/stream_chat_flutter/stream_channel_grid_view.mdx index 16bad7dc1..0fcde5c10 100644 --- a/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/stream_chat_flutter/stream_channel_grid_view.mdx +++ b/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/stream_chat_flutter/stream_channel_grid_view.mdx @@ -40,7 +40,7 @@ class _ChannelGridPageState extends State { 'members', [StreamChat.of(context).currentUser!.id], ), - sort: const [SortOption('last_message_at')], + channelStateSort: const [SortOption('last_message_at')], ); @override diff --git a/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/stream_chat_flutter/stream_channel_list_header.mdx b/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/stream_chat_flutter/stream_channel_list_header.mdx index 4c8fbc632..f05c8863a 100644 --- a/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/stream_chat_flutter/stream_channel_list_header.mdx +++ b/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/stream_chat_flutter/stream_channel_list_header.mdx @@ -44,7 +44,7 @@ class _ChannelListPageState extends State { 'members', [StreamChat.of(context).currentUser!.id], ), - sort: const [SortOption('last_message_at')], + channelStateSort: const [SortOption('last_message_at')], ); @override diff --git a/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/stream_chat_flutter/stream_channel_list_view.mdx b/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/stream_chat_flutter/stream_channel_list_view.mdx index 258c0b64b..a22c108ce 100644 --- a/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/stream_chat_flutter/stream_channel_list_view.mdx +++ b/docusaurus/flutter_versioned_docs/version-4.x.x/Flutter/stream_chat_flutter/stream_channel_list_view.mdx @@ -50,7 +50,7 @@ class _ChannelListPageState extends State { 'members', [StreamChat.of(context).currentUser!.id], ), - sort: const [SortOption('last_message_at')], + channelStateSort: const [SortOption('last_message_at')], ); @override From b1e71a28c6bf8b85209ca158b191ebc68988f886 Mon Sep 17 00:00:00 2001 From: Sahil Kumar Date: Thu, 9 Feb 2023 15:17:39 +0530 Subject: [PATCH 025/107] chore(llc): minor changes Signed-off-by: xsahil03x --- .../stream_chat/lib/src/client/channel.dart | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/packages/stream_chat/lib/src/client/channel.dart b/packages/stream_chat/lib/src/client/channel.dart index 68ce97173..7abcf1d02 100644 --- a/packages/stream_chat/lib/src/client/channel.dart +++ b/packages/stream_chat/lib/src/client/channel.dart @@ -1761,13 +1761,13 @@ class ChannelClientState { void _listenUserStartWatching() { _subscriptions.add( _channel.on(EventType.userWatchingStart).listen((event) { - if (event.user != null) { - final watcher = event.user; - final existingWatchers = channelState.watchers ?? []; + final watcher = event.user; + if (watcher != null) { + final existingWatchers = channelState.watchers; updateChannelState(channelState.copyWith( watchers: [ - ...existingWatchers, - watcher!, + ...?existingWatchers, + watcher, ], )); } @@ -1778,13 +1778,12 @@ class ChannelClientState { void _listenUserStopWatching() { _subscriptions.add( _channel.on(EventType.userWatchingStop).listen((event) { - if (event.user != null) { - final watcher = event.user; - final existingWatchers = channelState.watchers ?? []; - + final watcher = event.user; + if (watcher != null) { + final existingWatchers = channelState.watchers; updateChannelState(channelState.copyWith( watchers: existingWatchers - .where((user) => user.id != watcher!.id) + ?.where((user) => user.id != watcher.id) .toList(growable: false), )); } @@ -2116,9 +2115,12 @@ class ChannelClientState { .toList(); /// Channel watchers list as a stream. - Stream?> get watchersStream => channelStateStream - .map((cs) => cs.watchers) - .where((watchers) => watchers != null); + Stream> get watchersStream => CombineLatestStream.combine2< + List?, Map, List>( + channelStateStream.map((cs) => cs.watchers), + _channel.client.state.usersStream, + (watchers, users) => watchers!.map((e) => users[e.id] ?? e).toList(), + ).distinct(const ListEquality().equals); /// Channel member for the current user. Member? get currentUserMember => members.firstWhereOrNull( From 6e9202fe61793319f599036331ddcad4f67e9475 Mon Sep 17 00:00:00 2001 From: Sahil Kumar Date: Thu, 9 Feb 2023 15:47:36 +0530 Subject: [PATCH 026/107] chore(llc): rename theme property Signed-off-by: xsahil03x --- .../example/lib/tutorial_part_6.dart | 4 ++-- .../lib/src/attachment/url_attachment.dart | 2 +- .../lib/src/theme/message_theme.dart | 18 +++++++++++------- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/packages/stream_chat_flutter/example/lib/tutorial_part_6.dart b/packages/stream_chat_flutter/example/lib/tutorial_part_6.dart index 28f061ff7..dca8eaa1c 100644 --- a/packages/stream_chat_flutter/example/lib/tutorial_part_6.dart +++ b/packages/stream_chat_flutter/example/lib/tutorial_part_6.dart @@ -75,7 +75,7 @@ class MyApp extends StatelessWidget { ), ), ownMessageTheme: const StreamMessageThemeData( - urlLinkTitleMaxLine: 1, + urlAttachmentTitleMaxLine: 1, ), otherMessageTheme: StreamMessageThemeData( messageBackgroundColor: colorTheme.textHighEmphasis, @@ -85,7 +85,7 @@ class MyApp extends StatelessWidget { avatarTheme: StreamAvatarThemeData( borderRadius: BorderRadius.circular(8), ), - urlLinkTitleMaxLine: 1, + urlAttachmentTitleMaxLine: 1, ), ).merge(defaultTheme); diff --git a/packages/stream_chat_flutter/lib/src/attachment/url_attachment.dart b/packages/stream_chat_flutter/lib/src/attachment/url_attachment.dart index 11cf49142..10170bb15 100644 --- a/packages/stream_chat_flutter/lib/src/attachment/url_attachment.dart +++ b/packages/stream_chat_flutter/lib/src/attachment/url_attachment.dart @@ -107,7 +107,7 @@ class StreamUrlAttachment extends StatelessWidget { if (urlAttachment.title != null) Text( urlAttachment.title!.trim(), - maxLines: messageTheme.urlLinkTitleMaxLine ?? 1, + maxLines: messageTheme.urlAttachmentTitleMaxLine ?? 1, overflow: TextOverflow.ellipsis, style: chatThemeData.textTheme.body .copyWith(fontWeight: FontWeight.w700), diff --git a/packages/stream_chat_flutter/lib/src/theme/message_theme.dart b/packages/stream_chat_flutter/lib/src/theme/message_theme.dart index 999d2fe1c..7f34800c4 100644 --- a/packages/stream_chat_flutter/lib/src/theme/message_theme.dart +++ b/packages/stream_chat_flutter/lib/src/theme/message_theme.dart @@ -21,7 +21,7 @@ class StreamMessageThemeData with Diagnosticable { this.avatarTheme, this.createdAtStyle, this.linkBackgroundColor, - this.urlLinkTitleMaxLine, + this.urlAttachmentTitleMaxLine, }); /// Text style for message text @@ -61,7 +61,7 @@ class StreamMessageThemeData with Diagnosticable { final Color? linkBackgroundColor; /// Max number of lines in Url link title - final int? urlLinkTitleMaxLine; + final int? urlAttachmentTitleMaxLine; /// Copy with a theme StreamMessageThemeData copyWith({ @@ -94,7 +94,8 @@ class StreamMessageThemeData with Diagnosticable { reactionsBorderColor: reactionsBorderColor ?? this.reactionsBorderColor, reactionsMaskColor: reactionsMaskColor ?? this.reactionsMaskColor, linkBackgroundColor: linkBackgroundColor ?? this.linkBackgroundColor, - urlLinkTitleMaxLine: urlLinkTitleMaxLine ?? this.urlLinkTitleMaxLine, + urlAttachmentTitleMaxLine: + urlLinkTitleMaxLine ?? this.urlAttachmentTitleMaxLine, ); } @@ -154,7 +155,7 @@ class StreamMessageThemeData with Diagnosticable { reactionsBorderColor: other.reactionsBorderColor, reactionsMaskColor: other.reactionsMaskColor, linkBackgroundColor: other.linkBackgroundColor, - urlLinkTitleMaxLine: other.urlLinkTitleMaxLine, + urlLinkTitleMaxLine: other.urlAttachmentTitleMaxLine, ); } @@ -175,7 +176,7 @@ class StreamMessageThemeData with Diagnosticable { reactionsMaskColor == other.reactionsMaskColor && avatarTheme == other.avatarTheme && linkBackgroundColor == other.linkBackgroundColor && - urlLinkTitleMaxLine == other.urlLinkTitleMaxLine; + urlAttachmentTitleMaxLine == other.urlAttachmentTitleMaxLine; @override int get hashCode => @@ -191,7 +192,7 @@ class StreamMessageThemeData with Diagnosticable { reactionsMaskColor.hashCode ^ avatarTheme.hashCode ^ linkBackgroundColor.hashCode ^ - urlLinkTitleMaxLine.hashCode; + urlAttachmentTitleMaxLine.hashCode; @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { @@ -209,6 +210,9 @@ class StreamMessageThemeData with Diagnosticable { ..add(ColorProperty('reactionsBorderColor', reactionsBorderColor)) ..add(ColorProperty('reactionsMaskColor', reactionsMaskColor)) ..add(ColorProperty('linkBackgroundColor', linkBackgroundColor)) - ..add(DiagnosticsProperty('urlLinkTitleMaxLine', urlLinkTitleMaxLine)); + ..add(DiagnosticsProperty( + 'urlAttachmentTitleMaxLine', + urlAttachmentTitleMaxLine, + )); } } From cc1ad224e2137177ff41b32d10287c4d79540e33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Adasiewicz?= Date: Thu, 9 Feb 2023 13:14:44 +0100 Subject: [PATCH 027/107] feat(llc): expose presence property in Channel::watch method --- packages/stream_chat/CHANGELOG.md | 7 +++++-- packages/stream_chat/lib/src/client/channel.dart | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/stream_chat/CHANGELOG.md b/packages/stream_chat/CHANGELOG.md index f0ee6485a..04a47600d 100644 --- a/packages/stream_chat/CHANGELOG.md +++ b/packages/stream_chat/CHANGELOG.md @@ -2,13 +2,16 @@ 🐞 Fixed -- Fixed streamWatchers. Before it was always new, now it is possible to follow the watchers of a channel. -## Upcoming +- Fixed streamWatchers. Before it was always new, now it is possible to follow the watchers of a channel. 🔄 Changed - Cancelling a attachment upload now removes the attachment from the message. +✅ Added + +- Added `presence` property to `Channel::watch` method. + ## 5.3.0 🔄 Changed diff --git a/packages/stream_chat/lib/src/client/channel.dart b/packages/stream_chat/lib/src/client/channel.dart index 528a0fee0..7d8515c73 100644 --- a/packages/stream_chat/lib/src/client/channel.dart +++ b/packages/stream_chat/lib/src/client/channel.dart @@ -1234,11 +1234,11 @@ class Channel { } /// Loads the initial channel state and watches for changes. - Future watch() async { + Future watch({bool presence = false}) async { ChannelState response; try { - response = await query(watch: true); + response = await query(watch: true, presence: presence); } catch (error, stackTrace) { if (!_initializedCompleter.isCompleted) { _initializedCompleter.completeError(error, stackTrace); From 21897381350b7984ea0d7d739c978e8d1f611deb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Adasiewicz?= Date: Thu, 9 Feb 2023 13:59:12 +0100 Subject: [PATCH 028/107] fix analyze --- packages/stream_chat_flutter/lib/src/theme/message_theme.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/stream_chat_flutter/lib/src/theme/message_theme.dart b/packages/stream_chat_flutter/lib/src/theme/message_theme.dart index 7f34800c4..c022d6a68 100644 --- a/packages/stream_chat_flutter/lib/src/theme/message_theme.dart +++ b/packages/stream_chat_flutter/lib/src/theme/message_theme.dart @@ -95,7 +95,7 @@ class StreamMessageThemeData with Diagnosticable { reactionsMaskColor: reactionsMaskColor ?? this.reactionsMaskColor, linkBackgroundColor: linkBackgroundColor ?? this.linkBackgroundColor, urlAttachmentTitleMaxLine: - urlLinkTitleMaxLine ?? this.urlAttachmentTitleMaxLine, + urlLinkTitleMaxLine ?? urlAttachmentTitleMaxLine, ); } From ae5a8af93f1f5e79143836a3ec44f9487da9d0bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Adasiewicz?= Date: Thu, 9 Feb 2023 14:24:13 +0100 Subject: [PATCH 029/107] rename urlLinkTitleMaxLine to urlAttachmentTitleMaxLine --- .../stream_chat_flutter/lib/src/theme/message_theme.dart | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/stream_chat_flutter/lib/src/theme/message_theme.dart b/packages/stream_chat_flutter/lib/src/theme/message_theme.dart index c022d6a68..d95ed7bba 100644 --- a/packages/stream_chat_flutter/lib/src/theme/message_theme.dart +++ b/packages/stream_chat_flutter/lib/src/theme/message_theme.dart @@ -77,7 +77,7 @@ class StreamMessageThemeData with Diagnosticable { Color? reactionsBorderColor, Color? reactionsMaskColor, Color? linkBackgroundColor, - int? urlLinkTitleMaxLine, + int? urlAttachmentTitleMaxLine, }) { return StreamMessageThemeData( messageTextStyle: messageTextStyle ?? this.messageTextStyle, @@ -95,7 +95,7 @@ class StreamMessageThemeData with Diagnosticable { reactionsMaskColor: reactionsMaskColor ?? this.reactionsMaskColor, linkBackgroundColor: linkBackgroundColor ?? this.linkBackgroundColor, urlAttachmentTitleMaxLine: - urlLinkTitleMaxLine ?? urlAttachmentTitleMaxLine, + urlAttachmentTitleMaxLine ?? this.urlAttachmentTitleMaxLine, ); } @@ -155,7 +155,7 @@ class StreamMessageThemeData with Diagnosticable { reactionsBorderColor: other.reactionsBorderColor, reactionsMaskColor: other.reactionsMaskColor, linkBackgroundColor: other.linkBackgroundColor, - urlLinkTitleMaxLine: other.urlAttachmentTitleMaxLine, + urlAttachmentTitleMaxLine: other.urlAttachmentTitleMaxLine, ); } From 87a5acd503652c6390910e06dd1bc0d0fa8dc215 Mon Sep 17 00:00:00 2001 From: Leandro Borges Ferreira Date: Fri, 10 Feb 2023 12:37:54 +0100 Subject: [PATCH 030/107] Support iPad for share button --- .../lib/src/gallery/gallery_footer.dart | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/stream_chat_flutter/lib/src/gallery/gallery_footer.dart b/packages/stream_chat_flutter/lib/src/gallery/gallery_footer.dart index c5cfad788..98ae7df25 100644 --- a/packages/stream_chat_flutter/lib/src/gallery/gallery_footer.dart +++ b/packages/stream_chat_flutter/lib/src/gallery/gallery_footer.dart @@ -60,6 +60,7 @@ class StreamGalleryFooter extends StatefulWidget class _StreamGalleryFooterState extends State { final shareButtonKey = GlobalKey(); + @override Widget build(BuildContext context) { const showShareButton = !kIsWeb; @@ -107,12 +108,19 @@ class _StreamGalleryFooterState extends State { await file.writeAsBytes(bytes); final box = shareButtonKey.currentContext?.findRenderObject(); + final size = shareButtonKey.currentContext?.size; + final position = (box! as RenderBox).localToGlobal(Offset.zero); + await Share.shareXFiles( [XFile(filePath)], - sharePositionOrigin: - Rect.fromLTWH(position.dx, position.dy, 0, 0), + sharePositionOrigin: Rect.fromLTWH( + position.dx, + position.dy, + size?.width ?? 50, + (size?.height ?? 2) / 2, + ), ); }, ), From 69925deec7dd2929058cc5897e6d3a7f98fece04 Mon Sep 17 00:00:00 2001 From: Leandro Borges Ferreira Date: Fri, 10 Feb 2023 12:41:57 +0100 Subject: [PATCH 031/107] Update CHANGELOG.md --- packages/stream_chat_flutter/CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/stream_chat_flutter/CHANGELOG.md b/packages/stream_chat_flutter/CHANGELOG.md index 532bc7553..2585f5b8c 100644 --- a/packages/stream_chat_flutter/CHANGELOG.md +++ b/packages/stream_chat_flutter/CHANGELOG.md @@ -1,5 +1,8 @@ ## Upcoming +🐞 Fixed +[#1463](https://github.com/GetStream/stream-chat-flutter/pull/1463) Fixed support for iPad in the share button for images. + ✅ Added - Now it is possible to customize the max lines of the title of a url attachment. Before it was always 1 line. From a59dd88af4eff786187fa34e6fc6260467f2ef6b Mon Sep 17 00:00:00 2001 From: Leandro Borges Ferreira Date: Thu, 9 Feb 2023 15:07:17 +0100 Subject: [PATCH 032/107] Fixing logic for sending indicator --- .../src/message_widget/sending_indicator_wrapper.dart | 5 +++-- .../channel_scroll_view/stream_channel_list_tile.dart | 11 ++++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/packages/stream_chat_flutter/lib/src/message_widget/sending_indicator_wrapper.dart b/packages/stream_chat_flutter/lib/src/message_widget/sending_indicator_wrapper.dart index 9ca615584..9e2a97c23 100644 --- a/packages/stream_chat_flutter/lib/src/message_widget/sending_indicator_wrapper.dart +++ b/packages/stream_chat_flutter/lib/src/message_widget/sending_indicator_wrapper.dart @@ -65,10 +65,11 @@ class SendingIndicatorWrapper extends StatelessWidget { initialData: channel.state?.read, builder: (context, data) { final readList = data.where((it) => - it.user.id != streamChat.currentUser?.id && + it.user.id != streamChat.currentUser?.id && (it.lastRead.isAfter(message.createdAt) || it.lastRead.isAtSameMomentAs(message.createdAt))); - final isMessageRead = readList.length >= (channel.memberCount ?? 0) - 1; + + final isMessageRead = readList.isNotEmpty; Widget child = StreamSendingIndicator( message: message, isMessageRead: isMessageRead, diff --git a/packages/stream_chat_flutter/lib/src/scroll_view/channel_scroll_view/stream_channel_list_tile.dart b/packages/stream_chat_flutter/lib/src/scroll_view/channel_scroll_view/stream_channel_list_tile.dart index 508b9458d..267c36949 100644 --- a/packages/stream_chat_flutter/lib/src/scroll_view/channel_scroll_view/stream_channel_list_tile.dart +++ b/packages/stream_chat_flutter/lib/src/scroll_view/channel_scroll_view/stream_channel_list_tile.dart @@ -225,6 +225,13 @@ class StreamChannelListTile extends StatelessWidget { return const Offstage(); } + final isLastMessageRead = channelState.read + .where((readData) => readData.user.id != currentUser.id) + .any((readData) => + readData.lastRead.isAfter(lastMessage.createdAt) || + readData.lastRead + .isAtSameMomentAs(lastMessage.createdAt)); + return Padding( padding: const EdgeInsets.only(right: 4), child: @@ -232,9 +239,7 @@ class StreamChannelListTile extends StatelessWidget { StreamSendingIndicator( message: lastMessage, size: channelPreviewTheme.indicatorIconSize, - isMessageRead: channelState - .currentUserRead!.lastRead - .isAfter(lastMessage.createdAt), + isMessageRead: isLastMessageRead, ), ); }, From 769f657a9f71d913a916cac32f1fdee0fad5035c Mon Sep 17 00:00:00 2001 From: Leandro Borges Ferreira Date: Thu, 9 Feb 2023 15:11:07 +0100 Subject: [PATCH 033/107] Update CHANGELOG.md --- packages/stream_chat_flutter/CHANGELOG.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/stream_chat_flutter/CHANGELOG.md b/packages/stream_chat_flutter/CHANGELOG.md index 2585f5b8c..3148266dd 100644 --- a/packages/stream_chat_flutter/CHANGELOG.md +++ b/packages/stream_chat_flutter/CHANGELOG.md @@ -1,7 +1,9 @@ ## Upcoming 🐞 Fixed -[#1463](https://github.com/GetStream/stream-chat-flutter/pull/1463) Fixed support for iPad in the share button for images. + +- [#1461](https://github.com/GetStream/stream-chat-flutter/pull/1461) Fixed logic for showing that a message was read unsing sending indicator. +- [#1463](https://github.com/GetStream/stream-chat-flutter/pull/1463) Fixed support for iPad in the share button for images. ✅ Added From d410441aab5960248a4e7196e786fbc1bc28d75b Mon Sep 17 00:00:00 2001 From: Leandro Borges Ferreira Date: Thu, 9 Feb 2023 17:42:03 +0100 Subject: [PATCH 034/107] Listening for changes both in reads and in messages --- .../stream_channel_list_tile.dart | 49 +++++++++++-------- 1 file changed, 29 insertions(+), 20 deletions(-) diff --git a/packages/stream_chat_flutter/lib/src/scroll_view/channel_scroll_view/stream_channel_list_tile.dart b/packages/stream_chat_flutter/lib/src/scroll_view/channel_scroll_view/stream_channel_list_tile.dart index 267c36949..a17a2eaf6 100644 --- a/packages/stream_chat_flutter/lib/src/scroll_view/channel_scroll_view/stream_channel_list_tile.dart +++ b/packages/stream_chat_flutter/lib/src/scroll_view/channel_scroll_view/stream_channel_list_tile.dart @@ -216,31 +216,40 @@ class StreamChannelListTile extends StatelessWidget { initialData: channelState.messages, comparator: const ListEquality().equals, builder: (context, messages) { - final lastMessage = messages.lastWhereOrNull( - (m) => !m.shadowed && !m.isDeleted, - ); - - if (lastMessage == null || - (lastMessage.user?.id != currentUser.id)) { - return const Offstage(); - } - - final isLastMessageRead = channelState.read - .where((readData) => readData.user.id != currentUser.id) - .any((readData) => - readData.lastRead.isAfter(lastMessage.createdAt) || - readData.lastRead - .isAtSameMomentAs(lastMessage.createdAt)); - - return Padding( - padding: const EdgeInsets.only(right: 4), - child: - sendingIndicatorBuilder?.call(context, lastMessage) ?? + return BetterStreamBuilder>( + stream: channelState.readStream, + initialData: channelState.read, + builder: (context, reads) { + final lastMessage = messages.lastWhereOrNull( + (m) => !m.shadowed && !m.isDeleted, + ); + + if (lastMessage == null || + (lastMessage.user?.id != currentUser.id)) { + return const Offstage(); + } + + final isLastMessageRead = channelState.read + .where( + (readData) => readData.user.id != currentUser.id, + ) + .any((readData) => + readData.lastRead + .isAfter(lastMessage.createdAt) || + readData.lastRead + .isAtSameMomentAs(lastMessage.createdAt)); + + return Padding( + padding: const EdgeInsets.only(right: 4), + child: sendingIndicatorBuilder?.call( + context, lastMessage) ?? StreamSendingIndicator( message: lastMessage, size: channelPreviewTheme.indicatorIconSize, isMessageRead: isLastMessageRead, ), + ); + }, ); }, ), From 28de67097dffa2846a9fa2ff08b73682350ba8bd Mon Sep 17 00:00:00 2001 From: Leandro Borges Ferreira Date: Fri, 10 Feb 2023 15:56:53 +0100 Subject: [PATCH 035/107] Fixing format --- .../lib/src/message_widget/sending_indicator_wrapper.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/stream_chat_flutter/lib/src/message_widget/sending_indicator_wrapper.dart b/packages/stream_chat_flutter/lib/src/message_widget/sending_indicator_wrapper.dart index 9e2a97c23..1e2e31c65 100644 --- a/packages/stream_chat_flutter/lib/src/message_widget/sending_indicator_wrapper.dart +++ b/packages/stream_chat_flutter/lib/src/message_widget/sending_indicator_wrapper.dart @@ -65,7 +65,7 @@ class SendingIndicatorWrapper extends StatelessWidget { initialData: channel.state?.read, builder: (context, data) { final readList = data.where((it) => - it.user.id != streamChat.currentUser?.id && + it.user.id != streamChat.currentUser?.id && (it.lastRead.isAfter(message.createdAt) || it.lastRead.isAtSameMomentAs(message.createdAt))); From 8a9ecbc024d59791a00ef241aef4007591be0ab6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Adasiewicz?= Date: Tue, 14 Feb 2023 13:51:14 +0100 Subject: [PATCH 036/107] feat(ui): expose attachment actions modal builder --- packages/stream_chat_flutter/CHANGELOG.md | 1 + .../lib/src/attachment/giphy_attachment.dart | 5 +++++ .../lib/src/attachment/image_attachment.dart | 6 ++++++ .../lib/src/attachment/image_group.dart | 6 ++++++ .../lib/src/attachment/video_attachment.dart | 6 ++++++ .../lib/src/message_widget/message_widget.dart | 12 ++++++++++++ 6 files changed, 36 insertions(+) diff --git a/packages/stream_chat_flutter/CHANGELOG.md b/packages/stream_chat_flutter/CHANGELOG.md index 532bc7553..77b65b840 100644 --- a/packages/stream_chat_flutter/CHANGELOG.md +++ b/packages/stream_chat_flutter/CHANGELOG.md @@ -3,6 +3,7 @@ ✅ Added - Now it is possible to customize the max lines of the title of a url attachment. Before it was always 1 line. +- Added `attachmentActionsModalBuilder` parameter to `StreamMessageWidget` that allows to customize `AttachmentActionsModal`. 🔄 Changed diff --git a/packages/stream_chat_flutter/lib/src/attachment/giphy_attachment.dart b/packages/stream_chat_flutter/lib/src/attachment/giphy_attachment.dart index 563beb8d6..be756acaf 100644 --- a/packages/stream_chat_flutter/lib/src/attachment/giphy_attachment.dart +++ b/packages/stream_chat_flutter/lib/src/attachment/giphy_attachment.dart @@ -17,6 +17,7 @@ class StreamGiphyAttachment extends StreamAttachmentWidget { this.onShowMessage, this.onReplyMessage, this.onAttachmentTap, + this.attachmentActionsModalBuilder, }); /// {@macro showMessageCallback} @@ -28,6 +29,9 @@ class StreamGiphyAttachment extends StreamAttachmentWidget { /// {@macro onAttachmentTap} final OnAttachmentTap? onAttachmentTap; + /// {@macro attachmentActionsBuilder} + final AttachmentActionsBuilder? attachmentActionsModalBuilder; + @override Widget build(BuildContext context) { final imageUrl = @@ -260,6 +264,7 @@ class StreamGiphyAttachment extends StreamAttachmentWidget { userName: message.user!.name, onShowMessage: onShowMessage, onReplyMessage: onReplyMessage, + attachmentActionsModalBuilder: attachmentActionsModalBuilder, ), ); }, diff --git a/packages/stream_chat_flutter/lib/src/attachment/image_attachment.dart b/packages/stream_chat_flutter/lib/src/attachment/image_attachment.dart index 6a6ee780d..36a0df3a1 100644 --- a/packages/stream_chat_flutter/lib/src/attachment/image_attachment.dart +++ b/packages/stream_chat_flutter/lib/src/attachment/image_attachment.dart @@ -22,6 +22,7 @@ class StreamImageAttachment extends StreamAttachmentWidget { this.imageThumbnailSize = const Size(400, 400), this.imageThumbnailResizeType = 'clip', this.imageThumbnailCropType = 'center', + this.attachmentActionsModalBuilder, }); /// The [StreamMessageThemeData] to use for the image title @@ -52,6 +53,9 @@ class StreamImageAttachment extends StreamAttachmentWidget { /// Defaults to [center] final String /*center|top|bottom|left|right*/ imageThumbnailCropType; + /// {@macro attachmentActionsBuilder} + final AttachmentActionsBuilder? attachmentActionsModalBuilder; + @override Widget build(BuildContext context) { return source.when( @@ -161,6 +165,8 @@ class StreamImageAttachment extends StreamAttachmentWidget { userName: message.user!.name, onShowMessage: onShowMessage, onReplyMessage: onReplyMessage, + attachmentActionsModalBuilder: + attachmentActionsModalBuilder, ), ); }, diff --git a/packages/stream_chat_flutter/lib/src/attachment/image_group.dart b/packages/stream_chat_flutter/lib/src/attachment/image_group.dart index 6b7859fdc..5756b24ac 100644 --- a/packages/stream_chat_flutter/lib/src/attachment/image_group.dart +++ b/packages/stream_chat_flutter/lib/src/attachment/image_group.dart @@ -18,6 +18,7 @@ class StreamImageGroup extends StatelessWidget { this.imageThumbnailSize = const Size(400, 400), this.imageThumbnailResizeType = 'clip', this.imageThumbnailCropType = 'center', + this.attachmentActionsModalBuilder, }); /// List of attachments to show @@ -54,6 +55,9 @@ class StreamImageGroup extends StatelessWidget { /// Defaults to [center] final String /*center|top|bottom|left|right*/ imageThumbnailCropType; + /// {@macro attachmentActionsBuilder} + final AttachmentActionsBuilder? attachmentActionsModalBuilder; + @override Widget build(BuildContext context) { return ConstrainedBox( @@ -154,6 +158,7 @@ class StreamImageGroup extends StatelessWidget { userName: message.user!.name, onShowMessage: onShowMessage, onReplyMessage: onReplyMessage, + attachmentActionsModalBuilder: attachmentActionsModalBuilder, ), ), ), @@ -170,6 +175,7 @@ class StreamImageGroup extends StatelessWidget { imageThumbnailSize: imageThumbnailSize, imageThumbnailResizeType: imageThumbnailResizeType, imageThumbnailCropType: imageThumbnailCropType, + attachmentActionsModalBuilder: attachmentActionsModalBuilder, ); } } diff --git a/packages/stream_chat_flutter/lib/src/attachment/video_attachment.dart b/packages/stream_chat_flutter/lib/src/attachment/video_attachment.dart index b3aed834c..10efca0b8 100644 --- a/packages/stream_chat_flutter/lib/src/attachment/video_attachment.dart +++ b/packages/stream_chat_flutter/lib/src/attachment/video_attachment.dart @@ -17,6 +17,7 @@ class StreamVideoAttachment extends StreamAttachmentWidget { this.onShowMessage, this.onReplyMessage, this.onAttachmentTap, + this.attachmentActionsModalBuilder, }); /// The [StreamMessageThemeData] to use for the title @@ -31,6 +32,9 @@ class StreamVideoAttachment extends StreamAttachmentWidget { /// {@macro onAttachmentTap} final OnAttachmentTap? onAttachmentTap; + /// {@macro attachmentActionsBuilder} + final AttachmentActionsBuilder? attachmentActionsModalBuilder; + @override Widget build(BuildContext context) { return source.when( @@ -86,6 +90,8 @@ class StreamVideoAttachment extends StreamAttachmentWidget { userName: message.user!.name, onShowMessage: onShowMessage, onReplyMessage: onReplyMessage, + attachmentActionsModalBuilder: + attachmentActionsModalBuilder, ), ), ), diff --git a/packages/stream_chat_flutter/lib/src/message_widget/message_widget.dart b/packages/stream_chat_flutter/lib/src/message_widget/message_widget.dart index 0975320f6..7d51eb8be 100644 --- a/packages/stream_chat_flutter/lib/src/message_widget/message_widget.dart +++ b/packages/stream_chat_flutter/lib/src/message_widget/message_widget.dart @@ -107,6 +107,7 @@ class StreamMessageWidget extends StatefulWidget { this.imageAttachmentThumbnailSize = const Size(400, 400), this.imageAttachmentThumbnailResizeType = 'clip', this.imageAttachmentThumbnailCropType = 'center', + this.attachmentActionsModalBuilder, }) : assert( bottomRowBuilder == null || bottomRowBuilderWithDefaultWidget == null, 'You can only use one of the two bottom row builders', @@ -144,6 +145,8 @@ class StreamMessageWidget extends StatefulWidget { imageThumbnailResizeType: imageAttachmentThumbnailResizeType, imageThumbnailCropType: imageAttachmentThumbnailCropType, + attachmentActionsModalBuilder: + attachmentActionsModalBuilder, ), ), attachmentShape: border, @@ -171,6 +174,7 @@ class StreamMessageWidget extends StatefulWidget { imageThumbnailSize: imageAttachmentThumbnailSize, imageThumbnailResizeType: imageAttachmentThumbnailResizeType, imageThumbnailCropType: imageAttachmentThumbnailCropType, + attachmentActionsModalBuilder: attachmentActionsModalBuilder, ), attachmentShape: border, ); @@ -204,6 +208,8 @@ class StreamMessageWidget extends StatefulWidget { onAttachmentTap(message, attachment); } : null, + attachmentActionsModalBuilder: + attachmentActionsModalBuilder, ); }).toList(), ), @@ -533,6 +539,9 @@ class StreamMessageWidget extends StatefulWidget { /// {@macro onMessageWidgetAttachmentTap} final OnMessageWidgetAttachmentTap? onAttachmentTap; + /// {@macro attachmentActionsBuilder} + final AttachmentActionsBuilder? attachmentActionsModalBuilder; + /// Size of the image attachment thumbnail. final Size imageAttachmentThumbnailSize; @@ -617,6 +626,7 @@ class StreamMessageWidget extends StatefulWidget { Size? imageAttachmentThumbnailSize, String? imageAttachmentThumbnailResizeType, String? imageAttachmentThumbnailCropType, + AttachmentActionsBuilder? attachmentActionsModalBuilder, }) { assert( bottomRowBuilder == null || bottomRowBuilderWithDefaultWidget == null, @@ -703,6 +713,8 @@ class StreamMessageWidget extends StatefulWidget { this.imageAttachmentThumbnailResizeType, imageAttachmentThumbnailCropType: imageAttachmentThumbnailCropType ?? this.imageAttachmentThumbnailCropType, + attachmentActionsModalBuilder: + attachmentActionsModalBuilder ?? this.attachmentActionsModalBuilder, ); } From 6c4707772f492b0c370fda07db2f178f546bc062 Mon Sep 17 00:00:00 2001 From: Leandro Borges Ferreira Date: Wed, 15 Feb 2023 14:01:18 +0100 Subject: [PATCH 037/107] Update CHANGELOG.md --- packages/stream_chat_flutter/CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/stream_chat_flutter/CHANGELOG.md b/packages/stream_chat_flutter/CHANGELOG.md index 91c1eb012..51421f6d5 100644 --- a/packages/stream_chat_flutter/CHANGELOG.md +++ b/packages/stream_chat_flutter/CHANGELOG.md @@ -2,8 +2,8 @@ 🐞 Fixed -- [#1461](https://github.com/GetStream/stream-chat-flutter/pull/1461) Fixed logic for showing that a message was read unsing sending indicator. -- [#1463](https://github.com/GetStream/stream-chat-flutter/pull/1463) Fixed support for iPad in the share button for images. +- [#1456](https://github.com/GetStream/stream-chat-flutter/issues/1456) Fixed logic for showing that a message was read using sending indicator. +- [#1462](https://github.com/GetStream/stream-chat-flutter/issues/1462) Fixed support for iPad in the share button for images. ✅ Added From ffd26a4574151b3738f9b07fd50f741d2da86ab7 Mon Sep 17 00:00:00 2001 From: Leandro Borges Ferreira Date: Wed, 15 Feb 2023 14:27:21 +0100 Subject: [PATCH 038/107] Removing message builder --- .../stream_channel_list_tile.dart | 72 +++++++++---------- 1 file changed, 33 insertions(+), 39 deletions(-) diff --git a/packages/stream_chat_flutter/lib/src/scroll_view/channel_scroll_view/stream_channel_list_tile.dart b/packages/stream_chat_flutter/lib/src/scroll_view/channel_scroll_view/stream_channel_list_tile.dart index a17a2eaf6..a89b1a29a 100644 --- a/packages/stream_chat_flutter/lib/src/scroll_view/channel_scroll_view/stream_channel_list_tile.dart +++ b/packages/stream_chat_flutter/lib/src/scroll_view/channel_scroll_view/stream_channel_list_tile.dart @@ -211,45 +211,39 @@ class StreamChannelListTile extends StatelessWidget { child: subtitle, ), ), - BetterStreamBuilder>( - stream: channelState.messagesStream, - initialData: channelState.messages, - comparator: const ListEquality().equals, - builder: (context, messages) { - return BetterStreamBuilder>( - stream: channelState.readStream, - initialData: channelState.read, - builder: (context, reads) { - final lastMessage = messages.lastWhereOrNull( - (m) => !m.shadowed && !m.isDeleted, - ); - - if (lastMessage == null || - (lastMessage.user?.id != currentUser.id)) { - return const Offstage(); - } - - final isLastMessageRead = channelState.read - .where( - (readData) => readData.user.id != currentUser.id, - ) - .any((readData) => - readData.lastRead - .isAfter(lastMessage.createdAt) || - readData.lastRead - .isAtSameMomentAs(lastMessage.createdAt)); - - return Padding( - padding: const EdgeInsets.only(right: 4), - child: sendingIndicatorBuilder?.call( - context, lastMessage) ?? - StreamSendingIndicator( - message: lastMessage, - size: channelPreviewTheme.indicatorIconSize, - isMessageRead: isLastMessageRead, - ), - ); - }, + BetterStreamBuilder>( + stream: channelState.readStream, + initialData: channelState.read, + builder: (context, reads) { + final lastMessage = channelState.messages.lastWhereOrNull( + (m) => !m.shadowed && !m.isDeleted, + ); + + if (lastMessage == null || + (lastMessage.user?.id != currentUser.id)) { + return const Offstage(); + } + + final isLastMessageRead = channelState.read + .where( + (readData) => readData.user.id != currentUser.id, + ) + .any((readData) => + readData.lastRead.isAfter(lastMessage.createdAt) || + readData.lastRead + .isAtSameMomentAs(lastMessage.createdAt)); + + return Padding( + padding: const EdgeInsets.only(right: 4), + child: sendingIndicatorBuilder?.call( + context, + lastMessage, + ) ?? + StreamSendingIndicator( + message: lastMessage, + size: channelPreviewTheme.indicatorIconSize, + isMessageRead: isLastMessageRead, + ), ); }, ), From 8405d8a91906e3eeb23cf78b512ef36369417801 Mon Sep 17 00:00:00 2001 From: Leandro Borges Ferreira Date: Wed, 15 Feb 2023 17:04:50 +0100 Subject: [PATCH 039/107] Using SendingIndicatorWrapper instead of StreamSendingIndicator directly --- .../lib/src/channel/channel_preview.dart | 30 ++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/packages/stream_chat_flutter/lib/src/channel/channel_preview.dart b/packages/stream_chat_flutter/lib/src/channel/channel_preview.dart index 94c118c8b..7bca52491 100644 --- a/packages/stream_chat_flutter/lib/src/channel/channel_preview.dart +++ b/packages/stream_chat_flutter/lib/src/channel/channel_preview.dart @@ -6,6 +6,7 @@ import 'package:contextmenu/contextmenu.dart'; import 'package:flutter/material.dart'; import 'package:stream_chat_flutter/src/context_menu_items/stream_chat_context_menu_item.dart'; import 'package:stream_chat_flutter/src/dialogs/dialogs.dart'; +import 'package:stream_chat_flutter/src/message_widget/sending_indicator_wrapper.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; /// {@template channelPreview} @@ -76,6 +77,7 @@ class ChannelPreview extends StatelessWidget { Widget build(BuildContext context) { final channelPreviewTheme = StreamChannelPreviewTheme.of(context); final streamChatState = StreamChat.of(context); + final streamChatTheme = StreamChatTheme.of(context); return BetterStreamBuilder( stream: channel.isMutedStream, initialData: channel.isMuted, @@ -292,20 +294,20 @@ class ChannelPreview extends StatelessWidget { stream: channel.state?.readStream, initialData: channel.state?.read, builder: (context, data) { - final readList = data.where((it) => - it.user.id != - channel.client.state.currentUser?.id && - (it.lastRead - .isAfter(lastMessage!.createdAt) || - it.lastRead.isAtSameMomentAs( - lastMessage.createdAt, - ))); - final isMessageRead = readList.length >= - (channel.memberCount ?? 0) - 1; - return StreamSendingIndicator( - message: lastMessage!, - size: channelPreviewTheme.indicatorIconSize, - isMessageRead: isMessageRead, + + final hasNonUrlAttachments = lastMessage! + .attachments + .where((it) => + it.titleLink == null || + it.type == 'giphy') + .isNotEmpty; + + return SendingIndicatorWrapper( + messageTheme: streamChatTheme.ownMessageTheme, + message: lastMessage, + hasNonUrlAttachments: hasNonUrlAttachments, + streamChat: streamChatState, + streamChatTheme: streamChatTheme, ); }, ), From 6d97b8ac76942e49e9dff2e949f653704a9eb6b1 Mon Sep 17 00:00:00 2001 From: Leandro Borges Ferreira Date: Wed, 15 Feb 2023 17:10:14 +0100 Subject: [PATCH 040/107] Using Builder of messages instead of Read --- .../stream_channel_list_tile.dart | 27 +++++++++---------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/packages/stream_chat_flutter/lib/src/scroll_view/channel_scroll_view/stream_channel_list_tile.dart b/packages/stream_chat_flutter/lib/src/scroll_view/channel_scroll_view/stream_channel_list_tile.dart index a89b1a29a..999ce91a3 100644 --- a/packages/stream_chat_flutter/lib/src/scroll_view/channel_scroll_view/stream_channel_list_tile.dart +++ b/packages/stream_chat_flutter/lib/src/scroll_view/channel_scroll_view/stream_channel_list_tile.dart @@ -211,11 +211,12 @@ class StreamChannelListTile extends StatelessWidget { child: subtitle, ), ), - BetterStreamBuilder>( - stream: channelState.readStream, - initialData: channelState.read, - builder: (context, reads) { - final lastMessage = channelState.messages.lastWhereOrNull( + BetterStreamBuilder>( + stream: channelState.messagesStream, + initialData: channelState.messages, + comparator: const ListEquality().equals, + builder: (context, messages) { + final lastMessage = messages.lastWhereOrNull( (m) => !m.shadowed && !m.isDeleted, ); @@ -235,15 +236,13 @@ class StreamChannelListTile extends StatelessWidget { return Padding( padding: const EdgeInsets.only(right: 4), - child: sendingIndicatorBuilder?.call( - context, - lastMessage, - ) ?? - StreamSendingIndicator( - message: lastMessage, - size: channelPreviewTheme.indicatorIconSize, - isMessageRead: isLastMessageRead, - ), + child: + sendingIndicatorBuilder?.call(context, lastMessage) ?? + StreamSendingIndicator( + message: lastMessage, + size: channelPreviewTheme.indicatorIconSize, + isMessageRead: isLastMessageRead, + ), ); }, ), From 06542da156ae4b7ae49135399e0df9ad2526025a Mon Sep 17 00:00:00 2001 From: Leandro Borges Ferreira Date: Wed, 15 Feb 2023 17:33:23 +0100 Subject: [PATCH 041/107] Using only SendingIndicatorBuilder (rename from SendingIndicatorWrapper) --- .../lib/src/channel/channel_preview.dart | 3 ++- .../lib/src/message_widget/bottom_row.dart | 2 +- .../sending_indicator_wrapper.dart | 16 +++++++++------- .../stream_channel_list_tile.dart | 16 +++++++++++++--- 4 files changed, 25 insertions(+), 12 deletions(-) diff --git a/packages/stream_chat_flutter/lib/src/channel/channel_preview.dart b/packages/stream_chat_flutter/lib/src/channel/channel_preview.dart index 7bca52491..ded6f5587 100644 --- a/packages/stream_chat_flutter/lib/src/channel/channel_preview.dart +++ b/packages/stream_chat_flutter/lib/src/channel/channel_preview.dart @@ -302,12 +302,13 @@ class ChannelPreview extends StatelessWidget { it.type == 'giphy') .isNotEmpty; - return SendingIndicatorWrapper( + return SendingIndicatorBuilder( messageTheme: streamChatTheme.ownMessageTheme, message: lastMessage, hasNonUrlAttachments: hasNonUrlAttachments, streamChat: streamChatState, streamChatTheme: streamChatTheme, + channel: channel, ); }, ), diff --git a/packages/stream_chat_flutter/lib/src/message_widget/bottom_row.dart b/packages/stream_chat_flutter/lib/src/message_widget/bottom_row.dart index 5b1b14663..579dc65db 100644 --- a/packages/stream_chat_flutter/lib/src/message_widget/bottom_row.dart +++ b/packages/stream_chat_flutter/lib/src/message_widget/bottom_row.dart @@ -204,7 +204,7 @@ class BottomRow extends StatelessWidget { if (showSendingIndicator) WidgetSpan( child: sendingIndicatorBuilder?.call(context, message) ?? - SendingIndicatorWrapper( + SendingIndicatorBuilder( messageTheme: messageTheme, message: message, hasNonUrlAttachments: hasNonUrlAttachments, diff --git a/packages/stream_chat_flutter/lib/src/message_widget/sending_indicator_wrapper.dart b/packages/stream_chat_flutter/lib/src/message_widget/sending_indicator_wrapper.dart index 1e2e31c65..02ebe5ff1 100644 --- a/packages/stream_chat_flutter/lib/src/message_widget/sending_indicator_wrapper.dart +++ b/packages/stream_chat_flutter/lib/src/message_widget/sending_indicator_wrapper.dart @@ -6,15 +6,16 @@ import 'package:stream_chat_flutter/stream_chat_flutter.dart'; /// /// Used in [BottomRow]. Should not be used elsewhere. /// {@endtemplate} -class SendingIndicatorWrapper extends StatelessWidget { +class SendingIndicatorBuilder extends StatelessWidget { /// {@macro sendingIndicatorWrapper} - const SendingIndicatorWrapper({ + const SendingIndicatorBuilder({ super.key, required this.messageTheme, required this.message, required this.hasNonUrlAttachments, required this.streamChat, required this.streamChatTheme, + this.channel, }); /// {@macro messageTheme} @@ -32,10 +33,13 @@ class SendingIndicatorWrapper extends StatelessWidget { /// {@macro streamChatThemeData} final StreamChatThemeData streamChatTheme; + final Channel? channel; + @override Widget build(BuildContext context) { final style = messageTheme.createdAtStyle; - final memberCount = StreamChannel.of(context).channel.memberCount ?? 0; + final thisChannel = channel ?? StreamChannel.of(context).channel; + final memberCount = thisChannel.memberCount ?? 0; if (hasNonUrlAttachments && (message.status == MessageSendingStatus.sending || @@ -58,11 +62,9 @@ class SendingIndicatorWrapper extends StatelessWidget { ); } - final channel = StreamChannel.of(context).channel; - return BetterStreamBuilder>( - stream: channel.state?.readStream, - initialData: channel.state?.read, + stream: thisChannel.state?.readStream, + initialData: thisChannel.state?.read, builder: (context, data) { final readList = data.where((it) => it.user.id != streamChat.currentUser?.id && diff --git a/packages/stream_chat_flutter/lib/src/scroll_view/channel_scroll_view/stream_channel_list_tile.dart b/packages/stream_chat_flutter/lib/src/scroll_view/channel_scroll_view/stream_channel_list_tile.dart index 999ce91a3..08eb9e3b4 100644 --- a/packages/stream_chat_flutter/lib/src/scroll_view/channel_scroll_view/stream_channel_list_tile.dart +++ b/packages/stream_chat_flutter/lib/src/scroll_view/channel_scroll_view/stream_channel_list_tile.dart @@ -1,5 +1,6 @@ import 'package:collection/collection.dart'; import 'package:flutter/material.dart'; +import 'package:stream_chat_flutter/src/message_widget/sending_indicator_wrapper.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; /// A widget that displays a channel preview. @@ -145,6 +146,8 @@ class StreamChannelListTile extends StatelessWidget { final currentUser = channel.client.state.currentUser!; final channelPreviewTheme = StreamChannelPreviewTheme.of(context); + final streamChatTheme = StreamChatTheme.of(context); + final streamChat = StreamChat.of(context); final leading = this.leading ?? StreamChannelAvatar( @@ -234,14 +237,21 @@ class StreamChannelListTile extends StatelessWidget { readData.lastRead .isAtSameMomentAs(lastMessage.createdAt)); + final hasNonUrlAttachments = lastMessage.attachments + .where((it) => it.titleLink == null || it.type == 'giphy') + .isNotEmpty; + return Padding( padding: const EdgeInsets.only(right: 4), child: sendingIndicatorBuilder?.call(context, lastMessage) ?? - StreamSendingIndicator( + SendingIndicatorBuilder( + messageTheme: streamChatTheme.ownMessageTheme, message: lastMessage, - size: channelPreviewTheme.indicatorIconSize, - isMessageRead: isLastMessageRead, + hasNonUrlAttachments: hasNonUrlAttachments, + streamChat: streamChat, + streamChatTheme: streamChatTheme, + channel: channel, ), ); }, From 88572e3df3aaf84d7c783d332dc613fade2f4378 Mon Sep 17 00:00:00 2001 From: Leandro Borges Ferreira Date: Wed, 15 Feb 2023 17:37:15 +0100 Subject: [PATCH 042/107] Removing empty line --- .../stream_chat_flutter/lib/src/channel/channel_preview.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/stream_chat_flutter/lib/src/channel/channel_preview.dart b/packages/stream_chat_flutter/lib/src/channel/channel_preview.dart index ded6f5587..2626ad19e 100644 --- a/packages/stream_chat_flutter/lib/src/channel/channel_preview.dart +++ b/packages/stream_chat_flutter/lib/src/channel/channel_preview.dart @@ -294,7 +294,6 @@ class ChannelPreview extends StatelessWidget { stream: channel.state?.readStream, initialData: channel.state?.read, builder: (context, data) { - final hasNonUrlAttachments = lastMessage! .attachments .where((it) => From 23190d5b06fa46843451303f3154dacebf12851b Mon Sep 17 00:00:00 2001 From: Leandro Borges Ferreira Date: Wed, 15 Feb 2023 18:38:57 +0100 Subject: [PATCH 043/107] Docs --- .../lib/src/message_widget/sending_indicator_wrapper.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/stream_chat_flutter/lib/src/message_widget/sending_indicator_wrapper.dart b/packages/stream_chat_flutter/lib/src/message_widget/sending_indicator_wrapper.dart index 02ebe5ff1..9b0b2819c 100644 --- a/packages/stream_chat_flutter/lib/src/message_widget/sending_indicator_wrapper.dart +++ b/packages/stream_chat_flutter/lib/src/message_widget/sending_indicator_wrapper.dart @@ -33,6 +33,7 @@ class SendingIndicatorBuilder extends StatelessWidget { /// {@macro streamChatThemeData} final StreamChatThemeData streamChatTheme; + /// {@macro channel} final Channel? channel; @override From 9cafabc023ca1151406caf2814fd117f4e41f977 Mon Sep 17 00:00:00 2001 From: Leandro Borges Ferreira Date: Wed, 15 Feb 2023 18:39:11 +0100 Subject: [PATCH 044/107] Removing unused code --- .../channel_scroll_view/stream_channel_list_tile.dart | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/packages/stream_chat_flutter/lib/src/scroll_view/channel_scroll_view/stream_channel_list_tile.dart b/packages/stream_chat_flutter/lib/src/scroll_view/channel_scroll_view/stream_channel_list_tile.dart index 08eb9e3b4..fca7cf841 100644 --- a/packages/stream_chat_flutter/lib/src/scroll_view/channel_scroll_view/stream_channel_list_tile.dart +++ b/packages/stream_chat_flutter/lib/src/scroll_view/channel_scroll_view/stream_channel_list_tile.dart @@ -227,16 +227,7 @@ class StreamChannelListTile extends StatelessWidget { (lastMessage.user?.id != currentUser.id)) { return const Offstage(); } - - final isLastMessageRead = channelState.read - .where( - (readData) => readData.user.id != currentUser.id, - ) - .any((readData) => - readData.lastRead.isAfter(lastMessage.createdAt) || - readData.lastRead - .isAtSameMomentAs(lastMessage.createdAt)); - + final hasNonUrlAttachments = lastMessage.attachments .where((it) => it.titleLink == null || it.type == 'giphy') .isNotEmpty; From b9f150ae407e743dfe6dfbe867ced608c56e19f2 Mon Sep 17 00:00:00 2001 From: Leandro Borges Ferreira Date: Wed, 15 Feb 2023 19:26:00 +0100 Subject: [PATCH 045/107] Removing empty line --- .../channel_scroll_view/stream_channel_list_tile.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/stream_chat_flutter/lib/src/scroll_view/channel_scroll_view/stream_channel_list_tile.dart b/packages/stream_chat_flutter/lib/src/scroll_view/channel_scroll_view/stream_channel_list_tile.dart index fca7cf841..bf116bd81 100644 --- a/packages/stream_chat_flutter/lib/src/scroll_view/channel_scroll_view/stream_channel_list_tile.dart +++ b/packages/stream_chat_flutter/lib/src/scroll_view/channel_scroll_view/stream_channel_list_tile.dart @@ -227,7 +227,7 @@ class StreamChannelListTile extends StatelessWidget { (lastMessage.user?.id != currentUser.id)) { return const Offstage(); } - + final hasNonUrlAttachments = lastMessage.attachments .where((it) => it.titleLink == null || it.type == 'giphy') .isNotEmpty; From 87e07683df6a2df353c8834a8866395144cb6f78 Mon Sep 17 00:00:00 2001 From: Leandro Borges Ferreira Date: Tue, 7 Feb 2023 18:58:26 +0100 Subject: [PATCH 046/107] Fixing for multiline messages --- .../message_actions_modal.dart | 26 ++++++++--------- .../reactions/message_reactions_modal.dart | 16 ++-------- .../lib/src/utils/extensions.dart | 29 +++++++++++++++++++ 3 files changed, 44 insertions(+), 27 deletions(-) diff --git a/packages/stream_chat_flutter/lib/src/message_actions_modal/message_actions_modal.dart b/packages/stream_chat_flutter/lib/src/message_actions_modal/message_actions_modal.dart index 8a5d4740c..a8aec217d 100644 --- a/packages/stream_chat_flutter/lib/src/message_actions_modal/message_actions_modal.dart +++ b/packages/stream_chat_flutter/lib/src/message_actions_modal/message_actions_modal.dart @@ -101,20 +101,10 @@ class _MessageActionsModalState extends State { final user = StreamChat.of(context).currentUser; final roughMaxSize = size.width * 2 / 3; - var messageTextLength = widget.message.text!.length; - if (widget.message.quotedMessage != null) { - var quotedMessageLength = - (widget.message.quotedMessage!.text?.length ?? 0) + 40; - if (widget.message.quotedMessage!.attachments.isNotEmpty) { - quotedMessageLength += 40; - } - if (quotedMessageLength > messageTextLength) { - messageTextLength = quotedMessageLength; - } - } - final roughSentenceSize = messageTextLength * - (widget.messageTheme.messageTextStyle?.fontSize ?? 1) * - 1.2; + + final roughSentenceSize = widget.message + .roughMessageSize(widget.messageTheme.messageTextStyle?.fontSize); + final divFactor = widget.message.attachments.isNotEmpty ? 1 : (roughSentenceSize == 0 ? 1 : (roughSentenceSize / roughMaxSize)); @@ -289,6 +279,12 @@ class _MessageActionsModalState extends State { ) { var result = 0.0; var cont = true; + + print('INFO - max width: ${constraints.maxWidth}. ' + 'shiftFactor: $shiftFactor ' + 'divFactor: $divFactor ' + 'cont: $cont'); + if (user?.id == widget.message.user?.id) { if (divFactor >= 1.0) { // This calculation is hacky and does not cover all bases!!! @@ -358,6 +354,8 @@ class _MessageActionsModalState extends State { } } + print('INFO - result: $result'); + // Ensure reactions don't get pushed past the edge of the screen. // // Hacky!!! Needs improvement!!! diff --git a/packages/stream_chat_flutter/lib/src/message_widget/reactions/message_reactions_modal.dart b/packages/stream_chat_flutter/lib/src/message_widget/reactions/message_reactions_modal.dart index 281a37ccd..e87a89709 100644 --- a/packages/stream_chat_flutter/lib/src/message_widget/reactions/message_reactions_modal.dart +++ b/packages/stream_chat_flutter/lib/src/message_widget/reactions/message_reactions_modal.dart @@ -47,19 +47,9 @@ class StreamMessageReactionsModal extends StatelessWidget { _userPermissions.contains(PermissionType.sendReaction); final roughMaxSize = size.width * 2 / 3; - var messageTextLength = message.text!.length; - if (message.quotedMessage != null) { - var quotedMessageLength = message.quotedMessage!.text!.length + 40; - if (message.quotedMessage!.attachments.isNotEmpty) { - quotedMessageLength += 40; - } - if (quotedMessageLength > messageTextLength) { - messageTextLength = quotedMessageLength; - } - } - final roughSentenceSize = messageTextLength * - (messageTheme.messageTextStyle?.fontSize ?? 1) * - 1.2; + + final roughSentenceSize = + message.roughMessageSize(messageTheme.messageTextStyle?.fontSize); final divFactor = message.attachments.isNotEmpty ? 1 : (roughSentenceSize == 0 ? 1 : (roughSentenceSize / roughMaxSize)); diff --git a/packages/stream_chat_flutter/lib/src/utils/extensions.dart b/packages/stream_chat_flutter/lib/src/utils/extensions.dart index 448674dd4..8e6ef86ef 100644 --- a/packages/stream_chat_flutter/lib/src/utils/extensions.dart +++ b/packages/stream_chat_flutter/lib/src/utils/extensions.dart @@ -1,3 +1,4 @@ +import 'package:collection/collection.dart'; import 'package:diacritic/diacritic.dart'; import 'package:file_picker/file_picker.dart'; import 'package:flutter/foundation.dart'; @@ -12,6 +13,16 @@ extension StringExtension on String { String capitalize() => isNotEmpty ? '${this[0].toUpperCase()}${substring(1).toLowerCase()}' : ''; + /// Returns the biggest line of a text. + String biggestLine() { + if (contains('\n')) { + return split('\n') + .reduce((curr, next) => curr.length > next.length ? curr : next); + } else { + return this; + } + } + /// Returns whether the string contains only emoji's or not. /// /// Emojis guidelines @@ -353,6 +364,24 @@ extension MessageX on Message { return copyWith(text: messageTextToRender); } + /// Returns an approximation of message size + double roughMessageSize(double? fontSize) { + var messageTextLength = text!.biggestLine().length; + + if (quotedMessage != null) { + var quotedMessageLength = + (quotedMessage!.text?.biggestLine().length ?? 0) + 40; + if (quotedMessage!.attachments.isNotEmpty) { + quotedMessageLength += 40; + } + if (quotedMessageLength > messageTextLength) { + messageTextLength = quotedMessageLength; + } + } + + return messageTextLength * (fontSize ?? 1) * 1.2; + } + /// It returns the message with the translated text if available locally Message translate(String language) => copyWith(text: i18n?['${language}_text'] ?? text); From 858b6afddb8245f3e54875b0219cef2d150c76d8 Mon Sep 17 00:00:00 2001 From: Leandro Borges Ferreira Date: Tue, 7 Feb 2023 19:42:55 +0100 Subject: [PATCH 047/107] Fixing quoted messages --- packages/stream_chat_flutter/lib/src/utils/extensions.dart | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/stream_chat_flutter/lib/src/utils/extensions.dart b/packages/stream_chat_flutter/lib/src/utils/extensions.dart index 8e6ef86ef..b094fb600 100644 --- a/packages/stream_chat_flutter/lib/src/utils/extensions.dart +++ b/packages/stream_chat_flutter/lib/src/utils/extensions.dart @@ -370,7 +370,8 @@ extension MessageX on Message { if (quotedMessage != null) { var quotedMessageLength = - (quotedMessage!.text?.biggestLine().length ?? 0) + 40; + (quotedMessage!.text?.biggestLine().length ?? 0) + 6; + if (quotedMessage!.attachments.isNotEmpty) { quotedMessageLength += 40; } From 92a330cd71b16da277feb9985c33ba6963e62bed Mon Sep 17 00:00:00 2001 From: Leandro Borges Ferreira Date: Tue, 7 Feb 2023 19:43:54 +0100 Subject: [PATCH 048/107] Using constant instead of many size divisions --- .../message_actions_modal.dart | 79 +++++-------------- .../lib/src/utils/extensions.dart | 2 +- 2 files changed, 20 insertions(+), 61 deletions(-) diff --git a/packages/stream_chat_flutter/lib/src/message_actions_modal/message_actions_modal.dart b/packages/stream_chat_flutter/lib/src/message_actions_modal/message_actions_modal.dart index a8aec217d..da405247f 100644 --- a/packages/stream_chat_flutter/lib/src/message_actions_modal/message_actions_modal.dart +++ b/packages/stream_chat_flutter/lib/src/message_actions_modal/message_actions_modal.dart @@ -105,6 +105,8 @@ class _MessageActionsModalState extends State { final roughSentenceSize = widget.message .roughMessageSize(widget.messageTheme.messageTextStyle?.fontSize); + print('roughSentenceSize $roughSentenceSize'); + final divFactor = widget.message.attachments.isNotEmpty ? 1 : (roughSentenceSize == 0 ? 1 : (roughSentenceSize / roughMaxSize)); @@ -278,70 +280,27 @@ class _MessageActionsModalState extends State { BoxConstraints constraints, ) { var result = 0.0; - var cont = true; - print('INFO - max width: ${constraints.maxWidth}. ' + final maxWidth = constraints.maxWidth; + + print('INFO - max width: ${maxWidth}. ' 'shiftFactor: $shiftFactor ' - 'divFactor: $divFactor ' - 'cont: $cont'); + 'divFactor: $divFactor'); if (user?.id == widget.message.user?.id) { if (divFactor >= 1.0) { - // This calculation is hacky and does not cover all bases!!! - // A better option is needed! - - // Landscape calculations - if (constraints.maxWidth == 1350) { - // 12.7 iPad Pro - result = shiftFactor + 0.5; - cont = false; - } else if (constraints.maxWidth == 1178) { - // 11 inch iPad Pro - result = shiftFactor + 0.42; - cont = false; - } else if (constraints.maxWidth == 1164) { - // iPad Air 4 - result = shiftFactor + 0.4; - cont = false; - } else if (constraints.maxWidth == 1117) { - // iPad Mini 6 - result = shiftFactor + 0.37; - cont = false; - } else if (constraints.maxWidth == 1064) { - // iPad 9th gen - result = shiftFactor + 0.33; - cont = false; - } else if (constraints.maxWidth == 1008) { - // 9.7 inch iPad Pro - result = shiftFactor + 0.3; - cont = false; - } else if (constraints.maxWidth >= 200 && constraints.maxWidth <= 400) { - // Phone (?) - result = shiftFactor - 0.2; - cont = false; - } - - if (cont) { - // Portrait calculations - if (constraints.maxWidth == 1008) { - // 12.7 iPad Pro - result = shiftFactor + 0.3; - } else if (constraints.maxWidth == 818) { - // 11 inch iPad Pro - result = shiftFactor + 0.07; - } else if (constraints.maxWidth == 804) { - // iPad Air 4 - result = shiftFactor + 0.04; - } else if (constraints.maxWidth == 794) { - // iPad 9th gen - result = shiftFactor + 0.02; - } else if (constraints.maxWidth >= 752) { - // 9.7 inch iPad Pro - result = shiftFactor - 0.05; - } else if (constraints.maxWidth == 728) { - // iPad Mini 6 - result = shiftFactor - 0.1; - } + /* + This is an empiric value. This number tries to approximate all the + offset necessary for the position of reaction look the best way + possible. + */ + const offsetConstant = 2700; + final offsetCorrection = maxWidth / offsetConstant; + + if (maxWidth <= 752) { + result = shiftFactor - offsetCorrection; + } else { + result = shiftFactor + offsetCorrection; } } else { result = 1.2 - divFactor; @@ -359,7 +318,7 @@ class _MessageActionsModalState extends State { // Ensure reactions don't get pushed past the edge of the screen. // // Hacky!!! Needs improvement!!! - if (result > 1) { + if (result > 1.0) { return 1; } else { return result; diff --git a/packages/stream_chat_flutter/lib/src/utils/extensions.dart b/packages/stream_chat_flutter/lib/src/utils/extensions.dart index b094fb600..4e2da3838 100644 --- a/packages/stream_chat_flutter/lib/src/utils/extensions.dart +++ b/packages/stream_chat_flutter/lib/src/utils/extensions.dart @@ -371,7 +371,7 @@ extension MessageX on Message { if (quotedMessage != null) { var quotedMessageLength = (quotedMessage!.text?.biggestLine().length ?? 0) + 6; - + if (quotedMessage!.attachments.isNotEmpty) { quotedMessageLength += 40; } From 9fdc864af29996963ff0375b7168b2be27c099e9 Mon Sep 17 00:00:00 2001 From: Leandro Borges Ferreira Date: Tue, 7 Feb 2023 19:58:50 +0100 Subject: [PATCH 049/107] Adding negativeConstant --- .../message_actions_modal/message_actions_modal.dart | 10 +++++----- .../reactions/message_reactions_modal.dart | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/stream_chat_flutter/lib/src/message_actions_modal/message_actions_modal.dart b/packages/stream_chat_flutter/lib/src/message_actions_modal/message_actions_modal.dart index da405247f..970f4d28c 100644 --- a/packages/stream_chat_flutter/lib/src/message_actions_modal/message_actions_modal.dart +++ b/packages/stream_chat_flutter/lib/src/message_actions_modal/message_actions_modal.dart @@ -148,7 +148,7 @@ class _MessageActionsModalState extends State { ); }, ), - const SizedBox(height: 8), + const SizedBox(height: 10), IgnorePointer( child: widget.messageWidget, ), @@ -294,13 +294,13 @@ class _MessageActionsModalState extends State { offset necessary for the position of reaction look the best way possible. */ - const offsetConstant = 2700; - final offsetCorrection = maxWidth / offsetConstant; + const positiveConstant = 2700; + const negativeConstant = 1700; if (maxWidth <= 752) { - result = shiftFactor - offsetCorrection; + result = shiftFactor - maxWidth / negativeConstant; } else { - result = shiftFactor + offsetCorrection; + result = shiftFactor + maxWidth / positiveConstant; } } else { result = 1.2 - divFactor; diff --git a/packages/stream_chat_flutter/lib/src/message_widget/reactions/message_reactions_modal.dart b/packages/stream_chat_flutter/lib/src/message_widget/reactions/message_reactions_modal.dart index e87a89709..5cc804d1e 100644 --- a/packages/stream_chat_flutter/lib/src/message_widget/reactions/message_reactions_modal.dart +++ b/packages/stream_chat_flutter/lib/src/message_widget/reactions/message_reactions_modal.dart @@ -84,7 +84,7 @@ class StreamMessageReactionsModal extends StatelessWidget { message: message, ), ), - const SizedBox(height: 8), + const SizedBox(height: 10), IgnorePointer( child: messageWidget, ), From f02d4670e8132ad9137a0e96814fe3cb08b13410 Mon Sep 17 00:00:00 2001 From: Leandro Borges Ferreira Date: Tue, 7 Feb 2023 20:43:17 +0100 Subject: [PATCH 050/107] Adding only negative shift --- .../message_actions_modal.dart | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/packages/stream_chat_flutter/lib/src/message_actions_modal/message_actions_modal.dart b/packages/stream_chat_flutter/lib/src/message_actions_modal/message_actions_modal.dart index 970f4d28c..3e1260d58 100644 --- a/packages/stream_chat_flutter/lib/src/message_actions_modal/message_actions_modal.dart +++ b/packages/stream_chat_flutter/lib/src/message_actions_modal/message_actions_modal.dart @@ -106,6 +106,7 @@ class _MessageActionsModalState extends State { .roughMessageSize(widget.messageTheme.messageTextStyle?.fontSize); print('roughSentenceSize $roughSentenceSize'); + print('roughMaxSize $roughMaxSize'); final divFactor = widget.message.attachments.isNotEmpty ? 1 @@ -282,8 +283,10 @@ class _MessageActionsModalState extends State { var result = 0.0; final maxWidth = constraints.maxWidth; + final maxHeight = constraints.maxHeight; - print('INFO - max width: ${maxWidth}. ' + print('INFO - max width: $maxWidth. ' + 'maxHeight: $maxHeight ' 'shiftFactor: $shiftFactor ' 'divFactor: $divFactor'); @@ -294,15 +297,11 @@ class _MessageActionsModalState extends State { offset necessary for the position of reaction look the best way possible. */ - const positiveConstant = 2700; - const negativeConstant = 1700; + const constant = 1500; - if (maxWidth <= 752) { - result = shiftFactor - maxWidth / negativeConstant; - } else { - result = shiftFactor + maxWidth / positiveConstant; - } + result = shiftFactor - maxWidth / constant; } else { + // Small messages, it is simpler to align then. result = 1.2 - divFactor; } } else { From 40b27eca21b6355d82e2d1c28b4c49e3db909a05 Mon Sep 17 00:00:00 2001 From: Leandro Borges Ferreira Date: Tue, 7 Feb 2023 20:46:12 +0100 Subject: [PATCH 051/107] Update CHANGELOG.md --- packages/stream_chat_flutter/CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/stream_chat_flutter/CHANGELOG.md b/packages/stream_chat_flutter/CHANGELOG.md index 405f49f02..92964fedc 100644 --- a/packages/stream_chat_flutter/CHANGELOG.md +++ b/packages/stream_chat_flutter/CHANGELOG.md @@ -12,6 +12,10 @@ - Updated `share_plus` dependency to `^6.3.0` +🚀 Improved +- +- Improved draw of reaction options. [#1455](https://github.com/GetStream/stream-chat-flutter/pull/1455) + ## 5.3.0 🔄 Changed From 64df124e37c78758d500031ff1af01f255ae9861 Mon Sep 17 00:00:00 2001 From: Leandro Borges Ferreira Date: Wed, 8 Feb 2023 12:05:47 +0100 Subject: [PATCH 052/107] Extracting reactions align --- .../message_actions_modal.dart | 54 ++----------------- .../reactions/reactions_align.dart | 54 +++++++++++++++++++ 2 files changed, 57 insertions(+), 51 deletions(-) create mode 100644 packages/stream_chat_flutter/lib/src/message_widget/reactions/reactions_align.dart diff --git a/packages/stream_chat_flutter/lib/src/message_actions_modal/message_actions_modal.dart b/packages/stream_chat_flutter/lib/src/message_actions_modal/message_actions_modal.dart index 3e1260d58..18a49c952 100644 --- a/packages/stream_chat_flutter/lib/src/message_actions_modal/message_actions_modal.dart +++ b/packages/stream_chat_flutter/lib/src/message_actions_modal/message_actions_modal.dart @@ -2,6 +2,7 @@ import 'dart:ui'; import 'package:flutter/material.dart' hide ButtonStyle; import 'package:stream_chat_flutter/src/message_actions_modal/mam_widgets.dart'; +import 'package:stream_chat_flutter/src/message_widget/reactions/reactions_align.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; /// {@template messageActionsModal} @@ -135,8 +136,9 @@ class _MessageActionsModalState extends State { builder: (context, constraints) { return Align( alignment: Alignment( - _calculateReactionsHorizontalAlignmentValue( + calculateReactionsHorizontalAlignmentValue( user, + widget.message, divFactor, shiftFactor, constraints, @@ -274,56 +276,6 @@ class _MessageActionsModalState extends State { ); } - double _calculateReactionsHorizontalAlignmentValue( - User? user, - num divFactor, - double shiftFactor, - BoxConstraints constraints, - ) { - var result = 0.0; - - final maxWidth = constraints.maxWidth; - final maxHeight = constraints.maxHeight; - - print('INFO - max width: $maxWidth. ' - 'maxHeight: $maxHeight ' - 'shiftFactor: $shiftFactor ' - 'divFactor: $divFactor'); - - if (user?.id == widget.message.user?.id) { - if (divFactor >= 1.0) { - /* - This is an empiric value. This number tries to approximate all the - offset necessary for the position of reaction look the best way - possible. - */ - const constant = 1500; - - result = shiftFactor - maxWidth / constant; - } else { - // Small messages, it is simpler to align then. - result = 1.2 - divFactor; - } - } else { - if (divFactor >= 1.0) { - result = shiftFactor + 0.2; - } else { - result = -(1.2 - divFactor); - } - } - - print('INFO - result: $result'); - - // Ensure reactions don't get pushed past the edge of the screen. - // - // Hacky!!! Needs improvement!!! - if (result > 1.0) { - return 1; - } else { - return result; - } - } - InkWell _buildCustomAction( BuildContext context, StreamMessageAction messageAction, diff --git a/packages/stream_chat_flutter/lib/src/message_widget/reactions/reactions_align.dart b/packages/stream_chat_flutter/lib/src/message_widget/reactions/reactions_align.dart new file mode 100644 index 000000000..e6e81eb6c --- /dev/null +++ b/packages/stream_chat_flutter/lib/src/message_widget/reactions/reactions_align.dart @@ -0,0 +1,54 @@ +import 'package:flutter/material.dart'; +import 'package:stream_chat_flutter/stream_chat_flutter.dart'; + +/// Document here!! +double calculateReactionsHorizontalAlignmentValue( + User? user, + Message message, + num divFactor, + double shiftFactor, + BoxConstraints constraints, + ) { + var result = 0.0; + + final maxWidth = constraints.maxWidth; + final maxHeight = constraints.maxHeight; + + print('INFO - max width: $maxWidth. ' + 'maxHeight: $maxHeight ' + 'shiftFactor: $shiftFactor ' + 'divFactor: $divFactor'); + + if (user?.id == message.user?.id) { + if (divFactor >= 1.0) { + /* + This is an empiric value. This number tries to approximate all the + offset necessary for the position of reaction look the best way + possible. + */ + const constant = 1300; + + result = shiftFactor - maxWidth / constant; + } else { + // Small messages, it is simpler to align then. + result = 1.2 - divFactor; + } + } else { + if (divFactor >= 1.0) { + result = shiftFactor + 0.2; + } else { + result = -(1.2 - divFactor); + } + } + + print('INFO - result: $result'); + + // Ensure reactions don't get pushed past the edge of the screen. + // + // Hacky!!! Needs improvement!!! + if (result > 1.0) { + return 1; + } else { + return result; + } +} From c0936f87ab6f1bb0dabc4d6175cc0378f5d1b3a9 Mon Sep 17 00:00:00 2001 From: Leandro Borges Ferreira Date: Wed, 8 Feb 2023 12:50:11 +0100 Subject: [PATCH 053/107] Using the same logic for alignment --- .../message_actions_modal.dart | 14 +++--- .../reactions/message_reactions_modal.dart | 45 +++++++++---------- .../reactions/reactions_align.dart | 22 ++++++--- 3 files changed, 43 insertions(+), 38 deletions(-) diff --git a/packages/stream_chat_flutter/lib/src/message_actions_modal/message_actions_modal.dart b/packages/stream_chat_flutter/lib/src/message_actions_modal/message_actions_modal.dart index 18a49c952..0ca7ac163 100644 --- a/packages/stream_chat_flutter/lib/src/message_actions_modal/message_actions_modal.dart +++ b/packages/stream_chat_flutter/lib/src/message_actions_modal/message_actions_modal.dart @@ -106,19 +106,16 @@ class _MessageActionsModalState extends State { final roughSentenceSize = widget.message .roughMessageSize(widget.messageTheme.messageTextStyle?.fontSize); + final fontSize = widget.messageTheme.messageTextStyle?.fontSize; + print('roughSentenceSize $roughSentenceSize'); print('roughMaxSize $roughMaxSize'); - final divFactor = widget.message.attachments.isNotEmpty - ? 1 - : (roughSentenceSize == 0 ? 1 : (roughSentenceSize / roughMaxSize)); - final streamChatThemeData = StreamChatTheme.of(context); final numberOfReactions = StreamChatConfiguration.of(context).reactionIcons.length; - final shiftFactor = - numberOfReactions < 5 ? (5 - numberOfReactions) * 0.1 : 0.0; + final channel = StreamChannel.of(context).channel; final child = Center( @@ -139,9 +136,10 @@ class _MessageActionsModalState extends State { calculateReactionsHorizontalAlignmentValue( user, widget.message, - divFactor, - shiftFactor, constraints, + roughMaxSize, + fontSize, + numberOfReactions, ), 0, ), diff --git a/packages/stream_chat_flutter/lib/src/message_widget/reactions/message_reactions_modal.dart b/packages/stream_chat_flutter/lib/src/message_widget/reactions/message_reactions_modal.dart index 5cc804d1e..813c3d256 100644 --- a/packages/stream_chat_flutter/lib/src/message_widget/reactions/message_reactions_modal.dart +++ b/packages/stream_chat_flutter/lib/src/message_widget/reactions/message_reactions_modal.dart @@ -2,6 +2,7 @@ import 'dart:ui'; import 'package:flutter/material.dart'; import 'package:stream_chat_flutter/src/message_widget/reactions/reaction_bubble.dart'; +import 'package:stream_chat_flutter/src/message_widget/reactions/reactions_align.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; /// {@template streamMessageReactionsModal} @@ -45,19 +46,10 @@ class StreamMessageReactionsModal extends StatelessWidget { final hasReactionPermission = _userPermissions.contains(PermissionType.sendReaction); - final roughMaxSize = size.width * 2 / 3; - - final roughSentenceSize = - message.roughMessageSize(messageTheme.messageTextStyle?.fontSize); - final divFactor = message.attachments.isNotEmpty - ? 1 - : (roughSentenceSize == 0 ? 1 : (roughSentenceSize / roughMaxSize)); - + final fontSize = messageTheme.messageTextStyle?.fontSize; final numberOfReactions = StreamChatConfiguration.of(context).reactionIcons.length; - final shiftFactor = - numberOfReactions < 5 ? (5 - numberOfReactions) * 0.1 : 0.0; final child = Center( child: SingleChildScrollView( @@ -69,20 +61,25 @@ class StreamMessageReactionsModal extends StatelessWidget { children: [ if ((showReactions ?? hasReactionPermission) && (message.status == MessageSendingStatus.sent)) - Align( - alignment: Alignment( - user!.id == message.user!.id - ? (divFactor >= 1.0 - ? -0.2 - shiftFactor - : (1.2 - divFactor)) - : (divFactor >= 1.0 - ? shiftFactor + 0.2 - : -(1.2 - divFactor)), - 0, - ), - child: StreamReactionPicker( - message: message, - ), + LayoutBuilder( + builder: (context, constraints) { + return Align( + alignment: Alignment( + calculateReactionsHorizontalAlignmentValue( + user, + message, + constraints, + roughMaxSize, + fontSize, + numberOfReactions, + ), + 0, + ), + child: StreamReactionPicker( + message: message, + ), + ); + }, ), const SizedBox(height: 10), IgnorePointer( diff --git a/packages/stream_chat_flutter/lib/src/message_widget/reactions/reactions_align.dart b/packages/stream_chat_flutter/lib/src/message_widget/reactions/reactions_align.dart index e6e81eb6c..8abced3ec 100644 --- a/packages/stream_chat_flutter/lib/src/message_widget/reactions/reactions_align.dart +++ b/packages/stream_chat_flutter/lib/src/message_widget/reactions/reactions_align.dart @@ -3,17 +3,25 @@ import 'package:stream_chat_flutter/stream_chat_flutter.dart'; /// Document here!! double calculateReactionsHorizontalAlignmentValue( - User? user, - Message message, - num divFactor, - double shiftFactor, - BoxConstraints constraints, - ) { + User? user, + Message message, + BoxConstraints constraints, + double maxSize, + double? fontSize, + int reactionsCount, +) { var result = 0.0; + final shiftFactor = reactionsCount < 5 ? (5 - reactionsCount) * 0.1 : 0.0; final maxWidth = constraints.maxWidth; final maxHeight = constraints.maxHeight; + final roughSentenceSize = message.roughMessageSize(fontSize); + + final divFactor = message.attachments.isNotEmpty + ? 1 + : (roughSentenceSize == 0 ? 1 : (roughSentenceSize / maxSize)); + print('INFO - max width: $maxWidth. ' 'maxHeight: $maxHeight ' 'shiftFactor: $shiftFactor ' @@ -48,6 +56,8 @@ double calculateReactionsHorizontalAlignmentValue( // Hacky!!! Needs improvement!!! if (result > 1.0) { return 1; + } else if (result < -1.0) { + return -1; } else { return result; } From df98fd5d8dc8e9c6fe2ec23bbf7c6a1b434c51d1 Mon Sep 17 00:00:00 2001 From: Leandro Borges Ferreira Date: Wed, 8 Feb 2023 20:38:27 +0100 Subject: [PATCH 054/107] reducing code duplication --- .../message_actions_modal.dart | 2 + .../reactions/message_reactions_modal.dart | 2 + .../reactions/reactions_align.dart | 91 ++++++++++++++++++- 3 files changed, 91 insertions(+), 4 deletions(-) diff --git a/packages/stream_chat_flutter/lib/src/message_actions_modal/message_actions_modal.dart b/packages/stream_chat_flutter/lib/src/message_actions_modal/message_actions_modal.dart index 0ca7ac163..f14aa438f 100644 --- a/packages/stream_chat_flutter/lib/src/message_actions_modal/message_actions_modal.dart +++ b/packages/stream_chat_flutter/lib/src/message_actions_modal/message_actions_modal.dart @@ -100,6 +100,7 @@ class _MessageActionsModalState extends State { final mediaQueryData = MediaQuery.of(context); final size = mediaQueryData.size; final user = StreamChat.of(context).currentUser; + final orientation = mediaQueryData.orientation; final roughMaxSize = size.width * 2 / 3; @@ -140,6 +141,7 @@ class _MessageActionsModalState extends State { roughMaxSize, fontSize, numberOfReactions, + orientation, ), 0, ), diff --git a/packages/stream_chat_flutter/lib/src/message_widget/reactions/message_reactions_modal.dart b/packages/stream_chat_flutter/lib/src/message_widget/reactions/message_reactions_modal.dart index 813c3d256..6e746f389 100644 --- a/packages/stream_chat_flutter/lib/src/message_widget/reactions/message_reactions_modal.dart +++ b/packages/stream_chat_flutter/lib/src/message_widget/reactions/message_reactions_modal.dart @@ -43,6 +43,7 @@ class StreamMessageReactionsModal extends StatelessWidget { final size = MediaQuery.of(context).size; final user = StreamChat.of(context).currentUser; final _userPermissions = StreamChannel.of(context).channel.ownCapabilities; + final orientation = MediaQuery.of(context).orientation; final hasReactionPermission = _userPermissions.contains(PermissionType.sendReaction); @@ -72,6 +73,7 @@ class StreamMessageReactionsModal extends StatelessWidget { roughMaxSize, fontSize, numberOfReactions, + orientation, ), 0, ), diff --git a/packages/stream_chat_flutter/lib/src/message_widget/reactions/reactions_align.dart b/packages/stream_chat_flutter/lib/src/message_widget/reactions/reactions_align.dart index 8abced3ec..800e82e99 100644 --- a/packages/stream_chat_flutter/lib/src/message_widget/reactions/reactions_align.dart +++ b/packages/stream_chat_flutter/lib/src/message_widget/reactions/reactions_align.dart @@ -9,9 +9,8 @@ double calculateReactionsHorizontalAlignmentValue( double maxSize, double? fontSize, int reactionsCount, + Orientation orientation, ) { - var result = 0.0; - final shiftFactor = reactionsCount < 5 ? (5 - reactionsCount) * 0.1 : 0.0; final maxWidth = constraints.maxWidth; final maxHeight = constraints.maxHeight; @@ -22,11 +21,42 @@ double calculateReactionsHorizontalAlignmentValue( ? 1 : (roughSentenceSize == 0 ? 1 : (roughSentenceSize / maxSize)); + if (orientation == Orientation.portrait) { + return _portraitAlign( + user, + message, + maxWidth, + maxHeight, + shiftFactor, + divFactor, + ); + } else { + return _landScapeAlign( + user, + message, + maxWidth, + maxHeight, + shiftFactor, + divFactor, + ); + } +} + +double _portraitAlign( + User? user, + Message message, + double maxWidth, + double maxHeight, + double shiftFactor, + num divFactor, +) { print('INFO - max width: $maxWidth. ' 'maxHeight: $maxHeight ' 'shiftFactor: $shiftFactor ' 'divFactor: $divFactor'); + var result = 0.0; + if (user?.id == message.user?.id) { if (divFactor >= 1.0) { /* @@ -49,11 +79,64 @@ double calculateReactionsHorizontalAlignmentValue( } } - print('INFO - result: $result'); + print('INFO - result portrait: $result'); + + // Ensure reactions don't get pushed past the edge of the screen. + // + // This happens if divFactor is really big. When this happens, we can simply + // move the model all the way to the end of screen. + if (result > 1.0) { + return 1; + } else if (result < -1.0) { + return -1; + } else { + return result; + } +} + +double _landScapeAlign( + User? user, + Message message, + double maxWidth, + double maxHeight, + double shiftFactor, + num divFactor, +) { + var result = 0.0; + + print('INFO - max width: $maxWidth. ' + 'maxHeight: $maxHeight ' + 'shiftFactor: $shiftFactor ' + 'divFactor: $divFactor'); + + if (user?.id == message.user?.id) { + if (divFactor >= 1.7) { + /* + This is an empiric value. This number tries to approximate all the + offset necessary for the position of reaction look the best way + possible. + */ + const constant = 3000; + + result = shiftFactor - maxWidth / constant; + } else { + // Small messages, it is simpler to align then. + result = 1 - divFactor * 0.6; + } + } else { + if (divFactor >= 1.7) { + result = shiftFactor + 0.2; + } else { + result = -(1.2 - divFactor); + } + } + + print('INFO - result landscape: $result'); // Ensure reactions don't get pushed past the edge of the screen. // - // Hacky!!! Needs improvement!!! + // This happens if divFactor is really big. When this happens, we can simply + // move the model all the way to the end of screen. if (result > 1.0) { return 1; } else if (result < -1.0) { From 26d519029d4c5a81de5557888df075dbf8e64e35 Mon Sep 17 00:00:00 2001 From: Leandro Borges Ferreira Date: Wed, 8 Feb 2023 20:38:49 +0100 Subject: [PATCH 055/107] Applying max for message lengh --- packages/stream_chat_flutter/lib/src/utils/extensions.dart | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/stream_chat_flutter/lib/src/utils/extensions.dart b/packages/stream_chat_flutter/lib/src/utils/extensions.dart index 4e2da3838..a653219fe 100644 --- a/packages/stream_chat_flutter/lib/src/utils/extensions.dart +++ b/packages/stream_chat_flutter/lib/src/utils/extensions.dart @@ -1,3 +1,5 @@ +import 'dart:math'; + import 'package:collection/collection.dart'; import 'package:diacritic/diacritic.dart'; import 'package:file_picker/file_picker.dart'; @@ -366,11 +368,11 @@ extension MessageX on Message { /// Returns an approximation of message size double roughMessageSize(double? fontSize) { - var messageTextLength = text!.biggestLine().length; + var messageTextLength = min(text!.biggestLine().length, 65); if (quotedMessage != null) { var quotedMessageLength = - (quotedMessage!.text?.biggestLine().length ?? 0) + 6; + (min(quotedMessage!.text?.biggestLine().length ?? 0, 65)) + 6; if (quotedMessage!.attachments.isNotEmpty) { quotedMessageLength += 40; From 8ad70e02e433dc0fd5d35ccd27b5e40edce41614 Mon Sep 17 00:00:00 2001 From: Leandro Borges Ferreira Date: Wed, 8 Feb 2023 20:53:31 +0100 Subject: [PATCH 056/107] FIxing attachments --- .../reactions/reactions_align.dart | 38 ++++++++++--------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/packages/stream_chat_flutter/lib/src/message_widget/reactions/reactions_align.dart b/packages/stream_chat_flutter/lib/src/message_widget/reactions/reactions_align.dart index 800e82e99..7ea4d0da2 100644 --- a/packages/stream_chat_flutter/lib/src/message_widget/reactions/reactions_align.dart +++ b/packages/stream_chat_flutter/lib/src/message_widget/reactions/reactions_align.dart @@ -16,8 +16,8 @@ double calculateReactionsHorizontalAlignmentValue( final maxHeight = constraints.maxHeight; final roughSentenceSize = message.roughMessageSize(fontSize); - - final divFactor = message.attachments.isNotEmpty + final hasAttachments = message.attachments.isNotEmpty; + final divFactor = hasAttachments ? 1 : (roughSentenceSize == 0 ? 1 : (roughSentenceSize / maxSize)); @@ -29,6 +29,7 @@ double calculateReactionsHorizontalAlignmentValue( maxHeight, shiftFactor, divFactor, + hasAttachments, ); } else { return _landScapeAlign( @@ -38,6 +39,7 @@ double calculateReactionsHorizontalAlignmentValue( maxHeight, shiftFactor, divFactor, + hasAttachments, ); } } @@ -49,6 +51,7 @@ double _portraitAlign( double maxHeight, double shiftFactor, num divFactor, + bool hasAttachments, ) { print('INFO - max width: $maxWidth. ' 'maxHeight: $maxHeight ' @@ -57,23 +60,21 @@ double _portraitAlign( var result = 0.0; - if (user?.id == message.user?.id) { - if (divFactor >= 1.0) { - /* - This is an empiric value. This number tries to approximate all the - offset necessary for the position of reaction look the best way - possible. - */ - const constant = 1300; + // This is an empiric value. This number tries to approximate all the + // offset necessary for the position of reaction look the best way + // possible. + const constant = 1300; + if (user?.id == message.user?.id) { + if (divFactor >= 1.0 || hasAttachments) { result = shiftFactor - maxWidth / constant; } else { // Small messages, it is simpler to align then. result = 1.2 - divFactor; } } else { - if (divFactor >= 1.0) { - result = shiftFactor + 0.2; + if (divFactor >= 1.0 || hasAttachments) { + result = shiftFactor + maxWidth / constant; } else { result = -(1.2 - divFactor); } @@ -101,6 +102,7 @@ double _landScapeAlign( double maxHeight, double shiftFactor, num divFactor, + bool hasAttachments, ) { var result = 0.0; @@ -109,15 +111,15 @@ double _landScapeAlign( 'shiftFactor: $shiftFactor ' 'divFactor: $divFactor'); - if (user?.id == message.user?.id) { - if (divFactor >= 1.7) { - /* + /* This is an empiric value. This number tries to approximate all the offset necessary for the position of reaction look the best way possible. */ - const constant = 3000; + const constant = 3000; + if (user?.id == message.user?.id) { + if (divFactor >= 1.7) { result = shiftFactor - maxWidth / constant; } else { // Small messages, it is simpler to align then. @@ -125,9 +127,9 @@ double _landScapeAlign( } } else { if (divFactor >= 1.7) { - result = shiftFactor + 0.2; + result = shiftFactor + maxWidth / constant; } else { - result = -(1.2 - divFactor); + result = -(1.2 - divFactor * 0.6); } } From 91b801296437e243a9746d36ddb69887efc86a07 Mon Sep 17 00:00:00 2001 From: Leandro Borges Ferreira Date: Wed, 8 Feb 2023 20:54:50 +0100 Subject: [PATCH 057/107] Removing prints from reactions_align --- .../reactions/reactions_align.dart | 20 ++++--------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/packages/stream_chat_flutter/lib/src/message_widget/reactions/reactions_align.dart b/packages/stream_chat_flutter/lib/src/message_widget/reactions/reactions_align.dart index 7ea4d0da2..f5d0cce58 100644 --- a/packages/stream_chat_flutter/lib/src/message_widget/reactions/reactions_align.dart +++ b/packages/stream_chat_flutter/lib/src/message_widget/reactions/reactions_align.dart @@ -53,11 +53,6 @@ double _portraitAlign( num divFactor, bool hasAttachments, ) { - print('INFO - max width: $maxWidth. ' - 'maxHeight: $maxHeight ' - 'shiftFactor: $shiftFactor ' - 'divFactor: $divFactor'); - var result = 0.0; // This is an empiric value. This number tries to approximate all the @@ -106,16 +101,11 @@ double _landScapeAlign( ) { var result = 0.0; - print('INFO - max width: $maxWidth. ' - 'maxHeight: $maxHeight ' - 'shiftFactor: $shiftFactor ' - 'divFactor: $divFactor'); - /* - This is an empiric value. This number tries to approximate all the - offset necessary for the position of reaction look the best way - possible. - */ + This is an empiric value. This number tries to approximate all the + offset necessary for the position of reaction look the best way + possible. + */ const constant = 3000; if (user?.id == message.user?.id) { @@ -133,8 +123,6 @@ double _landScapeAlign( } } - print('INFO - result landscape: $result'); - // Ensure reactions don't get pushed past the edge of the screen. // // This happens if divFactor is really big. When this happens, we can simply From c9c43567a3170a31d24a287278ee371faed64089 Mon Sep 17 00:00:00 2001 From: Leandro Borges Ferreira Date: Wed, 8 Feb 2023 20:56:35 +0100 Subject: [PATCH 058/107] Removing prints --- .../src/message_actions_modal/message_actions_modal.dart | 9 --------- .../src/message_widget/reactions/reactions_align.dart | 2 -- 2 files changed, 11 deletions(-) diff --git a/packages/stream_chat_flutter/lib/src/message_actions_modal/message_actions_modal.dart b/packages/stream_chat_flutter/lib/src/message_actions_modal/message_actions_modal.dart index f14aa438f..d8f5614b9 100644 --- a/packages/stream_chat_flutter/lib/src/message_actions_modal/message_actions_modal.dart +++ b/packages/stream_chat_flutter/lib/src/message_actions_modal/message_actions_modal.dart @@ -103,17 +103,8 @@ class _MessageActionsModalState extends State { final orientation = mediaQueryData.orientation; final roughMaxSize = size.width * 2 / 3; - - final roughSentenceSize = widget.message - .roughMessageSize(widget.messageTheme.messageTextStyle?.fontSize); - final fontSize = widget.messageTheme.messageTextStyle?.fontSize; - - print('roughSentenceSize $roughSentenceSize'); - print('roughMaxSize $roughMaxSize'); - final streamChatThemeData = StreamChatTheme.of(context); - final numberOfReactions = StreamChatConfiguration.of(context).reactionIcons.length; diff --git a/packages/stream_chat_flutter/lib/src/message_widget/reactions/reactions_align.dart b/packages/stream_chat_flutter/lib/src/message_widget/reactions/reactions_align.dart index f5d0cce58..2dcc659cd 100644 --- a/packages/stream_chat_flutter/lib/src/message_widget/reactions/reactions_align.dart +++ b/packages/stream_chat_flutter/lib/src/message_widget/reactions/reactions_align.dart @@ -75,8 +75,6 @@ double _portraitAlign( } } - print('INFO - result portrait: $result'); - // Ensure reactions don't get pushed past the edge of the screen. // // This happens if divFactor is really big. When this happens, we can simply From 8fa7abea1b214815c936f5b028de92f85068d413 Mon Sep 17 00:00:00 2001 From: Leandro Borges Ferreira Date: Wed, 8 Feb 2023 20:59:45 +0100 Subject: [PATCH 059/107] Update reactions_align.dart --- .../reactions/reactions_align.dart | 28 ++++++++----------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/packages/stream_chat_flutter/lib/src/message_widget/reactions/reactions_align.dart b/packages/stream_chat_flutter/lib/src/message_widget/reactions/reactions_align.dart index 2dcc659cd..0808092b7 100644 --- a/packages/stream_chat_flutter/lib/src/message_widget/reactions/reactions_align.dart +++ b/packages/stream_chat_flutter/lib/src/message_widget/reactions/reactions_align.dart @@ -1,7 +1,9 @@ import 'package:flutter/material.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; -/// Document here!! +/// This method calculates the align that the modal of reactions should have. +/// THis is an approximation based on the size of the message and the +/// available space in the screen. double calculateReactionsHorizontalAlignmentValue( User? user, Message message, @@ -75,17 +77,7 @@ double _portraitAlign( } } - // Ensure reactions don't get pushed past the edge of the screen. - // - // This happens if divFactor is really big. When this happens, we can simply - // move the model all the way to the end of screen. - if (result > 1.0) { - return 1; - } else if (result < -1.0) { - return -1; - } else { - return result; - } + return _capResult(result); } double _landScapeAlign( @@ -121,10 +113,14 @@ double _landScapeAlign( } } - // Ensure reactions don't get pushed past the edge of the screen. - // - // This happens if divFactor is really big. When this happens, we can simply - // move the model all the way to the end of screen. + return _capResult(result); +} + +// Ensure reactions don't get pushed past the edge of the screen. +// +// This happens if divFactor is really big. When this happens, we can simply +// move the model all the way to the end of screen. +double _capResult(double result) { if (result > 1.0) { return 1; } else if (result < -1.0) { From 6b3c8ad95dfbf6e44214bb2bc2f27391fd486892 Mon Sep 17 00:00:00 2001 From: Leandro Borges Ferreira Date: Thu, 9 Feb 2023 13:50:06 +0100 Subject: [PATCH 060/107] Fixing static analyses --- packages/stream_chat_flutter/lib/src/utils/extensions.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/stream_chat_flutter/lib/src/utils/extensions.dart b/packages/stream_chat_flutter/lib/src/utils/extensions.dart index a653219fe..bbe43690e 100644 --- a/packages/stream_chat_flutter/lib/src/utils/extensions.dart +++ b/packages/stream_chat_flutter/lib/src/utils/extensions.dart @@ -1,6 +1,5 @@ import 'dart:math'; -import 'package:collection/collection.dart'; import 'package:diacritic/diacritic.dart'; import 'package:file_picker/file_picker.dart'; import 'package:flutter/foundation.dart'; From 4dda50df73299720004eb6c2cfd088c725f321ed Mon Sep 17 00:00:00 2001 From: Leandro Borges Ferreira Date: Sun, 26 Feb 2023 16:29:07 +0100 Subject: [PATCH 061/107] Fixing images alignment in portrait mode --- .../lib/src/message_widget/reactions/reactions_align.dart | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/stream_chat_flutter/lib/src/message_widget/reactions/reactions_align.dart b/packages/stream_chat_flutter/lib/src/message_widget/reactions/reactions_align.dart index 0808092b7..9985bd437 100644 --- a/packages/stream_chat_flutter/lib/src/message_widget/reactions/reactions_align.dart +++ b/packages/stream_chat_flutter/lib/src/message_widget/reactions/reactions_align.dart @@ -97,8 +97,9 @@ double _landScapeAlign( possible. */ const constant = 3000; - - if (user?.id == message.user?.id) { + if (hasAttachments) { + result = 0; + } else if (user?.id == message.user?.id) { if (divFactor >= 1.7) { result = shiftFactor - maxWidth / constant; } else { From dcf5abc11884b085321eec4b6142d7150a73c12c Mon Sep 17 00:00:00 2001 From: Leandro Borges Ferreira Date: Sun, 26 Feb 2023 16:53:13 +0100 Subject: [PATCH 062/107] Fixing some measures --- .../reactions/reactions_align.dart | 24 ++++++++++++------- .../lib/src/utils/extensions.dart | 2 +- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/packages/stream_chat_flutter/lib/src/message_widget/reactions/reactions_align.dart b/packages/stream_chat_flutter/lib/src/message_widget/reactions/reactions_align.dart index 9985bd437..639fad4ca 100644 --- a/packages/stream_chat_flutter/lib/src/message_widget/reactions/reactions_align.dart +++ b/packages/stream_chat_flutter/lib/src/message_widget/reactions/reactions_align.dart @@ -18,8 +18,12 @@ double calculateReactionsHorizontalAlignmentValue( final maxHeight = constraints.maxHeight; final roughSentenceSize = message.roughMessageSize(fontSize); + print('roughSentenceSize: $roughSentenceSize'); + print('maxSize: $maxSize'); final hasAttachments = message.attachments.isNotEmpty; - final divFactor = hasAttachments + final isReply = message.quotedMessageId != null; + final isAttachment = hasAttachments && !isReply; + final divFactor = isAttachment ? 1 : (roughSentenceSize == 0 ? 1 : (roughSentenceSize / maxSize)); @@ -31,7 +35,7 @@ double calculateReactionsHorizontalAlignmentValue( maxHeight, shiftFactor, divFactor, - hasAttachments, + isAttachment, ); } else { return _landScapeAlign( @@ -41,7 +45,7 @@ double calculateReactionsHorizontalAlignmentValue( maxHeight, shiftFactor, divFactor, - hasAttachments, + isAttachment, ); } } @@ -53,7 +57,7 @@ double _portraitAlign( double maxHeight, double shiftFactor, num divFactor, - bool hasAttachments, + bool isAttachment, ) { var result = 0.0; @@ -63,14 +67,14 @@ double _portraitAlign( const constant = 1300; if (user?.id == message.user?.id) { - if (divFactor >= 1.0 || hasAttachments) { + if (divFactor >= 1.0 || isAttachment) { result = shiftFactor - maxWidth / constant; } else { // Small messages, it is simpler to align then. result = 1.2 - divFactor; } } else { - if (divFactor >= 1.0 || hasAttachments) { + if (divFactor >= 1.0 || isAttachment) { result = shiftFactor + maxWidth / constant; } else { result = -(1.2 - divFactor); @@ -87,17 +91,21 @@ double _landScapeAlign( double maxHeight, double shiftFactor, num divFactor, - bool hasAttachments, + bool isAttachment, ) { var result = 0.0; + print('is attachment: $isAttachment'); + print('shiftFactor: $shiftFactor'); + print('divFactor: $divFactor'); + /* This is an empiric value. This number tries to approximate all the offset necessary for the position of reaction look the best way possible. */ const constant = 3000; - if (hasAttachments) { + if (isAttachment) { result = 0; } else if (user?.id == message.user?.id) { if (divFactor >= 1.7) { diff --git a/packages/stream_chat_flutter/lib/src/utils/extensions.dart b/packages/stream_chat_flutter/lib/src/utils/extensions.dart index bbe43690e..8b575910e 100644 --- a/packages/stream_chat_flutter/lib/src/utils/extensions.dart +++ b/packages/stream_chat_flutter/lib/src/utils/extensions.dart @@ -374,7 +374,7 @@ extension MessageX on Message { (min(quotedMessage!.text?.biggestLine().length ?? 0, 65)) + 6; if (quotedMessage!.attachments.isNotEmpty) { - quotedMessageLength += 40; + quotedMessageLength += 8; } if (quotedMessageLength > messageTextLength) { messageTextLength = quotedMessageLength; From 7586929a9c8006036648896629464789af2ef6e7 Mon Sep 17 00:00:00 2001 From: Leandro Borges Ferreira Date: Sun, 26 Feb 2023 17:16:19 +0100 Subject: [PATCH 063/107] Fixing calculus of message size when the message is a reply --- .../lib/src/utils/extensions.dart | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/packages/stream_chat_flutter/lib/src/utils/extensions.dart b/packages/stream_chat_flutter/lib/src/utils/extensions.dart index 8b575910e..bf5b30fbc 100644 --- a/packages/stream_chat_flutter/lib/src/utils/extensions.dart +++ b/packages/stream_chat_flutter/lib/src/utils/extensions.dart @@ -371,17 +371,25 @@ extension MessageX on Message { if (quotedMessage != null) { var quotedMessageLength = - (min(quotedMessage!.text?.biggestLine().length ?? 0, 65)) + 6; + (min(quotedMessage!.text?.biggestLine().length ?? 0, 65)) + 8; if (quotedMessage!.attachments.isNotEmpty) { quotedMessageLength += 8; } - if (quotedMessageLength > messageTextLength) { + + if (quotedMessageLength > messageTextLength * 1.2) { messageTextLength = quotedMessageLength; } } - return messageTextLength * (fontSize ?? 1) * 1.2; + // Quoted message have a smaller font, so it is necessary to reduce the + // size of the multiplier to count for the smaller font. + var multiplier = 1.2; + if (quotedMessage != null) { + multiplier = 1; + } + + return messageTextLength * (fontSize ?? 1) * multiplier; } /// It returns the message with the translated text if available locally From dc1b01f883779911cd9bd63a5953cb2b50f2356b Mon Sep 17 00:00:00 2001 From: Leandro Borges Ferreira Date: Sun, 26 Feb 2023 17:16:36 +0100 Subject: [PATCH 064/107] Moving modal to the middle of the screen when message is big --- .../lib/src/message_widget/reactions/reactions_align.dart | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/stream_chat_flutter/lib/src/message_widget/reactions/reactions_align.dart b/packages/stream_chat_flutter/lib/src/message_widget/reactions/reactions_align.dart index 639fad4ca..3fedbeff0 100644 --- a/packages/stream_chat_flutter/lib/src/message_widget/reactions/reactions_align.dart +++ b/packages/stream_chat_flutter/lib/src/message_widget/reactions/reactions_align.dart @@ -66,6 +66,10 @@ double _portraitAlign( // possible. const constant = 1300; + print('is attachment: $isAttachment'); + print('shiftFactor: $shiftFactor'); + print('divFactor: $divFactor'); + if (user?.id == message.user?.id) { if (divFactor >= 1.0 || isAttachment) { result = shiftFactor - maxWidth / constant; @@ -109,7 +113,7 @@ double _landScapeAlign( result = 0; } else if (user?.id == message.user?.id) { if (divFactor >= 1.7) { - result = shiftFactor - maxWidth / constant; + result = 0; } else { // Small messages, it is simpler to align then. result = 1 - divFactor * 0.6; From 9dc56f55014c5b717ef6b0d7fa76d5e275a0d037 Mon Sep 17 00:00:00 2001 From: Leandro Borges Ferreira Date: Sun, 26 Feb 2023 17:29:35 +0100 Subject: [PATCH 065/107] Fixing div factory and making alignment symmetrical --- .../lib/src/message_widget/reactions/reactions_align.dart | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/stream_chat_flutter/lib/src/message_widget/reactions/reactions_align.dart b/packages/stream_chat_flutter/lib/src/message_widget/reactions/reactions_align.dart index 3fedbeff0..ec1497187 100644 --- a/packages/stream_chat_flutter/lib/src/message_widget/reactions/reactions_align.dart +++ b/packages/stream_chat_flutter/lib/src/message_widget/reactions/reactions_align.dart @@ -112,17 +112,17 @@ double _landScapeAlign( if (isAttachment) { result = 0; } else if (user?.id == message.user?.id) { - if (divFactor >= 1.7) { + if (divFactor >= 1.0) { result = 0; } else { // Small messages, it is simpler to align then. result = 1 - divFactor * 0.6; } } else { - if (divFactor >= 1.7) { + if (divFactor >= 1.0) { result = shiftFactor + maxWidth / constant; } else { - result = -(1.2 - divFactor * 0.6); + result = -(1 - divFactor * 0.6); } } From 4818d094af83322e2b23dec37383626d4630bda9 Mon Sep 17 00:00:00 2001 From: Leandro Borges Ferreira Date: Sun, 26 Feb 2023 17:53:22 +0100 Subject: [PATCH 066/107] Fixing modal in the middle for big messages in landscape --- .../lib/src/message_widget/reactions/reactions_align.dart | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/stream_chat_flutter/lib/src/message_widget/reactions/reactions_align.dart b/packages/stream_chat_flutter/lib/src/message_widget/reactions/reactions_align.dart index ec1497187..da63f589f 100644 --- a/packages/stream_chat_flutter/lib/src/message_widget/reactions/reactions_align.dart +++ b/packages/stream_chat_flutter/lib/src/message_widget/reactions/reactions_align.dart @@ -108,19 +108,18 @@ double _landScapeAlign( offset necessary for the position of reaction look the best way possible. */ - const constant = 3000; if (isAttachment) { result = 0; } else if (user?.id == message.user?.id) { - if (divFactor >= 1.0) { + if (divFactor >= 1.3) { result = 0; } else { // Small messages, it is simpler to align then. result = 1 - divFactor * 0.6; } } else { - if (divFactor >= 1.0) { - result = shiftFactor + maxWidth / constant; + if (divFactor >= 1.3) { + result = 0; } else { result = -(1 - divFactor * 0.6); } From 009860d96aa687cd3a2b3743397043d508c78044 Mon Sep 17 00:00:00 2001 From: Leandro Borges Ferreira Date: Sun, 26 Feb 2023 19:02:46 +0100 Subject: [PATCH 067/107] Refactoring modal alignment logic --- .../message_actions_modal.dart | 8 +- .../reactions/message_reactions_modal.dart | 8 +- .../reactions/reactions_align.dart | 124 +++--------------- .../lib/src/utils/extensions.dart | 4 +- 4 files changed, 25 insertions(+), 119 deletions(-) diff --git a/packages/stream_chat_flutter/lib/src/message_actions_modal/message_actions_modal.dart b/packages/stream_chat_flutter/lib/src/message_actions_modal/message_actions_modal.dart index d8f5614b9..2ccb0bc2b 100644 --- a/packages/stream_chat_flutter/lib/src/message_actions_modal/message_actions_modal.dart +++ b/packages/stream_chat_flutter/lib/src/message_actions_modal/message_actions_modal.dart @@ -98,15 +98,11 @@ class _MessageActionsModalState extends State { Widget _showMessageOptionsModal() { final mediaQueryData = MediaQuery.of(context); - final size = mediaQueryData.size; final user = StreamChat.of(context).currentUser; final orientation = mediaQueryData.orientation; - final roughMaxSize = size.width * 2 / 3; final fontSize = widget.messageTheme.messageTextStyle?.fontSize; final streamChatThemeData = StreamChatTheme.of(context); - final numberOfReactions = - StreamChatConfiguration.of(context).reactionIcons.length; final channel = StreamChannel.of(context).channel; @@ -125,13 +121,11 @@ class _MessageActionsModalState extends State { builder: (context, constraints) { return Align( alignment: Alignment( - calculateReactionsHorizontalAlignmentValue( + calculateReactionsHorizontalAlignment( user, widget.message, constraints, - roughMaxSize, fontSize, - numberOfReactions, orientation, ), 0, diff --git a/packages/stream_chat_flutter/lib/src/message_widget/reactions/message_reactions_modal.dart b/packages/stream_chat_flutter/lib/src/message_widget/reactions/message_reactions_modal.dart index 6e746f389..0703ce19f 100644 --- a/packages/stream_chat_flutter/lib/src/message_widget/reactions/message_reactions_modal.dart +++ b/packages/stream_chat_flutter/lib/src/message_widget/reactions/message_reactions_modal.dart @@ -40,17 +40,13 @@ class StreamMessageReactionsModal extends StatelessWidget { @override Widget build(BuildContext context) { - final size = MediaQuery.of(context).size; final user = StreamChat.of(context).currentUser; final _userPermissions = StreamChannel.of(context).channel.ownCapabilities; final orientation = MediaQuery.of(context).orientation; final hasReactionPermission = _userPermissions.contains(PermissionType.sendReaction); - final roughMaxSize = size.width * 2 / 3; final fontSize = messageTheme.messageTextStyle?.fontSize; - final numberOfReactions = - StreamChatConfiguration.of(context).reactionIcons.length; final child = Center( child: SingleChildScrollView( @@ -66,13 +62,11 @@ class StreamMessageReactionsModal extends StatelessWidget { builder: (context, constraints) { return Align( alignment: Alignment( - calculateReactionsHorizontalAlignmentValue( + calculateReactionsHorizontalAlignment( user, message, constraints, - roughMaxSize, fontSize, - numberOfReactions, orientation, ), 0, diff --git a/packages/stream_chat_flutter/lib/src/message_widget/reactions/reactions_align.dart b/packages/stream_chat_flutter/lib/src/message_widget/reactions/reactions_align.dart index da63f589f..7f5f4cffc 100644 --- a/packages/stream_chat_flutter/lib/src/message_widget/reactions/reactions_align.dart +++ b/packages/stream_chat_flutter/lib/src/message_widget/reactions/reactions_align.dart @@ -2,129 +2,47 @@ import 'package:flutter/material.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; /// This method calculates the align that the modal of reactions should have. -/// THis is an approximation based on the size of the message and the +/// This is an approximation based on the size of the message and the /// available space in the screen. -double calculateReactionsHorizontalAlignmentValue( +double calculateReactionsHorizontalAlignment( User? user, Message message, BoxConstraints constraints, - double maxSize, double? fontSize, - int reactionsCount, Orientation orientation, ) { - final shiftFactor = reactionsCount < 5 ? (5 - reactionsCount) * 0.1 : 0.0; final maxWidth = constraints.maxWidth; - final maxHeight = constraints.maxHeight; final roughSentenceSize = message.roughMessageSize(fontSize); - print('roughSentenceSize: $roughSentenceSize'); - print('maxSize: $maxSize'); final hasAttachments = message.attachments.isNotEmpty; final isReply = message.quotedMessageId != null; final isAttachment = hasAttachments && !isReply; - final divFactor = isAttachment - ? 1 - : (roughSentenceSize == 0 ? 1 : (roughSentenceSize / maxSize)); - if (orientation == Orientation.portrait) { - return _portraitAlign( - user, - message, - maxWidth, - maxHeight, - shiftFactor, - divFactor, - isAttachment, - ); - } else { - return _landScapeAlign( - user, - message, - maxWidth, - maxHeight, - shiftFactor, - divFactor, - isAttachment, - ); - } -} - -double _portraitAlign( - User? user, - Message message, - double maxWidth, - double maxHeight, - double shiftFactor, - num divFactor, - bool isAttachment, -) { - var result = 0.0; - - // This is an empiric value. This number tries to approximate all the - // offset necessary for the position of reaction look the best way - // possible. - const constant = 1300; - - print('is attachment: $isAttachment'); - print('shiftFactor: $shiftFactor'); - print('divFactor: $divFactor'); - - if (user?.id == message.user?.id) { - if (divFactor >= 1.0 || isAttachment) { - result = shiftFactor - maxWidth / constant; - } else { - // Small messages, it is simpler to align then. - result = 1.2 - divFactor; - } - } else { - if (divFactor >= 1.0 || isAttachment) { - result = shiftFactor + maxWidth / constant; - } else { - result = -(1.2 - divFactor); - } - } - - return _capResult(result); -} - -double _landScapeAlign( - User? user, - Message message, - double maxWidth, - double maxHeight, - double shiftFactor, - num divFactor, - bool isAttachment, -) { - var result = 0.0; - - print('is attachment: $isAttachment'); - print('shiftFactor: $shiftFactor'); - print('divFactor: $divFactor'); - - /* - This is an empiric value. This number tries to approximate all the - offset necessary for the position of reaction look the best way - possible. - */ + // divFactor is the percentage of the available space that the message takes. + // When the divFactor is bigger than 0.5 that means that the messages is + // bigger than 50% of the available space and the modal should have an offset + // in the direction that the message grows. When the divFactor is smaller + // than 0.5 then the offset should be to he side opposite of the message + // growth. + // In resume, when divFactor > 0.5 then result > 0, when divFactor < 0.5 + // then result < 0. + var divFactor = 0.5; + + // When in portrait, attachments normally take 75% of the screen, when in + // landscape, attachments normally take 50% of the screen. if (isAttachment) { - result = 0; - } else if (user?.id == message.user?.id) { - if (divFactor >= 1.3) { - result = 0; + if (orientation == Orientation.portrait) { + divFactor = 0.75; } else { - // Small messages, it is simpler to align then. - result = 1 - divFactor * 0.6; + divFactor = 0.5; } } else { - if (divFactor >= 1.3) { - result = 0; - } else { - result = -(1 - divFactor * 0.6); - } + divFactor = roughSentenceSize == 0 ? 0.5 : (roughSentenceSize / maxWidth); } + final signal = user?.id == message.user?.id ? 1 : -1; + final result = signal * (1 - divFactor * 2.0); + return _capResult(result); } diff --git a/packages/stream_chat_flutter/lib/src/utils/extensions.dart b/packages/stream_chat_flutter/lib/src/utils/extensions.dart index bf5b30fbc..67b622dba 100644 --- a/packages/stream_chat_flutter/lib/src/utils/extensions.dart +++ b/packages/stream_chat_flutter/lib/src/utils/extensions.dart @@ -384,9 +384,9 @@ extension MessageX on Message { // Quoted message have a smaller font, so it is necessary to reduce the // size of the multiplier to count for the smaller font. - var multiplier = 1.2; + var multiplier = 0.55; if (quotedMessage != null) { - multiplier = 1; + multiplier = 0.45; } return messageTextLength * (fontSize ?? 1) * multiplier; From 1f6c3790484765fc446274b4bd5cee179dcab93d Mon Sep 17 00:00:00 2001 From: Leandro Borges Ferreira Date: Sun, 26 Feb 2023 19:05:46 +0100 Subject: [PATCH 068/107] Format comment --- .../lib/src/message_widget/reactions/reactions_align.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/stream_chat_flutter/lib/src/message_widget/reactions/reactions_align.dart b/packages/stream_chat_flutter/lib/src/message_widget/reactions/reactions_align.dart index 7f5f4cffc..e4e1ad489 100644 --- a/packages/stream_chat_flutter/lib/src/message_widget/reactions/reactions_align.dart +++ b/packages/stream_chat_flutter/lib/src/message_widget/reactions/reactions_align.dart @@ -29,7 +29,7 @@ double calculateReactionsHorizontalAlignment( var divFactor = 0.5; // When in portrait, attachments normally take 75% of the screen, when in - // landscape, attachments normally take 50% of the screen. + // landscape, attachments normally take 50% of the screen. if (isAttachment) { if (orientation == Orientation.portrait) { divFactor = 0.75; From d0fcdc78484608a2e98c3a0784f8c3490c37dee3 Mon Sep 17 00:00:00 2001 From: Leandro Borges Ferreira Date: Tue, 7 Mar 2023 11:46:30 +0100 Subject: [PATCH 069/107] Fixing typo in import --- packages/stream_chat_flutter/lib/src/video/vlc/vlc_manager.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/stream_chat_flutter/lib/src/video/vlc/vlc_manager.dart b/packages/stream_chat_flutter/lib/src/video/vlc/vlc_manager.dart index f721e2441..adecfc56b 100644 --- a/packages/stream_chat_flutter/lib/src/video/vlc/vlc_manager.dart +++ b/packages/stream_chat_flutter/lib/src/video/vlc/vlc_manager.dart @@ -1,6 +1,6 @@ import 'package:stream_chat_flutter/src/video/vlc/vlc_stub.dart' if (dart.library.io) 'vlc_manager_desktop.dart' - if (dar.library.html) 'vlc_manager_web.dart'; + if (dart.library.html) 'vlc_manager_web.dart'; /// {@template vlcManager} /// An abstract class for the purpose of ensuring Flutter applications that From 1caba4d43bd022ab9bccfbc7398ca1255d292ac1 Mon Sep 17 00:00:00 2001 From: Leandro Borges Ferreira Date: Tue, 7 Mar 2023 12:09:25 +0100 Subject: [PATCH 070/107] Update CHANGELOG.md --- packages/stream_chat_flutter/CHANGELOG.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/stream_chat_flutter/CHANGELOG.md b/packages/stream_chat_flutter/CHANGELOG.md index 405f49f02..cf0d43729 100644 --- a/packages/stream_chat_flutter/CHANGELOG.md +++ b/packages/stream_chat_flutter/CHANGELOG.md @@ -1,7 +1,9 @@ ## Upcoming 🐞 Fixed -[#1463](https://github.com/GetStream/stream-chat-flutter/pull/1463) Fixed support for iPad in the share button for images. + +- [#1462](https://github.com/GetStream/stream-chat-flutter/issues/1462) Fixed support for iPad in the share button for images. +- [#1475](https://github.com/GetStream/stream-chat-flutter/issues/1475) Fixed typo to fix compilation. ✅ Added From a3bc51590a0d5b604f5af8230b1737253c8b6077 Mon Sep 17 00:00:00 2001 From: Jeroen Leenarts Date: Mon, 13 Mar 2023 22:59:40 +0100 Subject: [PATCH 071/107] Fix link in 05-guides/09-initialize_stream_chat_widget_tree --- .../Flutter/05-guides/09-initialize_stream_chat_widget_tree.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docusaurus/docs/Flutter/05-guides/09-initialize_stream_chat_widget_tree.mdx b/docusaurus/docs/Flutter/05-guides/09-initialize_stream_chat_widget_tree.mdx index 17476d211..887c9b068 100644 --- a/docusaurus/docs/Flutter/05-guides/09-initialize_stream_chat_widget_tree.mdx +++ b/docusaurus/docs/Flutter/05-guides/09-initialize_stream_chat_widget_tree.mdx @@ -14,7 +14,7 @@ Before investigating potential solutions, let’s first take a look at the relev Most of the Stream Chat Flutter UI widgets rely on having a [StreamChat](../../customization/stream_chat_and_theming/) ancestor in the widget tree. The **StreamChat** widget is an [InheritedWidget](https://api.flutter.dev/flutter/widgets/InheritedWidget-class.html) that exposes the **StreamChatClient** through **BuildContext**. -This widget also initializes the [StreamChatCore](../../stream_chat_flutter_core/stream_chat_core.mdx) widget and the **StreamChatTheme**. +This widget also initializes the [StreamChatCore](../04-stream_chat_flutter_core/stream_chat_core.mdx) widget and the **StreamChatTheme**. **StreamChatCore** is a **StatefulWidget** used to react to life cycle changes and system updates. When the app goes into the background, the WebSocket connection is closed. From 33d2b4f7c064020494de8eeb2c09ba0ab6c8a054 Mon Sep 17 00:00:00 2001 From: Leandro Borges Ferreira Date: Thu, 30 Mar 2023 14:02:09 +0200 Subject: [PATCH 072/107] Bumping flutter --- .github/workflows/stream_flutter_workflow.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/stream_flutter_workflow.yml b/.github/workflows/stream_flutter_workflow.yml index 9de7ca4d5..e18a8b7a3 100644 --- a/.github/workflows/stream_flutter_workflow.yml +++ b/.github/workflows/stream_flutter_workflow.yml @@ -2,7 +2,7 @@ name: stream_flutter_workflow env: ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true' - flutter_version: "3.3.3" + flutter_version: "3.7.8" melos_version: "2.7.1" on: From 608049f71dff354eec7a26fc38f84e619cb6486a Mon Sep 17 00:00:00 2001 From: Sahil Kumar Date: Mon, 3 Apr 2023 18:01:09 +0530 Subject: [PATCH 073/107] feat(llc,core,ui,persistence,localization): update dependencies. Signed-off-by: xsahil03x --- melos.yaml | 4 +- packages/stream_chat/example/pubspec.yaml | 1 + .../lib/src/core/error/stream_chat_error.dart | 6 +- .../http/interceptor/logging_interceptor.dart | 11 +- .../lib/src/core/http/stream_http_client.dart | 4 +- .../core/models/attachment_file.freezed.dart | 157 +++++++++--------- .../lib/src/core/models/channel_model.g.dart | 45 ++--- .../lib/src/core/models/message.g.dart | 50 +++--- .../lib/src/core/models/reaction.g.dart | 28 +--- .../lib/src/core/models/user.g.dart | 16 +- packages/stream_chat/pubspec.yaml | 38 ++--- .../stream_chat_flutter/example/pubspec.yaml | 3 +- packages/stream_chat_flutter/pubspec.yaml | 16 +- .../example/pubspec.yaml | 2 + .../lib/src/paged_value_notifier.dart | 2 +- .../lib/src/paged_value_notifier.freezed.dart | 117 +++++++------ .../lib/src/stream_channel.dart | 4 +- .../stream_chat_flutter_core/pubspec.yaml | 11 +- .../test/stream_channel_test.dart | 2 +- .../stream_chat_localizations/pubspec.yaml | 1 + .../example/pubspec.yaml | 2 + packages/stream_chat_persistence/pubspec.yaml | 13 +- pubspec.yaml | 7 + 23 files changed, 267 insertions(+), 273 deletions(-) create mode 100644 pubspec.yaml diff --git a/melos.yaml b/melos.yaml index 217f4bc51..7a5016ff9 100644 --- a/melos.yaml +++ b/melos.yaml @@ -51,11 +51,11 @@ scripts: description: Build all generated files for Dart & Flutter packages in this project. generate:dart: - run: melos exec -c 1 --depends-on="build_runner" --no-flutter -- "dart run build_runner build --delete-conflicting-outputs --enable-experiment=super-parameters,enhanced-enums" + run: melos exec -c 1 --depends-on="build_runner" --no-flutter -- "dart run build_runner build --delete-conflicting-outputs" description: Build all generated files for Dart packages in this project. generate:flutter: - run: melos exec -c 1 --depends-on="build_runner" --flutter -- "flutter run build_runner build --delete-conflicting-outputs --enable-experiment=super-parameters,enhanced-enums" + run: melos exec -c 1 --depends-on="build_runner" --flutter -- "flutter pub run build_runner build --delete-conflicting-outputs" description: Build all generated files for Flutter packages in this project. test:all: diff --git a/packages/stream_chat/example/pubspec.yaml b/packages/stream_chat/example/pubspec.yaml index 9faa8ec74..49e226c2b 100644 --- a/packages/stream_chat/example/pubspec.yaml +++ b/packages/stream_chat/example/pubspec.yaml @@ -6,6 +6,7 @@ version: 1.0.0+1 environment: sdk: '>=2.17.0 <3.0.0' + flutter: ">=1.17.0" dependencies: cupertino_icons: ^1.0.0 diff --git a/packages/stream_chat/lib/src/core/error/stream_chat_error.dart b/packages/stream_chat/lib/src/core/error/stream_chat_error.dart index fc069a90d..1df285582 100644 --- a/packages/stream_chat/lib/src/core/error/stream_chat_error.dart +++ b/packages/stream_chat/lib/src/core/error/stream_chat_error.dart @@ -98,8 +98,10 @@ class StreamChatNetworkError extends StreamChatError { } return StreamChatNetworkError.raw( code: errorResponse?.code ?? -1, - message: - errorResponse?.message ?? response?.statusMessage ?? error.message, + message: errorResponse?.message ?? + response?.statusMessage ?? + error.message ?? + '', statusCode: errorResponse?.statusCode ?? response?.statusCode, data: errorResponse, isRequestCancelledError: error.type == DioErrorType.cancel, diff --git a/packages/stream_chat/lib/src/core/http/interceptor/logging_interceptor.dart b/packages/stream_chat/lib/src/core/http/interceptor/logging_interceptor.dart index 57ffda7db..6b07495de 100644 --- a/packages/stream_chat/lib/src/core/http/interceptor/logging_interceptor.dart +++ b/packages/stream_chat/lib/src/core/http/interceptor/logging_interceptor.dart @@ -87,8 +87,8 @@ class LoggingInterceptor extends Interceptor { requestHeaders['contentType'] = options.contentType?.toString(); requestHeaders['responseType'] = options.responseType.toString(); requestHeaders['followRedirects'] = options.followRedirects; - requestHeaders['connectTimeout'] = options.connectTimeout; - requestHeaders['receiveTimeout'] = options.receiveTimeout; + requestHeaders['connectTimeout'] = options.connectTimeout?.toString(); + requestHeaders['receiveTimeout'] = options.receiveTimeout?.toString(); _printMapAsTable(_logPrintRequest, requestHeaders, header: 'Headers'); _printMapAsTable(_logPrintRequest, options.extra, header: 'Extras'); } @@ -101,7 +101,8 @@ class LoggingInterceptor extends Interceptor { options.data as Map?, header: 'Body', ); - } else if (data is FormData) { + } + if (data is FormData) { final formDataMap = {} ..addEntries(data.fields) ..addEntries(data.files); @@ -121,7 +122,7 @@ class LoggingInterceptor extends Interceptor { @override void onError(DioError err, ErrorInterceptorHandler handler) { if (error) { - if (err.type == DioErrorType.response) { + if (err.type == DioErrorType.badResponse) { final uri = err.response?.requestOptions.uri; _printBoxed( _logPrintError, @@ -162,7 +163,7 @@ class LoggingInterceptor extends Interceptor { _logPrintResponse('║'); _printResponse(_logPrintResponse, response); _logPrintResponse('║'); - _printLine(_logPrintResponse, '╚'); + _logPrintResponse('╚'); } super.onResponse(response, handler); } diff --git a/packages/stream_chat/lib/src/core/http/stream_http_client.dart b/packages/stream_chat/lib/src/core/http/stream_http_client.dart index 7052ce384..4a13fbaf5 100644 --- a/packages/stream_chat/lib/src/core/http/stream_http_client.dart +++ b/packages/stream_chat/lib/src/core/http/stream_http_client.dart @@ -29,8 +29,8 @@ class StreamHttpClient { httpClient = dio ?? Dio() { httpClient ..options.baseUrl = _options.baseUrl - ..options.receiveTimeout = _options.receiveTimeout.inMilliseconds - ..options.connectTimeout = _options.connectTimeout.inMilliseconds + ..options.receiveTimeout = _options.receiveTimeout + ..options.connectTimeout = _options.connectTimeout ..options.queryParameters = { 'api_key': apiKey, ..._options.queryParameters, diff --git a/packages/stream_chat/lib/src/core/models/attachment_file.freezed.dart b/packages/stream_chat/lib/src/core/models/attachment_file.freezed.dart index f0ccc584c..9a0f3d1c0 100644 --- a/packages/stream_chat/lib/src/core/models/attachment_file.freezed.dart +++ b/packages/stream_chat/lib/src/core/models/attachment_file.freezed.dart @@ -1,7 +1,7 @@ // coverage:ignore-file // GENERATED CODE - DO NOT MODIFY BY HAND // ignore_for_file: type=lint -// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark part of 'attachment_file.dart'; @@ -43,10 +43,10 @@ mixin _$UploadState { throw _privateConstructorUsedError; @optionalTypeArgs TResult? whenOrNull({ - TResult Function()? preparing, - TResult Function(int uploaded, int total)? inProgress, - TResult Function()? success, - TResult Function(String error)? failed, + TResult? Function()? preparing, + TResult? Function(int uploaded, int total)? inProgress, + TResult? Function()? success, + TResult? Function(String error)? failed, }) => throw _privateConstructorUsedError; @optionalTypeArgs @@ -68,10 +68,10 @@ mixin _$UploadState { throw _privateConstructorUsedError; @optionalTypeArgs TResult? mapOrNull({ - TResult Function(Preparing value)? preparing, - TResult Function(InProgress value)? inProgress, - TResult Function(Success value)? success, - TResult Function(Failed value)? failed, + TResult? Function(Preparing value)? preparing, + TResult? Function(InProgress value)? inProgress, + TResult? Function(Success value)? success, + TResult? Function(Failed value)? failed, }) => throw _privateConstructorUsedError; @optionalTypeArgs @@ -90,16 +90,18 @@ mixin _$UploadState { abstract class $UploadStateCopyWith<$Res> { factory $UploadStateCopyWith( UploadState value, $Res Function(UploadState) then) = - _$UploadStateCopyWithImpl<$Res>; + _$UploadStateCopyWithImpl<$Res, UploadState>; } /// @nodoc -class _$UploadStateCopyWithImpl<$Res> implements $UploadStateCopyWith<$Res> { +class _$UploadStateCopyWithImpl<$Res, $Val extends UploadState> + implements $UploadStateCopyWith<$Res> { _$UploadStateCopyWithImpl(this._value, this._then); - final UploadState _value; // ignore: unused_field - final $Res Function(UploadState) _then; + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; } /// @nodoc @@ -110,14 +112,12 @@ abstract class _$$PreparingCopyWith<$Res> { } /// @nodoc -class __$$PreparingCopyWithImpl<$Res> extends _$UploadStateCopyWithImpl<$Res> +class __$$PreparingCopyWithImpl<$Res> + extends _$UploadStateCopyWithImpl<$Res, _$Preparing> implements _$$PreparingCopyWith<$Res> { __$$PreparingCopyWithImpl( _$Preparing _value, $Res Function(_$Preparing) _then) - : super(_value, (v) => _then(v as _$Preparing)); - - @override - _$Preparing get _value => super._value as _$Preparing; + : super(_value, _then); } /// @nodoc @@ -162,10 +162,10 @@ class _$Preparing extends Preparing { @override @optionalTypeArgs TResult? whenOrNull({ - TResult Function()? preparing, - TResult Function(int uploaded, int total)? inProgress, - TResult Function()? success, - TResult Function(String error)? failed, + TResult? Function()? preparing, + TResult? Function(int uploaded, int total)? inProgress, + TResult? Function()? success, + TResult? Function(String error)? failed, }) { return preparing?.call(); } @@ -199,10 +199,10 @@ class _$Preparing extends Preparing { @override @optionalTypeArgs TResult? mapOrNull({ - TResult Function(Preparing value)? preparing, - TResult Function(InProgress value)? inProgress, - TResult Function(Success value)? success, - TResult Function(Failed value)? failed, + TResult? Function(Preparing value)? preparing, + TResult? Function(InProgress value)? inProgress, + TResult? Function(Success value)? success, + TResult? Function(Failed value)? failed, }) { return preparing?.call(this); } @@ -242,30 +242,30 @@ abstract class _$$InProgressCopyWith<$Res> { factory _$$InProgressCopyWith( _$InProgress value, $Res Function(_$InProgress) then) = __$$InProgressCopyWithImpl<$Res>; + @useResult $Res call({int uploaded, int total}); } /// @nodoc -class __$$InProgressCopyWithImpl<$Res> extends _$UploadStateCopyWithImpl<$Res> +class __$$InProgressCopyWithImpl<$Res> + extends _$UploadStateCopyWithImpl<$Res, _$InProgress> implements _$$InProgressCopyWith<$Res> { __$$InProgressCopyWithImpl( _$InProgress _value, $Res Function(_$InProgress) _then) - : super(_value, (v) => _then(v as _$InProgress)); - - @override - _$InProgress get _value => super._value as _$InProgress; + : super(_value, _then); + @pragma('vm:prefer-inline') @override $Res call({ - Object? uploaded = freezed, - Object? total = freezed, + Object? uploaded = null, + Object? total = null, }) { return _then(_$InProgress( - uploaded: uploaded == freezed + uploaded: null == uploaded ? _value.uploaded : uploaded // ignore: cast_nullable_to_non_nullable as int, - total: total == freezed + total: null == total ? _value.total : total // ignore: cast_nullable_to_non_nullable as int, @@ -302,19 +302,18 @@ class _$InProgress extends InProgress { return identical(this, other) || (other.runtimeType == runtimeType && other is _$InProgress && - const DeepCollectionEquality().equals(other.uploaded, uploaded) && - const DeepCollectionEquality().equals(other.total, total)); + (identical(other.uploaded, uploaded) || + other.uploaded == uploaded) && + (identical(other.total, total) || other.total == total)); } @JsonKey(ignore: true) @override - int get hashCode => Object.hash( - runtimeType, - const DeepCollectionEquality().hash(uploaded), - const DeepCollectionEquality().hash(total)); + int get hashCode => Object.hash(runtimeType, uploaded, total); @JsonKey(ignore: true) @override + @pragma('vm:prefer-inline') _$$InProgressCopyWith<_$InProgress> get copyWith => __$$InProgressCopyWithImpl<_$InProgress>(this, _$identity); @@ -332,10 +331,10 @@ class _$InProgress extends InProgress { @override @optionalTypeArgs TResult? whenOrNull({ - TResult Function()? preparing, - TResult Function(int uploaded, int total)? inProgress, - TResult Function()? success, - TResult Function(String error)? failed, + TResult? Function()? preparing, + TResult? Function(int uploaded, int total)? inProgress, + TResult? Function()? success, + TResult? Function(String error)? failed, }) { return inProgress?.call(uploaded, total); } @@ -369,10 +368,10 @@ class _$InProgress extends InProgress { @override @optionalTypeArgs TResult? mapOrNull({ - TResult Function(Preparing value)? preparing, - TResult Function(InProgress value)? inProgress, - TResult Function(Success value)? success, - TResult Function(Failed value)? failed, + TResult? Function(Preparing value)? preparing, + TResult? Function(InProgress value)? inProgress, + TResult? Function(Success value)? success, + TResult? Function(Failed value)? failed, }) { return inProgress?.call(this); } @@ -422,13 +421,11 @@ abstract class _$$SuccessCopyWith<$Res> { } /// @nodoc -class __$$SuccessCopyWithImpl<$Res> extends _$UploadStateCopyWithImpl<$Res> +class __$$SuccessCopyWithImpl<$Res> + extends _$UploadStateCopyWithImpl<$Res, _$Success> implements _$$SuccessCopyWith<$Res> { __$$SuccessCopyWithImpl(_$Success _value, $Res Function(_$Success) _then) - : super(_value, (v) => _then(v as _$Success)); - - @override - _$Success get _value => super._value as _$Success; + : super(_value, _then); } /// @nodoc @@ -473,10 +470,10 @@ class _$Success extends Success { @override @optionalTypeArgs TResult? whenOrNull({ - TResult Function()? preparing, - TResult Function(int uploaded, int total)? inProgress, - TResult Function()? success, - TResult Function(String error)? failed, + TResult? Function()? preparing, + TResult? Function(int uploaded, int total)? inProgress, + TResult? Function()? success, + TResult? Function(String error)? failed, }) { return success?.call(); } @@ -510,10 +507,10 @@ class _$Success extends Success { @override @optionalTypeArgs TResult? mapOrNull({ - TResult Function(Preparing value)? preparing, - TResult Function(InProgress value)? inProgress, - TResult Function(Success value)? success, - TResult Function(Failed value)? failed, + TResult? Function(Preparing value)? preparing, + TResult? Function(InProgress value)? inProgress, + TResult? Function(Success value)? success, + TResult? Function(Failed value)? failed, }) { return success?.call(this); } @@ -552,24 +549,24 @@ abstract class Success extends UploadState { abstract class _$$FailedCopyWith<$Res> { factory _$$FailedCopyWith(_$Failed value, $Res Function(_$Failed) then) = __$$FailedCopyWithImpl<$Res>; + @useResult $Res call({String error}); } /// @nodoc -class __$$FailedCopyWithImpl<$Res> extends _$UploadStateCopyWithImpl<$Res> +class __$$FailedCopyWithImpl<$Res> + extends _$UploadStateCopyWithImpl<$Res, _$Failed> implements _$$FailedCopyWith<$Res> { __$$FailedCopyWithImpl(_$Failed _value, $Res Function(_$Failed) _then) - : super(_value, (v) => _then(v as _$Failed)); - - @override - _$Failed get _value => super._value as _$Failed; + : super(_value, _then); + @pragma('vm:prefer-inline') @override $Res call({ - Object? error = freezed, + Object? error = null, }) { return _then(_$Failed( - error: error == freezed + error: null == error ? _value.error : error // ignore: cast_nullable_to_non_nullable as String, @@ -603,16 +600,16 @@ class _$Failed extends Failed { return identical(this, other) || (other.runtimeType == runtimeType && other is _$Failed && - const DeepCollectionEquality().equals(other.error, error)); + (identical(other.error, error) || other.error == error)); } @JsonKey(ignore: true) @override - int get hashCode => - Object.hash(runtimeType, const DeepCollectionEquality().hash(error)); + int get hashCode => Object.hash(runtimeType, error); @JsonKey(ignore: true) @override + @pragma('vm:prefer-inline') _$$FailedCopyWith<_$Failed> get copyWith => __$$FailedCopyWithImpl<_$Failed>(this, _$identity); @@ -630,10 +627,10 @@ class _$Failed extends Failed { @override @optionalTypeArgs TResult? whenOrNull({ - TResult Function()? preparing, - TResult Function(int uploaded, int total)? inProgress, - TResult Function()? success, - TResult Function(String error)? failed, + TResult? Function()? preparing, + TResult? Function(int uploaded, int total)? inProgress, + TResult? Function()? success, + TResult? Function(String error)? failed, }) { return failed?.call(error); } @@ -667,10 +664,10 @@ class _$Failed extends Failed { @override @optionalTypeArgs TResult? mapOrNull({ - TResult Function(Preparing value)? preparing, - TResult Function(InProgress value)? inProgress, - TResult Function(Success value)? success, - TResult Function(Failed value)? failed, + TResult? Function(Preparing value)? preparing, + TResult? Function(InProgress value)? inProgress, + TResult? Function(Success value)? success, + TResult? Function(Failed value)? failed, }) { return failed?.call(this); } diff --git a/packages/stream_chat/lib/src/core/models/channel_model.g.dart b/packages/stream_chat/lib/src/core/models/channel_model.g.dart index 9bd8f062e..d86c2941f 100644 --- a/packages/stream_chat/lib/src/core/models/channel_model.g.dart +++ b/packages/stream_chat/lib/src/core/models/channel_model.g.dart @@ -38,30 +38,21 @@ ChannelModel _$ChannelModelFromJson(Map json) => ChannelModel( cooldown: json['cooldown'] as int? ?? 0, ); -Map _$ChannelModelToJson(ChannelModel instance) { - final val = { - 'id': instance.id, - 'type': instance.type, - }; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('cid', readonly(instance.cid)); - writeNotNull('own_capabilities', readonly(instance.ownCapabilities)); - writeNotNull('config', readonly(instance.config)); - writeNotNull('created_by', readonly(instance.createdBy)); - val['frozen'] = instance.frozen; - writeNotNull('last_message_at', readonly(instance.lastMessageAt)); - writeNotNull('created_at', readonly(instance.createdAt)); - writeNotNull('updated_at', readonly(instance.updatedAt)); - writeNotNull('deleted_at', readonly(instance.deletedAt)); - writeNotNull('member_count', readonly(instance.memberCount)); - val['cooldown'] = instance.cooldown; - val['extra_data'] = instance.extraData; - writeNotNull('team', readonly(instance.team)); - return val; -} +Map _$ChannelModelToJson(ChannelModel instance) => + { + 'id': instance.id, + 'type': instance.type, + 'cid': readonly(instance.cid), + 'own_capabilities': readonly(instance.ownCapabilities), + 'config': readonly(instance.config), + 'created_by': readonly(instance.createdBy), + 'frozen': instance.frozen, + 'last_message_at': readonly(instance.lastMessageAt), + 'created_at': readonly(instance.createdAt), + 'updated_at': readonly(instance.updatedAt), + 'deleted_at': readonly(instance.deletedAt), + 'member_count': readonly(instance.memberCount), + 'cooldown': instance.cooldown, + 'extra_data': instance.extraData, + 'team': readonly(instance.team), + }; diff --git a/packages/stream_chat/lib/src/core/models/message.g.dart b/packages/stream_chat/lib/src/core/models/message.g.dart index e2ff89b49..8023cb793 100644 --- a/packages/stream_chat/lib/src/core/models/message.g.dart +++ b/packages/stream_chat/lib/src/core/models/message.g.dart @@ -75,6 +75,31 @@ Map _$MessageToJson(Message instance) { final val = { 'id': instance.id, 'text': instance.text, + 'type': readonly(instance.type), + 'attachments': instance.attachments.map((e) => e.toJson()).toList(), + 'mentioned_users': User.toIds(instance.mentionedUsers), + 'reaction_counts': readonly(instance.reactionCounts), + 'reaction_scores': readonly(instance.reactionScores), + 'latest_reactions': readonly(instance.latestReactions), + 'own_reactions': readonly(instance.ownReactions), + 'parent_id': instance.parentId, + 'quoted_message': readonly(instance.quotedMessage), + 'quoted_message_id': instance.quotedMessageId, + 'reply_count': readonly(instance.replyCount), + 'thread_participants': readonly(instance.threadParticipants), + 'show_in_channel': instance.showInChannel, + 'silent': instance.silent, + 'shadowed': readonly(instance.shadowed), + 'command': readonly(instance.command), + 'deleted_at': readonly(instance.deletedAt), + 'created_at': readonly(instance.createdAt), + 'updated_at': readonly(instance.updatedAt), + 'user': readonly(instance.user), + 'pinned': instance.pinned, + 'pinned_at': readonly(instance.pinnedAt), + 'pin_expires': instance.pinExpires?.toIso8601String(), + 'pinned_by': readonly(instance.pinnedBy), + 'extra_data': instance.extraData, }; void writeNotNull(String key, dynamic value) { @@ -83,31 +108,6 @@ Map _$MessageToJson(Message instance) { } } - writeNotNull('type', readonly(instance.type)); - val['attachments'] = instance.attachments.map((e) => e.toJson()).toList(); - val['mentioned_users'] = User.toIds(instance.mentionedUsers); - writeNotNull('reaction_counts', readonly(instance.reactionCounts)); - writeNotNull('reaction_scores', readonly(instance.reactionScores)); - writeNotNull('latest_reactions', readonly(instance.latestReactions)); - writeNotNull('own_reactions', readonly(instance.ownReactions)); - val['parent_id'] = instance.parentId; - val['quoted_message'] = readonly(instance.quotedMessage); - val['quoted_message_id'] = instance.quotedMessageId; - writeNotNull('reply_count', readonly(instance.replyCount)); - writeNotNull('thread_participants', readonly(instance.threadParticipants)); - val['show_in_channel'] = instance.showInChannel; - val['silent'] = instance.silent; - writeNotNull('shadowed', readonly(instance.shadowed)); - writeNotNull('command', readonly(instance.command)); - writeNotNull('deleted_at', readonly(instance.deletedAt)); - writeNotNull('created_at', readonly(instance.createdAt)); - writeNotNull('updated_at', readonly(instance.updatedAt)); - writeNotNull('user', readonly(instance.user)); - val['pinned'] = instance.pinned; - val['pinned_at'] = readonly(instance.pinnedAt); - val['pin_expires'] = instance.pinExpires?.toIso8601String(); - val['pinned_by'] = readonly(instance.pinnedBy); - val['extra_data'] = instance.extraData; writeNotNull('i18n', instance.i18n); return val; } diff --git a/packages/stream_chat/lib/src/core/models/reaction.g.dart b/packages/stream_chat/lib/src/core/models/reaction.g.dart index 3554106d0..c669e8502 100644 --- a/packages/stream_chat/lib/src/core/models/reaction.g.dart +++ b/packages/stream_chat/lib/src/core/models/reaction.g.dart @@ -20,22 +20,12 @@ Reaction _$ReactionFromJson(Map json) => Reaction( extraData: json['extra_data'] as Map? ?? const {}, ); -Map _$ReactionToJson(Reaction instance) { - final val = { - 'message_id': instance.messageId, - 'type': instance.type, - }; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('created_at', readonly(instance.createdAt)); - writeNotNull('user', readonly(instance.user)); - val['score'] = instance.score; - writeNotNull('user_id', readonly(instance.userId)); - val['extra_data'] = instance.extraData; - return val; -} +Map _$ReactionToJson(Reaction instance) => { + 'message_id': instance.messageId, + 'type': instance.type, + 'created_at': readonly(instance.createdAt), + 'user': readonly(instance.user), + 'score': instance.score, + 'user_id': readonly(instance.userId), + 'extra_data': instance.extraData, + }; diff --git a/packages/stream_chat/lib/src/core/models/user.g.dart b/packages/stream_chat/lib/src/core/models/user.g.dart index 9e6ae3dce..3736cad1b 100644 --- a/packages/stream_chat/lib/src/core/models/user.g.dart +++ b/packages/stream_chat/lib/src/core/models/user.g.dart @@ -33,6 +33,14 @@ User _$UserFromJson(Map json) => User( Map _$UserToJson(User instance) { final val = { 'id': instance.id, + 'role': readonly(instance.role), + 'teams': readonly(instance.teams), + 'created_at': readonly(instance.createdAt), + 'updated_at': readonly(instance.updatedAt), + 'last_active': readonly(instance.lastActive), + 'online': readonly(instance.online), + 'banned': readonly(instance.banned), + 'ban_expires': readonly(instance.banExpires), }; void writeNotNull(String key, dynamic value) { @@ -41,14 +49,6 @@ Map _$UserToJson(User instance) { } } - writeNotNull('role', readonly(instance.role)); - writeNotNull('teams', readonly(instance.teams)); - writeNotNull('created_at', readonly(instance.createdAt)); - writeNotNull('updated_at', readonly(instance.updatedAt)); - writeNotNull('last_active', readonly(instance.lastActive)); - writeNotNull('online', readonly(instance.online)); - writeNotNull('banned', readonly(instance.banned)); - writeNotNull('ban_expires', readonly(instance.banExpires)); writeNotNull('language', instance.language); val['extra_data'] = instance.extraData; return val; diff --git a/packages/stream_chat/pubspec.yaml b/packages/stream_chat/pubspec.yaml index 67eb5a21d..fe2bfe002 100644 --- a/packages/stream_chat/pubspec.yaml +++ b/packages/stream_chat/pubspec.yaml @@ -9,26 +9,26 @@ environment: sdk: '>=2.17.0 <3.0.0' dependencies: - async: ^2.5.0 - collection: ^1.15.0 - dio: ^4.0.0 - equatable: ^2.0.0 - freezed_annotation: ^2.0.3 - http_parser: ^4.0.0 - jose: ^0.3.2 - json_annotation: ^4.5.0 - logging: ^1.0.1 - meta: ^1.3.0 - mime: ^1.0.0 + async: ^2.10.0 + collection: ^1.17.0 + dio: ^5.1.1 + equatable: ^2.0.5 + freezed_annotation: ^2.2.0 + http_parser: ^4.0.2 + jose: ^0.3.3 + json_annotation: ^4.8.0 + logging: ^1.1.1 + meta: ^1.8.0 + mime: ^1.0.4 rate_limiter: ^1.0.0 - rxdart: ^0.27.0 - uuid: ^3.0.4 - web_socket_channel: ^2.0.0 + rxdart: ^0.27.7 + uuid: ^3.0.7 + web_socket_channel: ^2.3.0 dev_dependencies: - build_runner: ^2.0.1 - dart_code_metrics: ^4.4.0 - freezed: ^2.0.3 - json_serializable: ^6.2.0 + build_runner: ^2.3.3 + dart_code_metrics: ^5.7.0 + freezed: ^2.3.2 + json_serializable: ^6.6.1 mocktail: ^0.3.0 - test: ^1.17.12 + test: ^1.24.1 diff --git a/packages/stream_chat_flutter/example/pubspec.yaml b/packages/stream_chat_flutter/example/pubspec.yaml index c9fc3f0ad..defb72573 100644 --- a/packages/stream_chat_flutter/example/pubspec.yaml +++ b/packages/stream_chat_flutter/example/pubspec.yaml @@ -19,6 +19,7 @@ version: 1.0.0+1 environment: sdk: '>=2.17.0 <3.0.0' + flutter: ">=1.17.0" dependencies: # The following adds the Cupertino Icons font to your application. @@ -27,7 +28,7 @@ dependencies: cupertino_icons: ^1.0.4 flutter: sdk: flutter - responsive_builder: ^0.4.2 + responsive_builder: ^0.6.4 stream_chat_flutter: path: ../ stream_chat_localizations: diff --git a/packages/stream_chat_flutter/pubspec.yaml b/packages/stream_chat_flutter/pubspec.yaml index 8bc6e544e..d67aa740d 100644 --- a/packages/stream_chat_flutter/pubspec.yaml +++ b/packages/stream_chat_flutter/pubspec.yaml @@ -12,12 +12,11 @@ environment: dependencies: cached_network_image: ^3.0.0 chewie: ^1.3.4 - collection: ^1.15.0 + collection: ^1.17.0 contextmenu: ^3.0.0 dart_vlc: ^0.4.0 desktop_drop: ^0.4.0 diacritic: ^0.1.3 - dio: ^4.0.6 ezanimation: ^0.6.0 file_picker: ^5.2.4 file_selector: ^0.9.0 @@ -25,14 +24,13 @@ dependencies: sdk: flutter flutter_markdown: ^0.6.1 flutter_portal: ^1.0.0 - flutter_svg: ^1.0.1 - http: ^0.13.4 + flutter_svg: ^2.0.4 http_parser: ^4.0.0 image_gallery_saver: ^1.7.1 image_picker: ^0.8.2 jiffy: ^5.0.0 lottie: ^2.0.0 - meta: ^1.3.0 + meta: ^1.8.0 path_provider: ^2.0.9 photo_manager: ^2.5.2 photo_view: ^0.14.0 @@ -44,7 +42,7 @@ dependencies: thumblr: ^0.0.4 url_launcher: ^6.1.0 video_player: ^2.4.5 - video_player_macos: ^1.0.6 + video_player_macos: ^2.0.1 video_thumbnail: ^0.5.0 flutter: @@ -56,9 +54,9 @@ flutter: uses-material-design: true dev_dependencies: - dart_code_metrics: ^4.4.0 + dart_code_metrics: ^5.7.0 flutter_test: sdk: flutter - golden_toolkit: ^0.13.0 + golden_toolkit: ^0.15.0 mocktail: ^0.3.0 - path: ^1.8.0 + path: ^1.8.2 diff --git a/packages/stream_chat_flutter_core/example/pubspec.yaml b/packages/stream_chat_flutter_core/example/pubspec.yaml index 7cd391bc4..0abc0cdc0 100644 --- a/packages/stream_chat_flutter_core/example/pubspec.yaml +++ b/packages/stream_chat_flutter_core/example/pubspec.yaml @@ -19,6 +19,7 @@ version: 1.0.0+1 environment: sdk: '>=2.17.0 <3.0.0' + flutter: ">=1.17.0" dependencies: # The following adds the Cupertino Icons font to your application. @@ -27,6 +28,7 @@ dependencies: flutter: sdk: flutter stream_chat_flutter_core: ^5.1.0 + dev_dependencies: flutter_test: sdk: flutter diff --git a/packages/stream_chat_flutter_core/lib/src/paged_value_notifier.dart b/packages/stream_chat_flutter_core/lib/src/paged_value_notifier.dart index c122be1df..0209c223c 100644 --- a/packages/stream_chat_flutter_core/lib/src/paged_value_notifier.dart +++ b/packages/stream_chat_flutter_core/lib/src/paged_value_notifier.dart @@ -83,7 +83,7 @@ abstract class PagedValueNotifier /// Paged value that can be used with [PagedValueNotifier]. @freezed -abstract class PagedValue with _$PagedValue { +class PagedValue with _$PagedValue { /// Represents the success state of the [PagedValue] // @Assert( // 'nextPageKey != null', diff --git a/packages/stream_chat_flutter_core/lib/src/paged_value_notifier.freezed.dart b/packages/stream_chat_flutter_core/lib/src/paged_value_notifier.freezed.dart index 9e3255310..4a85ff07f 100644 --- a/packages/stream_chat_flutter_core/lib/src/paged_value_notifier.freezed.dart +++ b/packages/stream_chat_flutter_core/lib/src/paged_value_notifier.freezed.dart @@ -1,7 +1,7 @@ // coverage:ignore-file // GENERATED CODE - DO NOT MODIFY BY HAND // ignore_for_file: type=lint -// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark part of 'paged_value_notifier.dart'; @@ -27,11 +27,11 @@ mixin _$PagedValue { throw _privateConstructorUsedError; @optionalTypeArgs TResult? whenOrNull( - TResult Function( + TResult? Function( List items, Key? nextPageKey, StreamChatError? error)? $default, { - TResult Function()? loading, - TResult Function(StreamChatError error)? error, + TResult? Function()? loading, + TResult? Function(StreamChatError error)? error, }) => throw _privateConstructorUsedError; @optionalTypeArgs @@ -53,9 +53,9 @@ mixin _$PagedValue { throw _privateConstructorUsedError; @optionalTypeArgs TResult? mapOrNull( - TResult Function(Success value)? $default, { - TResult Function(Loading value)? loading, - TResult Function(Error value)? error, + TResult? Function(Success value)? $default, { + TResult? Function(Loading value)? loading, + TResult? Function(Error value)? error, }) => throw _privateConstructorUsedError; @optionalTypeArgs @@ -72,17 +72,19 @@ mixin _$PagedValue { abstract class $PagedValueCopyWith { factory $PagedValueCopyWith(PagedValue value, $Res Function(PagedValue) then) = - _$PagedValueCopyWithImpl; + _$PagedValueCopyWithImpl>; } /// @nodoc -class _$PagedValueCopyWithImpl +class _$PagedValueCopyWithImpl> implements $PagedValueCopyWith { _$PagedValueCopyWithImpl(this._value, this._then); - final PagedValue _value; // ignore: unused_field - final $Res Function(PagedValue) _then; + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; } /// @nodoc @@ -90,36 +92,35 @@ abstract class _$$SuccessCopyWith { factory _$$SuccessCopyWith(_$Success value, $Res Function(_$Success) then) = __$$SuccessCopyWithImpl; + @useResult $Res call({List items, Key? nextPageKey, StreamChatError? error}); } /// @nodoc class __$$SuccessCopyWithImpl - extends _$PagedValueCopyWithImpl + extends _$PagedValueCopyWithImpl> implements _$$SuccessCopyWith { __$$SuccessCopyWithImpl( _$Success _value, $Res Function(_$Success) _then) - : super(_value, (v) => _then(v as _$Success)); - - @override - _$Success get _value => super._value as _$Success; + : super(_value, _then); + @pragma('vm:prefer-inline') @override $Res call({ - Object? items = freezed, + Object? items = null, Object? nextPageKey = freezed, Object? error = freezed, }) { return _then(_$Success( - items: items == freezed + items: null == items ? _value._items : items // ignore: cast_nullable_to_non_nullable as List, - nextPageKey: nextPageKey == freezed + nextPageKey: freezed == nextPageKey ? _value.nextPageKey : nextPageKey // ignore: cast_nullable_to_non_nullable as Key?, - error: error == freezed + error: freezed == error ? _value.error : error // ignore: cast_nullable_to_non_nullable as StreamChatError?, @@ -142,6 +143,7 @@ class _$Success extends Success /// List with all items loaded so far. @override List get items { + if (_items is EqualUnmodifiableListView) return _items; // ignore: implicit_dynamic_type return EqualUnmodifiableListView(_items); } @@ -177,7 +179,7 @@ class _$Success extends Success const DeepCollectionEquality().equals(other._items, _items) && const DeepCollectionEquality() .equals(other.nextPageKey, nextPageKey) && - const DeepCollectionEquality().equals(other.error, error)); + (identical(other.error, error) || other.error == error)); } @override @@ -185,10 +187,11 @@ class _$Success extends Success runtimeType, const DeepCollectionEquality().hash(_items), const DeepCollectionEquality().hash(nextPageKey), - const DeepCollectionEquality().hash(error)); + error); @JsonKey(ignore: true) @override + @pragma('vm:prefer-inline') _$$SuccessCopyWith> get copyWith => __$$SuccessCopyWithImpl>( this, _$identity); @@ -208,11 +211,11 @@ class _$Success extends Success @override @optionalTypeArgs TResult? whenOrNull( - TResult Function( + TResult? Function( List items, Key? nextPageKey, StreamChatError? error)? $default, { - TResult Function()? loading, - TResult Function(StreamChatError error)? error, + TResult? Function()? loading, + TResult? Function(StreamChatError error)? error, }) { return $default?.call(items, nextPageKey, this.error); } @@ -246,9 +249,9 @@ class _$Success extends Success @override @optionalTypeArgs TResult? mapOrNull( - TResult Function(Success value)? $default, { - TResult Function(Loading value)? loading, - TResult Function(Error value)? error, + TResult? Function(Success value)? $default, { + TResult? Function(Loading value)? loading, + TResult? Function(Error value)? error, }) { return $default?.call(this); } @@ -276,13 +279,13 @@ abstract class Success extends PagedValue { const Success._() : super._(); /// List with all items loaded so far. - List get items => throw _privateConstructorUsedError; + List get items; /// The key for the next page to be fetched. - Key? get nextPageKey => throw _privateConstructorUsedError; + Key? get nextPageKey; /// The current error, if any. - StreamChatError? get error => throw _privateConstructorUsedError; + StreamChatError? get error; @JsonKey(ignore: true) _$$SuccessCopyWith> get copyWith => throw _privateConstructorUsedError; @@ -297,14 +300,11 @@ abstract class _$$LoadingCopyWith { /// @nodoc class __$$LoadingCopyWithImpl - extends _$PagedValueCopyWithImpl + extends _$PagedValueCopyWithImpl> implements _$$LoadingCopyWith { __$$LoadingCopyWithImpl( _$Loading _value, $Res Function(_$Loading) _then) - : super(_value, (v) => _then(v as _$Loading)); - - @override - _$Loading get _value => super._value as _$Loading; + : super(_value, _then); } /// @nodoc @@ -349,11 +349,11 @@ class _$Loading extends Loading @override @optionalTypeArgs TResult? whenOrNull( - TResult Function( + TResult? Function( List items, Key? nextPageKey, StreamChatError? error)? $default, { - TResult Function()? loading, - TResult Function(StreamChatError error)? error, + TResult? Function()? loading, + TResult? Function(StreamChatError error)? error, }) { return loading?.call(); } @@ -387,9 +387,9 @@ class _$Loading extends Loading @override @optionalTypeArgs TResult? mapOrNull( - TResult Function(Success value)? $default, { - TResult Function(Loading value)? loading, - TResult Function(Error value)? error, + TResult? Function(Success value)? $default, { + TResult? Function(Loading value)? loading, + TResult? Function(Error value)? error, }) { return loading?.call(this); } @@ -419,26 +419,25 @@ abstract class _$$ErrorCopyWith { factory _$$ErrorCopyWith( _$Error value, $Res Function(_$Error) then) = __$$ErrorCopyWithImpl; + @useResult $Res call({StreamChatError error}); } /// @nodoc class __$$ErrorCopyWithImpl - extends _$PagedValueCopyWithImpl + extends _$PagedValueCopyWithImpl> implements _$$ErrorCopyWith { __$$ErrorCopyWithImpl( _$Error _value, $Res Function(_$Error) _then) - : super(_value, (v) => _then(v as _$Error)); - - @override - _$Error get _value => super._value as _$Error; + : super(_value, _then); + @pragma('vm:prefer-inline') @override $Res call({ - Object? error = freezed, + Object? error = null, }) { return _then(_$Error( - error == freezed + null == error ? _value.error : error // ignore: cast_nullable_to_non_nullable as StreamChatError, @@ -473,15 +472,15 @@ class _$Error extends Error return identical(this, other) || (other.runtimeType == runtimeType && other is _$Error && - const DeepCollectionEquality().equals(other.error, error)); + (identical(other.error, error) || other.error == error)); } @override - int get hashCode => - Object.hash(runtimeType, const DeepCollectionEquality().hash(error)); + int get hashCode => Object.hash(runtimeType, error); @JsonKey(ignore: true) @override + @pragma('vm:prefer-inline') _$$ErrorCopyWith> get copyWith => __$$ErrorCopyWithImpl>(this, _$identity); @@ -500,11 +499,11 @@ class _$Error extends Error @override @optionalTypeArgs TResult? whenOrNull( - TResult Function( + TResult? Function( List items, Key? nextPageKey, StreamChatError? error)? $default, { - TResult Function()? loading, - TResult Function(StreamChatError error)? error, + TResult? Function()? loading, + TResult? Function(StreamChatError error)? error, }) { return error?.call(this.error); } @@ -538,9 +537,9 @@ class _$Error extends Error @override @optionalTypeArgs TResult? mapOrNull( - TResult Function(Success value)? $default, { - TResult Function(Loading value)? loading, - TResult Function(Error value)? error, + TResult? Function(Success value)? $default, { + TResult? Function(Loading value)? loading, + TResult? Function(Error value)? error, }) { return error?.call(this); } @@ -564,7 +563,7 @@ abstract class Error extends PagedValue { const factory Error(final StreamChatError error) = _$Error; const Error._() : super._(); - StreamChatError get error => throw _privateConstructorUsedError; + StreamChatError get error; @JsonKey(ignore: true) _$$ErrorCopyWith> get copyWith => throw _privateConstructorUsedError; diff --git a/packages/stream_chat_flutter_core/lib/src/stream_channel.dart b/packages/stream_chat_flutter_core/lib/src/stream_channel.dart index bf37aa11f..9842c3e2a 100644 --- a/packages/stream_chat_flutter_core/lib/src/stream_channel.dart +++ b/packages/stream_chat_flutter_core/lib/src/stream_channel.dart @@ -425,8 +425,8 @@ class StreamChannelState extends State { var message = snapshot.error.toString(); if (snapshot.error is DioError) { final dioError = snapshot.error as DioError?; - if (dioError?.type == DioErrorType.response) { - message = dioError!.message; + if (dioError?.type == DioErrorType.badResponse) { + message = dioError!.message ?? 'Bad response'; } else { message = 'Check your connection and retry'; } diff --git a/packages/stream_chat_flutter_core/pubspec.yaml b/packages/stream_chat_flutter_core/pubspec.yaml index 81fbe3197..78a3e813c 100644 --- a/packages/stream_chat_flutter_core/pubspec.yaml +++ b/packages/stream_chat_flutter_core/pubspec.yaml @@ -10,20 +10,21 @@ environment: flutter: ">=1.17.0" dependencies: - collection: ^1.15.0 + collection: ^1.17.0 connectivity_plus: ^3.0.2 flutter: sdk: flutter freezed_annotation: ^2.0.3 - meta: ^1.3.0 + meta: ^1.8.0 rxdart: ^0.27.0 stream_chat: ^5.3.0 + dev_dependencies: - build_runner: ^2.0.1 - dart_code_metrics: ^4.4.0 + build_runner: ^2.3.3 + dart_code_metrics: ^5.7.0 fake_async: ^1.2.0 flutter_test: sdk: flutter - freezed: ^2.0.3 + freezed: ^2.3.2 mocktail: ^0.3.0 diff --git a/packages/stream_chat_flutter_core/test/stream_channel_test.dart b/packages/stream_chat_flutter_core/test/stream_channel_test.dart index 86ce7c2be..875b885d5 100644 --- a/packages/stream_chat_flutter_core/test/stream_channel_test.dart +++ b/packages/stream_chat_flutter_core/test/stream_channel_test.dart @@ -92,7 +92,7 @@ void main() { const errorMessage = 'Error! Error! Error!'; final error = DioError( - type: DioErrorType.response, + type: DioErrorType.badResponse, error: errorMessage, requestOptions: RequestOptions(path: ''), ); diff --git a/packages/stream_chat_localizations/pubspec.yaml b/packages/stream_chat_localizations/pubspec.yaml index ce2e5e3ac..7462a2872 100644 --- a/packages/stream_chat_localizations/pubspec.yaml +++ b/packages/stream_chat_localizations/pubspec.yaml @@ -15,6 +15,7 @@ dependencies: flutter_localizations: sdk: flutter stream_chat_flutter: ^5.3.0 + dev_dependencies: dart_code_metrics: ^4.16.0 flutter_test: diff --git a/packages/stream_chat_persistence/example/pubspec.yaml b/packages/stream_chat_persistence/example/pubspec.yaml index 435b14420..80a35fc75 100644 --- a/packages/stream_chat_persistence/example/pubspec.yaml +++ b/packages/stream_chat_persistence/example/pubspec.yaml @@ -6,6 +6,7 @@ version: 1.0.0+1 environment: sdk: '>=2.17.0 <3.0.0' + flutter: ">=1.17.0" dependencies: cupertino_icons: ^1.0.3 @@ -13,6 +14,7 @@ dependencies: sdk: flutter stream_chat: ^5.1.0 stream_chat_persistence: ^5.1.0 + dev_dependencies: flutter_test: sdk: flutter diff --git a/packages/stream_chat_persistence/pubspec.yaml b/packages/stream_chat_persistence/pubspec.yaml index dcdf8bd1c..5628688b9 100644 --- a/packages/stream_chat_persistence/pubspec.yaml +++ b/packages/stream_chat_persistence/pubspec.yaml @@ -10,20 +10,21 @@ environment: flutter: ">=1.17.0" dependencies: - drift: ^1.5.0 + drift: ^1.7.1 flutter: sdk: flutter logging: ^1.0.1 - meta: ^1.3.0 + meta: ^1.8.0 mutex: ^3.0.0 - path: ^1.8.0 + path: ^1.8.2 path_provider: ^2.0.1 sqlite3_flutter_libs: ^0.5.0 stream_chat: ^5.1.0 + dev_dependencies: - build_runner: ^2.0.1 - dart_code_metrics: ^4.4.0 - drift_dev: ^1.5.2 + build_runner: ^2.3.3 + dart_code_metrics: ^4.18.0 + drift_dev: ^1.7.1 flutter_test: sdk: flutter mocktail: ^0.3.0 diff --git a/pubspec.yaml b/pubspec.yaml new file mode 100644 index 000000000..9016fa8f7 --- /dev/null +++ b/pubspec.yaml @@ -0,0 +1,7 @@ +name: stream_chat_flutter_workspace + +environment: + sdk: '>=2.18.0 <3.0.0' + +dev_dependencies: + melos: ^3.0.0 From c771aa96d5b8003fed116438502ba2d13328378b Mon Sep 17 00:00:00 2001 From: Sahil Kumar Date: Mon, 3 Apr 2023 18:07:31 +0530 Subject: [PATCH 074/107] ci(repo): update melos version Signed-off-by: xsahil03x --- .github/workflows/dart_code_metrics.yaml | 3 +-- .github/workflows/stream_flutter_workflow.yml | 7 +++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/dart_code_metrics.yaml b/.github/workflows/dart_code_metrics.yaml index 9162b1a77..093747178 100644 --- a/.github/workflows/dart_code_metrics.yaml +++ b/.github/workflows/dart_code_metrics.yaml @@ -3,7 +3,6 @@ name: Dart Code Metrics env: flutter_version: "3.3.3" folders: "lib, test" - melos_version: "2.7.1" on: pull_request: @@ -34,7 +33,7 @@ jobs: flutter-version: ${{ env.flutter_version }} - name: "Install Tools" - run: flutter pub global activate melos ${{ env.melos_version }} + run: flutter pub global activate melos - name: "Bootstrap Workspace" run: melos bootstrap diff --git a/.github/workflows/stream_flutter_workflow.yml b/.github/workflows/stream_flutter_workflow.yml index 9de7ca4d5..5cfbce79d 100644 --- a/.github/workflows/stream_flutter_workflow.yml +++ b/.github/workflows/stream_flutter_workflow.yml @@ -3,7 +3,6 @@ name: stream_flutter_workflow env: ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true' flutter_version: "3.3.3" - melos_version: "2.7.1" on: pull_request: @@ -34,7 +33,7 @@ jobs: flutter-version: ${{ env.flutter_version }} - name: "Install Tools" run: | - flutter pub global activate melos ${{ env.melos_version }} + flutter pub global activate melos - name: "Bootstrap Workspace" run: melos bootstrap --verbose - name: "Dart Analyze" @@ -65,7 +64,7 @@ jobs: flutter-version: ${{ env.flutter_version }} - name: "Install Tools" run: | - flutter pub global activate melos ${{ env.melos_version }} + flutter pub global activate melos - name: "Bootstrap Workspace" run: melos bootstrap - name: "Melos Format" @@ -94,7 +93,7 @@ jobs: flutter-version: ${{ env.flutter_version }} - name: "Install Tools" run: | - flutter pub global activate melos ${{ env.melos_version }} + flutter pub global activate melos flutter pub global activate remove_from_coverage - name: "Bootstrap Workspace" run: melos bootstrap From ffb00d0309bf0b6489e04d7a1f9702702bc1e949 Mon Sep 17 00:00:00 2001 From: Sahil Kumar Date: Mon, 3 Apr 2023 18:13:45 +0530 Subject: [PATCH 075/107] ci(repo): update flutter version Signed-off-by: xsahil03x --- .github/workflows/dart_code_metrics.yaml | 2 +- .github/workflows/stream_flutter_workflow.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/dart_code_metrics.yaml b/.github/workflows/dart_code_metrics.yaml index 093747178..265ec8292 100644 --- a/.github/workflows/dart_code_metrics.yaml +++ b/.github/workflows/dart_code_metrics.yaml @@ -1,7 +1,7 @@ name: Dart Code Metrics env: - flutter_version: "3.3.3" + flutter_version: "3.7.0" folders: "lib, test" on: diff --git a/.github/workflows/stream_flutter_workflow.yml b/.github/workflows/stream_flutter_workflow.yml index 5cfbce79d..c979229e8 100644 --- a/.github/workflows/stream_flutter_workflow.yml +++ b/.github/workflows/stream_flutter_workflow.yml @@ -2,7 +2,7 @@ name: stream_flutter_workflow env: ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true' - flutter_version: "3.3.3" + flutter_version: "3.7.0" on: pull_request: From caec2647d3113ee07b349a278b86737401d6d7ed Mon Sep 17 00:00:00 2001 From: Sahil Kumar Date: Mon, 3 Apr 2023 18:19:17 +0530 Subject: [PATCH 076/107] chore(core): fix format Signed-off-by: xsahil03x --- .../lib/src/stream_channel_list_controller.dart | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/stream_chat_flutter_core/lib/src/stream_channel_list_controller.dart b/packages/stream_chat_flutter_core/lib/src/stream_channel_list_controller.dart index bc98780d8..71bc06947 100644 --- a/packages/stream_chat_flutter_core/lib/src/stream_channel_list_controller.dart +++ b/packages/stream_chat_flutter_core/lib/src/stream_channel_list_controller.dart @@ -244,10 +244,11 @@ class StreamChannelListController extends PagedValueNotifier { _unsubscribeFromChannelListEvents(); } - _channelEventSubscription = - client.on().skip(1) // Skipping the last emitted event. - // We only need to handle the latest events. - .listen((event) { + _channelEventSubscription = client + .on() + .skip(1) // Skipping the last emitted event. + // We only need to handle the latest events. + .listen((event) { // Only handle the event if the value is in success state. if (value.isNotSuccess) return; From 61170a09215b0a5a76d817e37ef6f581141180ec Mon Sep 17 00:00:00 2001 From: Sahil Kumar Date: Mon, 3 Apr 2023 18:26:57 +0530 Subject: [PATCH 077/107] ci(repo): add cache and concurrency Signed-off-by: xsahil03x --- .github/workflows/dart_code_metrics.yaml | 13 ++++++------- .github/workflows/pana.yml | 4 ++++ .github/workflows/pr_title.yml | 4 ++++ .github/workflows/stream_flutter_workflow.yml | 12 ++++++------ 4 files changed, 20 insertions(+), 13 deletions(-) diff --git a/.github/workflows/dart_code_metrics.yaml b/.github/workflows/dart_code_metrics.yaml index 265ec8292..23be05617 100644 --- a/.github/workflows/dart_code_metrics.yaml +++ b/.github/workflows/dart_code_metrics.yaml @@ -10,6 +10,10 @@ on: branches: - master - develop + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true jobs: check: @@ -21,15 +25,10 @@ jobs: with: fetch-depth: 0 - - name: "Cache Flutter dependencies" - uses: actions/cache@v2 - with: - path: /opt/hostedtoolcache/flutter - key: ${{ env.flutter_version }}-flutter - - name: "Install Flutter" - uses: subosito/flutter-action@v1 + uses: subosito/flutter-action@v2 with: + cache: true flutter-version: ${{ env.flutter_version }} - name: "Install Tools" diff --git a/.github/workflows/pana.yml b/.github/workflows/pana.yml index a6a7e8222..39d2b898d 100644 --- a/.github/workflows/pana.yml +++ b/.github/workflows/pana.yml @@ -14,6 +14,10 @@ on: - master paths-ignore: - 'docs/**' + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true jobs: stream_chat: diff --git a/.github/workflows/pr_title.yml b/.github/workflows/pr_title.yml index b7d1ad9b5..bd4e36cb0 100644 --- a/.github/workflows/pr_title.yml +++ b/.github/workflows/pr_title.yml @@ -7,6 +7,10 @@ on: - synchronize branches: - develop + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true jobs: conventional_pr_title: diff --git a/.github/workflows/stream_flutter_workflow.yml b/.github/workflows/stream_flutter_workflow.yml index c979229e8..478ed227b 100644 --- a/.github/workflows/stream_flutter_workflow.yml +++ b/.github/workflows/stream_flutter_workflow.yml @@ -11,6 +11,10 @@ on: branches: - master - develop + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true jobs: analyze: @@ -22,14 +26,10 @@ jobs: uses: actions/checkout@v2 with: fetch-depth: 0 - - name: Cache Flutter dependencies - uses: actions/cache@v2 - with: - path: /opt/hostedtoolcache/flutter - key: ${{ env.flutter_version }}-flutter - name: "Install Flutter" - uses: subosito/flutter-action@v1 + uses: subosito/flutter-action@v2 with: + cache: true flutter-version: ${{ env.flutter_version }} - name: "Install Tools" run: | From 7e7ce696addc88f97a5d494d6eb4411f7e2b23dc Mon Sep 17 00:00:00 2001 From: Sahil Kumar Date: Mon, 3 Apr 2023 18:45:06 +0530 Subject: [PATCH 078/107] chore(core): remove redundant matchers Signed-off-by: xsahil03x --- .../test/matchers/channel_matcher.dart | 48 ----------------- .../get_message_response_matcher.dart | 54 ------------------- .../test/matchers/message_matcher.dart | 48 ----------------- .../test/matchers/users_matcher.dart | 46 ---------------- 4 files changed, 196 deletions(-) delete mode 100644 packages/stream_chat_flutter_core/test/matchers/channel_matcher.dart delete mode 100644 packages/stream_chat_flutter_core/test/matchers/get_message_response_matcher.dart delete mode 100644 packages/stream_chat_flutter_core/test/matchers/message_matcher.dart delete mode 100644 packages/stream_chat_flutter_core/test/matchers/users_matcher.dart diff --git a/packages/stream_chat_flutter_core/test/matchers/channel_matcher.dart b/packages/stream_chat_flutter_core/test/matchers/channel_matcher.dart deleted file mode 100644 index 514462e0c..000000000 --- a/packages/stream_chat_flutter_core/test/matchers/channel_matcher.dart +++ /dev/null @@ -1,48 +0,0 @@ -import 'package:flutter_test/flutter_test.dart'; -import 'package:stream_chat_flutter_core/stream_chat_flutter_core.dart'; - -Matcher isSameChannelAs(Channel targetChannel) => - _IsSameChannelAs(targetChannel: targetChannel); - -class _IsSameChannelAs extends Matcher { - const _IsSameChannelAs({ - required this.targetChannel, - }); - - final Channel targetChannel; - - @override - bool matches(covariant Channel channel, Map matchState) => - channel.cid == targetChannel.cid; - - @override - Description describe(Description description) => - description.add('is same channel as $targetChannel'); -} - -Matcher isSameChannelListAs(List targetChannelList) => - _IsSameChannelListAs(targetChannelList: targetChannelList); - -class _IsSameChannelListAs extends Matcher { - const _IsSameChannelListAs({ - required this.targetChannelList, - }); - - final List targetChannelList; - - @override - bool matches(covariant List channelList, Map matchState) { - var matches = true; - for (var i = 0; i < channelList.length; i++) { - final channel = channelList[i]; - final targetChannel = targetChannelList[i]; - matches = isSameChannelAs(targetChannel).matches(channel, matchState); - if (!matches) break; - } - return matches; - } - - @override - Description describe(Description description) => - description.add('is same channelList as $targetChannelList'); -} diff --git a/packages/stream_chat_flutter_core/test/matchers/get_message_response_matcher.dart b/packages/stream_chat_flutter_core/test/matchers/get_message_response_matcher.dart deleted file mode 100644 index c3a6629d9..000000000 --- a/packages/stream_chat_flutter_core/test/matchers/get_message_response_matcher.dart +++ /dev/null @@ -1,54 +0,0 @@ -import 'package:flutter_test/flutter_test.dart'; -import 'package:stream_chat_flutter_core/stream_chat_flutter_core.dart'; - -Matcher isSameMessageResponseAs(GetMessageResponse targetResponse) => - _IsSameMessageResponseAs(targetResponse: targetResponse); - -class _IsSameMessageResponseAs extends Matcher { - const _IsSameMessageResponseAs({ - required this.targetResponse, - }); - - final GetMessageResponse targetResponse; - - @override - bool matches(covariant GetMessageResponse response, Map matchState) => - response.message.id == targetResponse.message.id && - response.channel?.cid == targetResponse.channel?.cid; - - @override - Description describe(Description description) => - description.add('is same message response as $targetResponse'); -} - -Matcher isSameMessageResponseListAs( - List targetResponseList) => - _IsSameMessageResponseListAs(targetResponseList: targetResponseList); - -class _IsSameMessageResponseListAs extends Matcher { - const _IsSameMessageResponseListAs({ - required this.targetResponseList, - }); - - final List targetResponseList; - - @override - bool matches( - covariant List responseList, Map matchState) { - var matches = true; - for (var i = 0; i < responseList.length; i++) { - final response = responseList[i]; - final targetResponse = targetResponseList[i]; - matches = isSameMessageResponseAs(targetResponse).matches( - response, - matchState, - ); - if (!matches) break; - } - return matches; - } - - @override - Description describe(Description description) => - description.add('is same userResponseList as $targetResponseList'); -} diff --git a/packages/stream_chat_flutter_core/test/matchers/message_matcher.dart b/packages/stream_chat_flutter_core/test/matchers/message_matcher.dart deleted file mode 100644 index 776665ffc..000000000 --- a/packages/stream_chat_flutter_core/test/matchers/message_matcher.dart +++ /dev/null @@ -1,48 +0,0 @@ -import 'package:flutter_test/flutter_test.dart'; -import 'package:stream_chat_flutter_core/stream_chat_flutter_core.dart'; - -Matcher isSameMessageAs(Message targetMessage) => - _IsSameMessageAs(targetMessage: targetMessage); - -class _IsSameMessageAs extends Matcher { - const _IsSameMessageAs({ - required this.targetMessage, - }); - - final Message targetMessage; - - @override - bool matches(covariant Message message, Map matchState) => - message.id == targetMessage.id; - - @override - Description describe(Description description) => - description.add('is same message as $targetMessage'); -} - -Matcher isSameMessageListAs(List targetMessageList) => - _IsSameMessageListAs(targetMessageList: targetMessageList); - -class _IsSameMessageListAs extends Matcher { - const _IsSameMessageListAs({ - required this.targetMessageList, - }); - - final List targetMessageList; - - @override - bool matches(covariant List messageList, Map matchState) { - var matches = true; - for (var i = 0; i < messageList.length; i++) { - final message = messageList[i]; - final targetMessage = targetMessageList[i]; - matches = isSameMessageAs(targetMessage).matches(message, matchState); - if (!matches) break; - } - return matches; - } - - @override - Description describe(Description description) => - description.add('is same messageList as $targetMessageList'); -} diff --git a/packages/stream_chat_flutter_core/test/matchers/users_matcher.dart b/packages/stream_chat_flutter_core/test/matchers/users_matcher.dart deleted file mode 100644 index fa0f0c08a..000000000 --- a/packages/stream_chat_flutter_core/test/matchers/users_matcher.dart +++ /dev/null @@ -1,46 +0,0 @@ -import 'package:flutter_test/flutter_test.dart'; -import 'package:stream_chat_flutter_core/stream_chat_flutter_core.dart'; - -Matcher isSameUserAs(User targetUser) => _IsSameUserAs(targetUser: targetUser); - -class _IsSameUserAs extends Matcher { - const _IsSameUserAs({ - required this.targetUser, - }); - - final User targetUser; - - @override - bool matches(covariant User user, Map matchState) => user.id == targetUser.id; - - @override - Description describe(Description description) => - description.add('is same user as $targetUser'); -} - -Matcher isSameUserListAs(List targetUserList) => - _IsSameUserListAs(targetUserList: targetUserList); - -class _IsSameUserListAs extends Matcher { - const _IsSameUserListAs({ - required this.targetUserList, - }); - - final List targetUserList; - - @override - bool matches(covariant List userList, Map matchState) { - var matches = true; - for (var i = 0; i < userList.length; i++) { - final user = userList[i]; - final targetUser = targetUserList[i]; - matches = isSameUserAs(targetUser).matches(user, matchState); - if (!matches) break; - } - return matches; - } - - @override - Description describe(Description description) => - description.add('is same userList as $targetUserList'); -} From 4f46983e5f36d8337b6480d54ed4630ee0cbf4ed Mon Sep 17 00:00:00 2001 From: Sahil Kumar Date: Mon, 3 Apr 2023 18:47:26 +0530 Subject: [PATCH 079/107] ci(repo): enable flutter cache Signed-off-by: xsahil03x --- .github/workflows/stream_flutter_workflow.yml | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/.github/workflows/stream_flutter_workflow.yml b/.github/workflows/stream_flutter_workflow.yml index 478ed227b..22d341b93 100644 --- a/.github/workflows/stream_flutter_workflow.yml +++ b/.github/workflows/stream_flutter_workflow.yml @@ -53,14 +53,10 @@ jobs: uses: actions/checkout@v2 with: fetch-depth: 0 - - name: Cache Flutter dependencies - uses: actions/cache@v2 - with: - path: /opt/hostedtoolcache/flutter - key: ${{ env.flutter_version }}-flutter - name: "Install Flutter" - uses: subosito/flutter-action@v1 + uses: subosito/flutter-action@v2 with: + cache: true flutter-version: ${{ env.flutter_version }} - name: "Install Tools" run: | @@ -82,14 +78,10 @@ jobs: uses: actions/checkout@v2 with: fetch-depth: 0 - - name: Cache Flutter dependencies - uses: actions/cache@v2 - with: - path: /Users/runner/hostedtoolcache/flutter - key: ${{ env.flutter_version }}-flutter - name: "Install Flutter" - uses: subosito/flutter-action@v1 + uses: subosito/flutter-action@v2 with: + cache: true flutter-version: ${{ env.flutter_version }} - name: "Install Tools" run: | From 99dd1dbaabc84ed9485e614e69d595dffa764e74 Mon Sep 17 00:00:00 2001 From: Sahil Kumar Date: Mon, 3 Apr 2023 18:58:55 +0530 Subject: [PATCH 080/107] push Signed-off-by: xsahil03x --- .../example/ios/Runner.xcodeproj/project.pbxproj | 4 +++- .../example/ios/Runner/Info.plist | 2 ++ .../linux/flutter/generated_plugin_registrant.cc | 12 ++++-------- .../example/linux/flutter/generated_plugins.cmake | 3 +-- .../example/macos/Runner.xcodeproj/project.pbxproj | 11 ++++++----- .../xcshareddata/xcschemes/Runner.xcscheme | 2 +- .../windows/flutter/generated_plugin_registrant.cc | 14 ++++---------- .../windows/flutter/generated_plugins.cmake | 6 ++---- .../windows/flutter/generated_plugin_registrant.cc | 2 +- .../windows/flutter/generated_plugins.cmake | 2 +- 10 files changed, 25 insertions(+), 33 deletions(-) diff --git a/packages/stream_chat_flutter/example/ios/Runner.xcodeproj/project.pbxproj b/packages/stream_chat_flutter/example/ios/Runner.xcodeproj/project.pbxproj index 9b47e613f..e5d8f7436 100644 --- a/packages/stream_chat_flutter/example/ios/Runner.xcodeproj/project.pbxproj +++ b/packages/stream_chat_flutter/example/ios/Runner.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 51; + objectVersion = 54; objects = { /* Begin PBXBuildFile section */ @@ -199,6 +199,7 @@ /* Begin PBXShellScriptBuildPhase section */ 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; buildActionMask = 2147483647; files = ( ); @@ -235,6 +236,7 @@ }; 9740EEB61CF901F6004384FC /* Run Script */ = { isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; buildActionMask = 2147483647; files = ( ); diff --git a/packages/stream_chat_flutter/example/ios/Runner/Info.plist b/packages/stream_chat_flutter/example/ios/Runner/Info.plist index 299ebd4cf..d49f0173b 100644 --- a/packages/stream_chat_flutter/example/ios/Runner/Info.plist +++ b/packages/stream_chat_flutter/example/ios/Runner/Info.plist @@ -61,5 +61,7 @@ Explain why your app uses the mic CADisableMinimumFrameDurationOnPhone + UIApplicationSupportsIndirectInputEvents + diff --git a/packages/stream_chat_flutter/example/linux/flutter/generated_plugin_registrant.cc b/packages/stream_chat_flutter/example/linux/flutter/generated_plugin_registrant.cc index bb19d0b5b..5d1305adb 100644 --- a/packages/stream_chat_flutter/example/linux/flutter/generated_plugin_registrant.cc +++ b/packages/stream_chat_flutter/example/linux/flutter/generated_plugin_registrant.cc @@ -8,10 +8,9 @@ #include #include -#include +#include #include #include -#include void fl_register_plugins(FlPluginRegistry* registry) { g_autoptr(FlPluginRegistrar) dart_vlc_registrar = @@ -20,16 +19,13 @@ void fl_register_plugins(FlPluginRegistry* registry) { g_autoptr(FlPluginRegistrar) desktop_drop_registrar = fl_plugin_registry_get_registrar_for_plugin(registry, "DesktopDropPlugin"); desktop_drop_plugin_register_with_registrar(desktop_drop_registrar); - g_autoptr(FlPluginRegistrar) screen_retriever_registrar = - fl_plugin_registry_get_registrar_for_plugin(registry, "ScreenRetrieverPlugin"); - screen_retriever_plugin_register_with_registrar(screen_retriever_registrar); + g_autoptr(FlPluginRegistrar) file_selector_linux_registrar = + fl_plugin_registry_get_registrar_for_plugin(registry, "FileSelectorPlugin"); + file_selector_plugin_register_with_registrar(file_selector_linux_registrar); g_autoptr(FlPluginRegistrar) sqlite3_flutter_libs_registrar = fl_plugin_registry_get_registrar_for_plugin(registry, "Sqlite3FlutterLibsPlugin"); sqlite3_flutter_libs_plugin_register_with_registrar(sqlite3_flutter_libs_registrar); g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar = fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin"); url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar); - g_autoptr(FlPluginRegistrar) window_manager_registrar = - fl_plugin_registry_get_registrar_for_plugin(registry, "WindowManagerPlugin"); - window_manager_plugin_register_with_registrar(window_manager_registrar); } diff --git a/packages/stream_chat_flutter/example/linux/flutter/generated_plugins.cmake b/packages/stream_chat_flutter/example/linux/flutter/generated_plugins.cmake index fb9923e9d..631f39a5f 100644 --- a/packages/stream_chat_flutter/example/linux/flutter/generated_plugins.cmake +++ b/packages/stream_chat_flutter/example/linux/flutter/generated_plugins.cmake @@ -5,10 +5,9 @@ list(APPEND FLUTTER_PLUGIN_LIST dart_vlc desktop_drop - screen_retriever + file_selector_linux sqlite3_flutter_libs url_launcher_linux - window_manager ) list(APPEND FLUTTER_FFI_PLUGIN_LIST diff --git a/packages/stream_chat_flutter/example/macos/Runner.xcodeproj/project.pbxproj b/packages/stream_chat_flutter/example/macos/Runner.xcodeproj/project.pbxproj index f8c105bbd..747ee4d99 100644 --- a/packages/stream_chat_flutter/example/macos/Runner.xcodeproj/project.pbxproj +++ b/packages/stream_chat_flutter/example/macos/Runner.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 51; + objectVersion = 54; objects = { /* Begin PBXAggregateTarget section */ @@ -203,7 +203,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0920; - LastUpgradeCheck = 0930; + LastUpgradeCheck = 1300; ORGANIZATIONNAME = ""; TargetAttributes = { 33CC10EC2044A3C60003C045 = { @@ -256,6 +256,7 @@ /* Begin PBXShellScriptBuildPhase section */ 3399D490228B24CF009A79C7 /* ShellScript */ = { isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; buildActionMask = 2147483647; files = ( ); @@ -404,7 +405,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.11; + MACOSX_DEPLOYMENT_TARGET = 10.14; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = macosx; SWIFT_COMPILATION_MODE = wholemodule; @@ -484,7 +485,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.11; + MACOSX_DEPLOYMENT_TARGET = 10.14; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = macosx; @@ -531,7 +532,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.11; + MACOSX_DEPLOYMENT_TARGET = 10.14; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = macosx; SWIFT_COMPILATION_MODE = wholemodule; diff --git a/packages/stream_chat_flutter/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/packages/stream_chat_flutter/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index ae8ff59d9..7fd7126b0 100644 --- a/packages/stream_chat_flutter/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/packages/stream_chat_flutter/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -1,6 +1,6 @@ +#include #include #include #include -#include -#include +#include #include #include #include -#include void RegisterPlugins(flutter::PluginRegistry* registry) { ConnectivityPlusWindowsPluginRegisterWithRegistrar( @@ -26,16 +24,12 @@ void RegisterPlugins(flutter::PluginRegistry* registry) { registry->GetRegistrarForPlugin("DesktopDropPlugin")); FileSelectorWindowsRegisterWithRegistrar( registry->GetRegistrarForPlugin("FileSelectorWindows")); - FlutterNativeViewPluginRegisterWithRegistrar( - registry->GetRegistrarForPlugin("FlutterNativeViewPlugin")); - ScreenRetrieverPluginRegisterWithRegistrar( - registry->GetRegistrarForPlugin("ScreenRetrieverPlugin")); + SharePlusWindowsPluginCApiRegisterWithRegistrar( + registry->GetRegistrarForPlugin("SharePlusWindowsPluginCApi")); Sqlite3FlutterLibsPluginRegisterWithRegistrar( registry->GetRegistrarForPlugin("Sqlite3FlutterLibsPlugin")); ThumblrWindowsPluginRegisterWithRegistrar( registry->GetRegistrarForPlugin("ThumblrWindowsPlugin")); UrlLauncherWindowsRegisterWithRegistrar( registry->GetRegistrarForPlugin("UrlLauncherWindows")); - WindowManagerPluginRegisterWithRegistrar( - registry->GetRegistrarForPlugin("WindowManagerPlugin")); } diff --git a/packages/stream_chat_flutter/example/windows/flutter/generated_plugins.cmake b/packages/stream_chat_flutter/example/windows/flutter/generated_plugins.cmake index 727838743..aeb58c228 100644 --- a/packages/stream_chat_flutter/example/windows/flutter/generated_plugins.cmake +++ b/packages/stream_chat_flutter/example/windows/flutter/generated_plugins.cmake @@ -3,16 +3,14 @@ # list(APPEND FLUTTER_PLUGIN_LIST - connectivity_plus_windows + connectivity_plus dart_vlc desktop_drop file_selector_windows - flutter_native_view - screen_retriever + share_plus sqlite3_flutter_libs thumblr_windows url_launcher_windows - window_manager ) list(APPEND FLUTTER_FFI_PLUGIN_LIST diff --git a/packages/stream_chat_flutter_core/example/windows/flutter/generated_plugin_registrant.cc b/packages/stream_chat_flutter_core/example/windows/flutter/generated_plugin_registrant.cc index 8083d749b..8777c93d9 100644 --- a/packages/stream_chat_flutter_core/example/windows/flutter/generated_plugin_registrant.cc +++ b/packages/stream_chat_flutter_core/example/windows/flutter/generated_plugin_registrant.cc @@ -6,7 +6,7 @@ #include "generated_plugin_registrant.h" -#include +#include void RegisterPlugins(flutter::PluginRegistry* registry) { ConnectivityPlusWindowsPluginRegisterWithRegistrar( diff --git a/packages/stream_chat_flutter_core/example/windows/flutter/generated_plugins.cmake b/packages/stream_chat_flutter_core/example/windows/flutter/generated_plugins.cmake index 8cf5d4267..cc1361d8d 100644 --- a/packages/stream_chat_flutter_core/example/windows/flutter/generated_plugins.cmake +++ b/packages/stream_chat_flutter_core/example/windows/flutter/generated_plugins.cmake @@ -3,7 +3,7 @@ # list(APPEND FLUTTER_PLUGIN_LIST - connectivity_plus_windows + connectivity_plus ) list(APPEND FLUTTER_FFI_PLUGIN_LIST From 36d3ca925815045f19e396a60f3096b15a3f5b14 Mon Sep 17 00:00:00 2001 From: xsahil03x Date: Mon, 3 Apr 2023 20:27:14 +0530 Subject: [PATCH 081/107] fix tests Signed-off-by: xsahil03x --- melos.yaml | 14 ++++---- .../lib/src/core/models/attachment.dart | 4 +-- .../lib/src/core/models/channel_model.dart | 26 +++++++------- .../lib/src/core/models/channel_model.g.dart | 10 ------ .../lib/src/core/models/message.dart | 34 ++++++++----------- .../lib/src/core/models/message.g.dart | 13 ------- .../lib/src/core/models/reaction.dart | 6 ++-- .../lib/src/core/models/reaction.g.dart | 3 -- .../stream_chat/lib/src/core/models/user.dart | 29 ++++++---------- .../lib/src/core/models/user.g.dart | 8 ----- .../core/http/stream_http_client_test.dart | 6 +++- .../test/stream_channel_test.dart | 2 +- 12 files changed, 55 insertions(+), 100 deletions(-) diff --git a/melos.yaml b/melos.yaml index 7a5016ff9..baa8761d3 100644 --- a/melos.yaml +++ b/melos.yaml @@ -65,29 +65,29 @@ scripts: test:dart: run: melos exec -c 1 --fail-fast -- "flutter test --coverage" description: Run Dart tests for a specific package in this project. - select-package: + packageFilters: flutter: false - dir-exists: test + dirExists: test test:flutter: run: melos exec -c 4 --fail-fast -- "flutter test --coverage" description: Run Flutter tests for a specific package in this project. - select-package: + packageFilters: flutter: true - dir-exists: test + dirExists: test clean:flutter: run: melos exec -c 4 --fail-fast -- "flutter clean" description: Run Flutter clean for a specific package in this project. - select-package: + packageFilters: flutter: true coverage:ignore-file: run: | melos exec -c 5 --fail-fast -- "\$MELOS_ROOT_PATH/.github/workflows/scripts/remove-from-coverage.sh" description: Removes all the ignored files from the coverage report. - select-package: - dir-exists: coverage + packageFilters: + dirExists: coverage docs: run: | diff --git a/packages/stream_chat/lib/src/core/models/attachment.dart b/packages/stream_chat/lib/src/core/models/attachment.dart index 4d9a3b30a..c757a174d 100644 --- a/packages/stream_chat/lib/src/core/models/attachment.dart +++ b/packages/stream_chat/lib/src/core/models/attachment.dart @@ -146,13 +146,13 @@ class Attachment extends Equatable { /// Shortcut for file size. /// /// {@macro fileSize} - @JsonKey(ignore: true) + @JsonKey(includeToJson: false, includeFromJson: false) int? get fileSize => extraData['file_size'] as int?; /// Shortcut for file mimeType. /// /// {@macro mimeType} - @JsonKey(ignore: true) + @JsonKey(includeToJson: false, includeFromJson: false) String? get mimeType => extraData['mime_type'] as String?; /// Known top level fields. diff --git a/packages/stream_chat/lib/src/core/models/channel_model.dart b/packages/stream_chat/lib/src/core/models/channel_model.dart index 8d01f89d8..b3523743b 100644 --- a/packages/stream_chat/lib/src/core/models/channel_model.dart +++ b/packages/stream_chat/lib/src/core/models/channel_model.dart @@ -62,19 +62,19 @@ class ChannelModel { final String type; /// The cid of this channel - @JsonKey(includeIfNull: false, toJson: Serializer.readOnly) + @JsonKey(includeToJson: false) final String cid; /// List of user permissions on this channel - @JsonKey(includeIfNull: false, toJson: Serializer.readOnly) + @JsonKey(includeToJson: false) final List? ownCapabilities; /// The channel configuration data - @JsonKey(includeIfNull: false, toJson: Serializer.readOnly) + @JsonKey(includeToJson: false) final ChannelConfig config; /// The user that created this channel - @JsonKey(includeIfNull: false, toJson: Serializer.readOnly) + @JsonKey(includeToJson: false) final User? createdBy; /// True if this channel is frozen @@ -82,23 +82,23 @@ class ChannelModel { final bool frozen; /// The date of the last message - @JsonKey(includeIfNull: false, toJson: Serializer.readOnly) + @JsonKey(includeToJson: false) final DateTime? lastMessageAt; /// The date of channel creation - @JsonKey(includeIfNull: false, toJson: Serializer.readOnly) + @JsonKey(includeToJson: false) final DateTime createdAt; /// The date of the last channel update - @JsonKey(includeIfNull: false, toJson: Serializer.readOnly) + @JsonKey(includeToJson: false) final DateTime updatedAt; /// The date of channel deletion - @JsonKey(includeIfNull: false, toJson: Serializer.readOnly) + @JsonKey(includeToJson: false) final DateTime? deletedAt; /// The count of this channel members - @JsonKey(includeIfNull: false, toJson: Serializer.readOnly) + @JsonKey(includeToJson: false) final int memberCount; /// The number of seconds in a cooldown @@ -106,15 +106,15 @@ class ChannelModel { final int cooldown; /// True if the channel is disabled - @JsonKey(ignore: true) + @JsonKey(includeToJson: false, includeFromJson: false) bool? get disabled => extraData['disabled'] as bool?; /// True if the channel is hidden - @JsonKey(ignore: true) + @JsonKey(includeToJson: false, includeFromJson: false) bool? get hidden => extraData['hidden'] as bool?; /// The date of the last time channel got truncated - @JsonKey(ignore: true) + @JsonKey(includeToJson: false, includeFromJson: false) DateTime? get truncatedAt { final truncatedAt = extraData['truncated_at'] as String?; if (truncatedAt == null) return null; @@ -126,7 +126,7 @@ class ChannelModel { final Map extraData; /// The team the channel belongs to - @JsonKey(includeIfNull: false, toJson: Serializer.readOnly) + @JsonKey(includeToJson: false) final String? team; /// Known top level fields. diff --git a/packages/stream_chat/lib/src/core/models/channel_model.g.dart b/packages/stream_chat/lib/src/core/models/channel_model.g.dart index d86c2941f..b1a691e3f 100644 --- a/packages/stream_chat/lib/src/core/models/channel_model.g.dart +++ b/packages/stream_chat/lib/src/core/models/channel_model.g.dart @@ -42,17 +42,7 @@ Map _$ChannelModelToJson(ChannelModel instance) => { 'id': instance.id, 'type': instance.type, - 'cid': readonly(instance.cid), - 'own_capabilities': readonly(instance.ownCapabilities), - 'config': readonly(instance.config), - 'created_by': readonly(instance.createdBy), 'frozen': instance.frozen, - 'last_message_at': readonly(instance.lastMessageAt), - 'created_at': readonly(instance.createdAt), - 'updated_at': readonly(instance.updatedAt), - 'deleted_at': readonly(instance.deletedAt), - 'member_count': readonly(instance.memberCount), 'cooldown': instance.cooldown, 'extra_data': instance.extraData, - 'team': readonly(instance.team), }; diff --git a/packages/stream_chat/lib/src/core/models/message.dart b/packages/stream_chat/lib/src/core/models/message.dart index 017bb06fc..6f3a5b13d 100644 --- a/packages/stream_chat/lib/src/core/models/message.dart +++ b/packages/stream_chat/lib/src/core/models/message.dart @@ -95,14 +95,11 @@ class Message extends Equatable { final String? text; /// The status of a sending message. - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) final MessageSendingStatus status; /// The message type. - @JsonKey( - includeIfNull: false, - toJson: Serializer.readOnly, - ) + @JsonKey(includeToJson: false) final String type; /// The list of attachments, either provided by the user or generated from a @@ -115,19 +112,19 @@ class Message extends Equatable { final List mentionedUsers; /// A map describing the count of number of every reaction. - @JsonKey(includeIfNull: false, toJson: Serializer.readOnly) + @JsonKey(includeToJson: false) final Map? reactionCounts; /// A map describing the count of score of every reaction. - @JsonKey(includeIfNull: false, toJson: Serializer.readOnly) + @JsonKey(includeToJson: false) final Map? reactionScores; /// The latest reactions to the message created by any user. - @JsonKey(includeIfNull: false, toJson: Serializer.readOnly) + @JsonKey(includeToJson: false) final List? latestReactions; /// The reactions added to the message by the current user. - @JsonKey(includeIfNull: false, toJson: Serializer.readOnly) + @JsonKey(includeToJson: false) final List? ownReactions; /// The ID of the parent message, if the message is a thread reply. @@ -143,11 +140,11 @@ class Message extends Equatable { String? get quotedMessageId => _quotedMessageId ?? quotedMessage?.id; /// Reserved field indicating the number of replies for this message. - @JsonKey(includeIfNull: false, toJson: Serializer.readOnly) + @JsonKey(includeToJson: false) final int? replyCount; /// Reserved field indicating the thread participants for this message. - @JsonKey(includeIfNull: false, toJson: Serializer.readOnly) + @JsonKey(includeToJson: false) final List? threadParticipants; /// Check if this message needs to show in the channel. @@ -157,34 +154,31 @@ class Message extends Equatable { final bool silent; /// If true the message is shadowed. - @JsonKey( - includeIfNull: false, - toJson: Serializer.readOnly, - ) + @JsonKey(includeToJson: false) final bool shadowed; /// A used command name. - @JsonKey(includeIfNull: false, toJson: Serializer.readOnly) + @JsonKey(includeToJson: false) final String? command; final DateTime? _createdAt; /// Reserved field indicating when the message was deleted. - @JsonKey(includeIfNull: false, toJson: Serializer.readOnly) + @JsonKey(includeToJson: false) final DateTime? deletedAt; /// Reserved field indicating when the message was created. - @JsonKey(includeIfNull: false, toJson: Serializer.readOnly) + @JsonKey(includeToJson: false) DateTime get createdAt => _createdAt ?? DateTime.now(); final DateTime? _updatedAt; /// Reserved field indicating when the message was updated last time. - @JsonKey(includeIfNull: false, toJson: Serializer.readOnly) + @JsonKey(includeToJson: false) DateTime get updatedAt => _updatedAt ?? DateTime.now(); /// User who sent the message. - @JsonKey(includeIfNull: false, toJson: Serializer.readOnly) + @JsonKey(includeToJson: false) final User? user; /// If true the message is pinned. diff --git a/packages/stream_chat/lib/src/core/models/message.g.dart b/packages/stream_chat/lib/src/core/models/message.g.dart index 8023cb793..cbf849cc0 100644 --- a/packages/stream_chat/lib/src/core/models/message.g.dart +++ b/packages/stream_chat/lib/src/core/models/message.g.dart @@ -75,26 +75,13 @@ Map _$MessageToJson(Message instance) { final val = { 'id': instance.id, 'text': instance.text, - 'type': readonly(instance.type), 'attachments': instance.attachments.map((e) => e.toJson()).toList(), 'mentioned_users': User.toIds(instance.mentionedUsers), - 'reaction_counts': readonly(instance.reactionCounts), - 'reaction_scores': readonly(instance.reactionScores), - 'latest_reactions': readonly(instance.latestReactions), - 'own_reactions': readonly(instance.ownReactions), 'parent_id': instance.parentId, 'quoted_message': readonly(instance.quotedMessage), 'quoted_message_id': instance.quotedMessageId, - 'reply_count': readonly(instance.replyCount), - 'thread_participants': readonly(instance.threadParticipants), 'show_in_channel': instance.showInChannel, 'silent': instance.silent, - 'shadowed': readonly(instance.shadowed), - 'command': readonly(instance.command), - 'deleted_at': readonly(instance.deletedAt), - 'created_at': readonly(instance.createdAt), - 'updated_at': readonly(instance.updatedAt), - 'user': readonly(instance.user), 'pinned': instance.pinned, 'pinned_at': readonly(instance.pinnedAt), 'pin_expires': instance.pinExpires?.toIso8601String(), diff --git a/packages/stream_chat/lib/src/core/models/reaction.dart b/packages/stream_chat/lib/src/core/models/reaction.dart index f16fb09f4..2bc6f52ba 100644 --- a/packages/stream_chat/lib/src/core/models/reaction.dart +++ b/packages/stream_chat/lib/src/core/models/reaction.dart @@ -33,18 +33,18 @@ class Reaction { final String type; /// The date of the reaction - @JsonKey(includeIfNull: false, toJson: Serializer.readOnly) + @JsonKey(includeToJson: false) final DateTime createdAt; /// The user that sent the reaction - @JsonKey(includeIfNull: false, toJson: Serializer.readOnly) + @JsonKey(includeToJson: false) final User? user; /// The score of the reaction (ie. number of reactions sent) final int score; /// The userId that sent the reaction - @JsonKey(includeIfNull: false, toJson: Serializer.readOnly) + @JsonKey(includeToJson: false) final String? userId; /// Reaction custom extraData diff --git a/packages/stream_chat/lib/src/core/models/reaction.g.dart b/packages/stream_chat/lib/src/core/models/reaction.g.dart index c669e8502..6dcac5e19 100644 --- a/packages/stream_chat/lib/src/core/models/reaction.g.dart +++ b/packages/stream_chat/lib/src/core/models/reaction.g.dart @@ -23,9 +23,6 @@ Reaction _$ReactionFromJson(Map json) => Reaction( Map _$ReactionToJson(Reaction instance) => { 'message_id': instance.messageId, 'type': instance.type, - 'created_at': readonly(instance.createdAt), - 'user': readonly(instance.user), 'score': instance.score, - 'user_id': readonly(instance.userId), 'extra_data': instance.extraData, }; diff --git a/packages/stream_chat/lib/src/core/models/user.dart b/packages/stream_chat/lib/src/core/models/user.dart index 6cce01df0..ca60e6148 100644 --- a/packages/stream_chat/lib/src/core/models/user.dart +++ b/packages/stream_chat/lib/src/core/models/user.dart @@ -79,7 +79,7 @@ class User extends Equatable { /// Shortcut for user name. /// /// {@macro name} - @JsonKey(ignore: true) + @JsonKey(includeToJson: false, includeFromJson: false) String get name { if (extraData.containsKey('name') && extraData['name'] != null) { final name = extraData['name']! as String; @@ -91,48 +91,39 @@ class User extends Equatable { /// Shortcut for user image. /// /// {@macro image} - @JsonKey(ignore: true) + @JsonKey(includeToJson: false, includeFromJson: false) String? get image => extraData['image'] as String?; /// User role. - @JsonKey(includeIfNull: false, toJson: Serializer.readOnly) + @JsonKey(includeToJson: false) final String? role; /// User teams - @JsonKey( - includeIfNull: false, - toJson: Serializer.readOnly, - ) + @JsonKey(includeToJson: false) final List teams; /// Date of user creation. - @JsonKey(includeIfNull: false, toJson: Serializer.readOnly) + @JsonKey(includeToJson: false) final DateTime createdAt; /// Date of last user update. - @JsonKey(includeIfNull: false, toJson: Serializer.readOnly) + @JsonKey(includeToJson: false) final DateTime updatedAt; /// Date of last user connection. - @JsonKey(includeIfNull: false, toJson: Serializer.readOnly) + @JsonKey(includeToJson: false) final DateTime? lastActive; /// True if user is online. - @JsonKey( - includeIfNull: false, - toJson: Serializer.readOnly, - ) + @JsonKey(includeToJson: false) final bool online; /// True if user is banned from the chat. - @JsonKey( - includeIfNull: false, - toJson: Serializer.readOnly, - ) + @JsonKey(includeToJson: false) final bool banned; /// The date at which the ban will expire. - @JsonKey(includeIfNull: false, toJson: Serializer.readOnly) + @JsonKey(includeToJson: false) final DateTime? banExpires; /// The language this user prefers. diff --git a/packages/stream_chat/lib/src/core/models/user.g.dart b/packages/stream_chat/lib/src/core/models/user.g.dart index 3736cad1b..47094ffc2 100644 --- a/packages/stream_chat/lib/src/core/models/user.g.dart +++ b/packages/stream_chat/lib/src/core/models/user.g.dart @@ -33,14 +33,6 @@ User _$UserFromJson(Map json) => User( Map _$UserToJson(User instance) { final val = { 'id': instance.id, - 'role': readonly(instance.role), - 'teams': readonly(instance.teams), - 'created_at': readonly(instance.createdAt), - 'updated_at': readonly(instance.updatedAt), - 'last_active': readonly(instance.lastActive), - 'online': readonly(instance.online), - 'banned': readonly(instance.banned), - 'ban_expires': readonly(instance.banExpires), }; void writeNotNull(String key, dynamic value) { diff --git a/packages/stream_chat/test/src/core/http/stream_http_client_test.dart b/packages/stream_chat/test/src/core/http/stream_http_client_test.dart index 6abed8ae2..4854b98f8 100644 --- a/packages/stream_chat/test/src/core/http/stream_http_client_test.dart +++ b/packages/stream_chat/test/src/core/http/stream_http_client_test.dart @@ -129,7 +129,11 @@ void main() { await client.get('path'); } on StreamChatNetworkError catch (e) { expect(e, isA()); - expect(e.message, "Dio can't establish new connection after closed."); + expect( + e.message, + "The connection errored: Dio can't establish a new connection" + ' after it was closed.', + ); } }); diff --git a/packages/stream_chat_flutter_core/test/stream_channel_test.dart b/packages/stream_chat_flutter_core/test/stream_channel_test.dart index 875b885d5..60a199f27 100644 --- a/packages/stream_chat_flutter_core/test/stream_channel_test.dart +++ b/packages/stream_chat_flutter_core/test/stream_channel_test.dart @@ -93,7 +93,7 @@ void main() { const errorMessage = 'Error! Error! Error!'; final error = DioError( type: DioErrorType.badResponse, - error: errorMessage, + message: errorMessage, requestOptions: RequestOptions(path: ''), ); when(() => mockChannel.initialized) From 7992a51bef1041bc3b4407db466e84266f96478a Mon Sep 17 00:00:00 2001 From: Sahil Kumar Date: Tue, 4 Apr 2023 02:47:46 +0530 Subject: [PATCH 082/107] fix analysis issues Signed-off-by: xsahil03x --- .../lib/src/core/api/requests.dart | 2 +- .../lib/src/core/models/attachment_file.dart | 2 +- .../stream_chat_flutter/example/lib/main.dart | 2 +- .../example/lib/split_view.dart | 2 +- .../lib/src/channel/channel_header.dart | 4 +-- .../lib/src/channel/channel_list_header.dart | 9 +++-- .../lib/src/gallery/gallery_header.dart | 4 +-- .../stream_message_text_field.dart | 35 +------------------ .../lib/src/misc/stream_svg_icon.dart | 7 +++- .../lib/src/misc/thread_header.dart | 4 +-- .../stream_channel_list_view.dart | 2 +- .../test/stream_channel_test.dart | 2 +- .../test/basics_test.dart | 2 +- 13 files changed, 26 insertions(+), 51 deletions(-) diff --git a/packages/stream_chat/lib/src/core/api/requests.dart b/packages/stream_chat/lib/src/core/api/requests.dart index 719b2b9b4..f81ee70b6 100644 --- a/packages/stream_chat/lib/src/core/api/requests.dart +++ b/packages/stream_chat/lib/src/core/api/requests.dart @@ -40,7 +40,7 @@ class SortOption { final int direction; /// Sorting field Comparator required for offline sorting - @JsonKey(ignore: true) + @JsonKey(includeToJson: false, includeFromJson: false) final Comparator? comparator; /// Serialize model to json diff --git a/packages/stream_chat/lib/src/core/models/attachment_file.dart b/packages/stream_chat/lib/src/core/models/attachment_file.dart index e67508436..ee6690ca9 100644 --- a/packages/stream_chat/lib/src/core/models/attachment_file.dart +++ b/packages/stream_chat/lib/src/core/models/attachment_file.dart @@ -52,7 +52,7 @@ class AttachmentFile { /// Byte data for this file. Particularly useful if you want to manipulate /// its data or easily upload to somewhere else. - @JsonKey(ignore: true) + @JsonKey(includeToJson: false, includeFromJson: false) final Uint8List? bytes; /// The file size in bytes. diff --git a/packages/stream_chat_flutter/example/lib/main.dart b/packages/stream_chat_flutter/example/lib/main.dart index c8978a45b..e4f291fef 100644 --- a/packages/stream_chat_flutter/example/lib/main.dart +++ b/packages/stream_chat_flutter/example/lib/main.dart @@ -177,7 +177,7 @@ class _SplitViewState extends State { : Center( child: Text( 'Pick a channel to show the messages 💬', - style: Theme.of(context).textTheme.headline5, + style: Theme.of(context).textTheme.headlineSmall, ), ), ), diff --git a/packages/stream_chat_flutter/example/lib/split_view.dart b/packages/stream_chat_flutter/example/lib/split_view.dart index 2ae8e8aad..bbfe63016 100644 --- a/packages/stream_chat_flutter/example/lib/split_view.dart +++ b/packages/stream_chat_flutter/example/lib/split_view.dart @@ -78,7 +78,7 @@ class _SplitViewState extends State { : Center( child: Text( 'Pick a channel to show the messages 💬', - style: Theme.of(context).textTheme.headline5, + style: Theme.of(context).textTheme.headlineSmall, ), ), ), diff --git a/packages/stream_chat_flutter/lib/src/channel/channel_header.dart b/packages/stream_chat_flutter/lib/src/channel/channel_header.dart index d8dce9ffd..b97af4922 100644 --- a/packages/stream_chat_flutter/lib/src/channel/channel_header.dart +++ b/packages/stream_chat_flutter/lib/src/channel/channel_header.dart @@ -162,8 +162,8 @@ class StreamChannelHeader extends StatelessWidget showMessage: showConnectionStateTile && showStatus, message: statusString, child: AppBar( - toolbarTextStyle: theme.textTheme.bodyText2, - titleTextStyle: theme.textTheme.headline6, + toolbarTextStyle: theme.textTheme.bodyMedium, + titleTextStyle: theme.textTheme.titleLarge, systemOverlayStyle: theme.brightness == Brightness.dark ? SystemUiOverlayStyle.light : SystemUiOverlayStyle.dark, diff --git a/packages/stream_chat_flutter/lib/src/channel/channel_list_header.dart b/packages/stream_chat_flutter/lib/src/channel/channel_list_header.dart index 95cf640d7..20c214b10 100644 --- a/packages/stream_chat_flutter/lib/src/channel/channel_list_header.dart +++ b/packages/stream_chat_flutter/lib/src/channel/channel_list_header.dart @@ -131,8 +131,8 @@ class StreamChannelListHeader extends StatelessWidget showMessage: showConnectionStateTile && showStatus, message: statusString, child: AppBar( - toolbarTextStyle: theme.textTheme.bodyText2, - titleTextStyle: theme.textTheme.headline6, + toolbarTextStyle: theme.textTheme.bodyMedium, + titleTextStyle: theme.textTheme.titleLarge, systemOverlayStyle: theme.brightness == Brightness.dark ? SystemUiOverlayStyle.light : SystemUiOverlayStyle.dark, @@ -181,7 +181,10 @@ class StreamChannelListHeader extends StatelessWidget package: 'stream_chat_flutter', width: 24, height: 24, - color: color, + colorFilter: ColorFilter.mode( + color, + BlendMode.srcIn, + ), ); }, ), diff --git a/packages/stream_chat_flutter/lib/src/gallery/gallery_header.dart b/packages/stream_chat_flutter/lib/src/gallery/gallery_header.dart index 866e3c5e9..19aed6e6d 100644 --- a/packages/stream_chat_flutter/lib/src/gallery/gallery_header.dart +++ b/packages/stream_chat_flutter/lib/src/gallery/gallery_header.dart @@ -80,8 +80,8 @@ class StreamGalleryHeader extends StatelessWidget final galleryHeaderThemeData = StreamGalleryHeaderTheme.of(context); final theme = Theme.of(context); return AppBar( - toolbarTextStyle: theme.textTheme.bodyText2, - titleTextStyle: theme.textTheme.headline6, + toolbarTextStyle: theme.textTheme.bodyMedium, + titleTextStyle: theme.textTheme.titleLarge, systemOverlayStyle: theme.brightness == Brightness.dark ? SystemUiOverlayStyle.light : SystemUiOverlayStyle.dark, diff --git a/packages/stream_chat_flutter/lib/src/message_input/stream_message_text_field.dart b/packages/stream_chat_flutter/lib/src/message_input/stream_message_text_field.dart index 5a0fd63a9..a04ab829d 100644 --- a/packages/stream_chat_flutter/lib/src/message_input/stream_message_text_field.dart +++ b/packages/stream_chat_flutter/lib/src/message_input/stream_message_text_field.dart @@ -80,7 +80,6 @@ class StreamMessageTextField extends StatefulWidget { this.textAlignVertical, this.textDirection, this.readOnly = false, - ToolbarOptions? toolbarOptions, this.showCursor, this.autofocus = false, this.obscuringCharacter = '•', @@ -155,31 +154,7 @@ class StreamMessageTextField extends StatefulWidget { keyboardType = keyboardType ?? (maxLines == 1 ? TextInputType.text : TextInputType.multiline), enableInteractiveSelection = - enableInteractiveSelection ?? (!readOnly || !obscureText), - toolbarOptions = toolbarOptions ?? - (obscureText - ? (readOnly - // No point in even offering "Select All" in a read-only obscured - // field. - ? const ToolbarOptions() - // Writable, but obscured. - : const ToolbarOptions( - selectAll: true, - paste: true, - )) - : (readOnly - // Read-only, not obscured. - ? const ToolbarOptions( - selectAll: true, - copy: true, - ) - // Writable, not obscured. - : const ToolbarOptions( - copy: true, - cut: true, - selectAll: true, - paste: true, - ))); + enableInteractiveSelection ?? (!readOnly || !obscureText); /// Controls the message being edited. /// @@ -304,13 +279,6 @@ class StreamMessageTextField extends StatefulWidget { /// {@macro flutter.widgets.editableText.readOnly} final bool readOnly; - /// Configuration of toolbar options. - /// - /// If not set, select all and paste will default to be enabled. Copy and cut - /// will be disabled if [obscureText] is true. If [readOnly] is true, - /// paste and cut will be disabled regardless. - final ToolbarOptions toolbarOptions; - /// {@macro flutter.widgets.editableText.showCursor} final bool? showCursor; @@ -720,7 +688,6 @@ class _StreamMessageTextFieldState extends State textAlignVertical: widget.textAlignVertical, textDirection: widget.textDirection, readOnly: widget.readOnly, - toolbarOptions: widget.toolbarOptions, showCursor: widget.showCursor, autofocus: widget.autofocus, obscuringCharacter: widget.obscuringCharacter, diff --git a/packages/stream_chat_flutter/lib/src/misc/stream_svg_icon.dart b/packages/stream_chat_flutter/lib/src/misc/stream_svg_icon.dart index 8472af6e7..a040bd427 100644 --- a/packages/stream_chat_flutter/lib/src/misc/stream_svg_icon.dart +++ b/packages/stream_chat_flutter/lib/src/misc/stream_svg_icon.dart @@ -1088,7 +1088,12 @@ class StreamSvgIcon extends StatelessWidget { key: key, width: width, height: height, - color: color, + colorFilter: color != null + ? ColorFilter.mode( + color!, + BlendMode.srcIn, + ) + : null, ); } } diff --git a/packages/stream_chat_flutter/lib/src/misc/thread_header.dart b/packages/stream_chat_flutter/lib/src/misc/thread_header.dart index b6e24cf9f..1142ac450 100644 --- a/packages/stream_chat_flutter/lib/src/misc/thread_header.dart +++ b/packages/stream_chat_flutter/lib/src/misc/thread_header.dart @@ -149,8 +149,8 @@ class StreamThreadHeader extends StatelessWidget final theme = Theme.of(context); return AppBar( automaticallyImplyLeading: false, - toolbarTextStyle: theme.textTheme.bodyText2, - titleTextStyle: theme.textTheme.headline6, + toolbarTextStyle: theme.textTheme.bodyMedium, + titleTextStyle: theme.textTheme.titleLarge, systemOverlayStyle: theme.brightness == Brightness.dark ? SystemUiOverlayStyle.light : SystemUiOverlayStyle.dark, diff --git a/packages/stream_chat_flutter/lib/src/scroll_view/channel_scroll_view/stream_channel_list_view.dart b/packages/stream_chat_flutter/lib/src/scroll_view/channel_scroll_view/stream_channel_list_view.dart index 6cc18e699..d2829ffd3 100644 --- a/packages/stream_chat_flutter/lib/src/scroll_view/channel_scroll_view/stream_channel_list_view.dart +++ b/packages/stream_chat_flutter/lib/src/scroll_view/channel_scroll_view/stream_channel_list_view.dart @@ -409,7 +409,7 @@ class StreamChannelListErrorWidget extends StatelessWidget { TextSpan(text: context.translations.loadingChannelsError), ], ), - style: Theme.of(context).textTheme.headline6, + style: Theme.of(context).textTheme.titleLarge, ), TextButton( onPressed: onPressed, diff --git a/packages/stream_chat_flutter_core/test/stream_channel_test.dart b/packages/stream_chat_flutter_core/test/stream_channel_test.dart index 60a199f27..f4acf3c9c 100644 --- a/packages/stream_chat_flutter_core/test/stream_channel_test.dart +++ b/packages/stream_chat_flutter_core/test/stream_channel_test.dart @@ -94,7 +94,7 @@ void main() { final error = DioError( type: DioErrorType.badResponse, message: errorMessage, - requestOptions: RequestOptions(path: ''), + requestOptions: RequestOptions(), ); when(() => mockChannel.initialized) .thenAnswer((_) => Future.error(error)); diff --git a/packages/stream_chat_localizations/test/basics_test.dart b/packages/stream_chat_localizations/test/basics_test.dart index ae52a1af2..2c8bb4db9 100644 --- a/packages/stream_chat_localizations/test/basics_test.dart +++ b/packages/stream_chat_localizations/test/basics_test.dart @@ -103,7 +103,7 @@ class LocalizationTrackerState extends State { @override Widget build(BuildContext context) { - captionFontSize = Theme.of(context).textTheme.caption!.fontSize!; + captionFontSize = Theme.of(context).textTheme.bodySmall!.fontSize!; return Container(); } } From 4be55961e86beb2ef384a3531b687da6056fab94 Mon Sep 17 00:00:00 2001 From: Sahil Kumar Date: Tue, 4 Apr 2023 02:57:59 +0530 Subject: [PATCH 083/107] update dcm action Signed-off-by: xsahil03x --- .github/workflows/dart_code_metrics.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/dart_code_metrics.yaml b/.github/workflows/dart_code_metrics.yaml index 23be05617..18742e1f3 100644 --- a/.github/workflows/dart_code_metrics.yaml +++ b/.github/workflows/dart_code_metrics.yaml @@ -10,7 +10,7 @@ on: branches: - master - develop - + concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true @@ -37,35 +37,35 @@ jobs: run: melos bootstrap - name: "Stream Chat Metrics" - uses: dart-code-checker/dart-code-metrics-action@v2.0.0 + uses: dart-code-checker/dart-code-metrics-action@v3 with: github_token: ${{ secrets.GITHUB_TOKEN }} relative_path: 'packages/stream_chat' folders: ${{ env.folders }} - name: "Stream Chat Flutter Core Metrics" - uses: dart-code-checker/dart-code-metrics-action@v2.0.0 + uses: dart-code-checker/dart-code-metrics-action@v3 with: github_token: ${{ secrets.GITHUB_TOKEN }} relative_path: 'packages/stream_chat_flutter_core' folders: ${{ env.folders }} - name: "Stream Chat Flutter Metrics" - uses: dart-code-checker/dart-code-metrics-action@v2.0.0 + uses: dart-code-checker/dart-code-metrics-action@v3 with: github_token: ${{ secrets.GITHUB_TOKEN }} relative_path: 'packages/stream_chat_flutter' folders: ${{ env.folders }} - name: "Stream Chat Localizations Metrics" - uses: dart-code-checker/dart-code-metrics-action@v2.0.0 + uses: dart-code-checker/dart-code-metrics-action@v3 with: github_token: ${{ secrets.GITHUB_TOKEN }} relative_path: 'packages/stream_chat_localizations' folders: ${{ env.folders }} - name: "Stream Chat Persistence Metrics" - uses: dart-code-checker/dart-code-metrics-action@v2.0.0 + uses: dart-code-checker/dart-code-metrics-action@v3 with: github_token: ${{ secrets.GITHUB_TOKEN }} relative_path: 'packages/stream_chat_persistence' From cbc8eeddd8da5df53b5b5dfb9ebb1242c771573f Mon Sep 17 00:00:00 2001 From: Sahil Kumar Date: Tue, 4 Apr 2023 03:07:27 +0530 Subject: [PATCH 084/107] update action checkout Signed-off-by: xsahil03x --- .github/workflows/dart_code_metrics.yaml | 2 +- .github/workflows/docusaurus.yml | 2 +- .github/workflows/pana.yml | 8 ++++---- .github/workflows/stream_flutter_workflow.yml | 8 ++++---- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/dart_code_metrics.yaml b/.github/workflows/dart_code_metrics.yaml index 18742e1f3..52837c1e0 100644 --- a/.github/workflows/dart_code_metrics.yaml +++ b/.github/workflows/dart_code_metrics.yaml @@ -21,7 +21,7 @@ jobs: runs-on: ubuntu-latest steps: - name: "Git Checkout" - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: fetch-depth: 0 diff --git a/.github/workflows/docusaurus.yml b/.github/workflows/docusaurus.yml index f46fa8938..fc29804f8 100644 --- a/.github/workflows/docusaurus.yml +++ b/.github/workflows/docusaurus.yml @@ -11,7 +11,7 @@ jobs: push_docusaurus: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: push uses: GetStream/push-stream-chat-docusaurus-action@main with: diff --git a/.github/workflows/pana.yml b/.github/workflows/pana.yml index 39d2b898d..aa72f61a7 100644 --- a/.github/workflows/pana.yml +++ b/.github/workflows/pana.yml @@ -23,7 +23,7 @@ jobs: stream_chat: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: axel-op/dart-package-analyzer@v3 id: analysis with: @@ -43,7 +43,7 @@ jobs: stream_chat_persistence: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: axel-op/dart-package-analyzer@v3 id: analysis with: @@ -64,7 +64,7 @@ jobs: stream_chat_flutter_core: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: axel-op/dart-package-analyzer@v3 id: analysis with: @@ -84,7 +84,7 @@ jobs: stream_chat_flutter: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: axel-op/dart-package-analyzer@v3 id: analysis with: diff --git a/.github/workflows/stream_flutter_workflow.yml b/.github/workflows/stream_flutter_workflow.yml index 22d341b93..8e6df33b2 100644 --- a/.github/workflows/stream_flutter_workflow.yml +++ b/.github/workflows/stream_flutter_workflow.yml @@ -23,7 +23,7 @@ jobs: runs-on: ubuntu-latest steps: - name: "Git Checkout" - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: fetch-depth: 0 - name: "Install Flutter" @@ -50,7 +50,7 @@ jobs: timeout-minutes: 15 steps: - name: "Git Checkout" - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: fetch-depth: 0 - name: "Install Flutter" @@ -70,12 +70,12 @@ jobs: ./.github/workflows/scripts/validate-formatting.sh test: - runs-on: macos-latest + runs-on: ubuntu-latest if: github.event.pull_request.draft == false timeout-minutes: 30 steps: - name: "Git Checkout" - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: fetch-depth: 0 - name: "Install Flutter" From 23fae50fefd3d4ec05a20d95792965eaae9cd02a Mon Sep 17 00:00:00 2001 From: Sahil Kumar Date: Tue, 4 Apr 2023 15:31:10 +0530 Subject: [PATCH 085/107] update CHANGELOG.md Signed-off-by: xsahil03x --- packages/stream_chat/CHANGELOG.md | 1 + packages/stream_chat_flutter/CHANGELOG.md | 2 +- packages/stream_chat_flutter_core/CHANGELOG.md | 4 ++++ packages/stream_chat_persistence/CHANGELOG.md | 4 ++++ 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/stream_chat/CHANGELOG.md b/packages/stream_chat/CHANGELOG.md index 04a47600d..6b7301fcf 100644 --- a/packages/stream_chat/CHANGELOG.md +++ b/packages/stream_chat/CHANGELOG.md @@ -7,6 +7,7 @@ 🔄 Changed - Cancelling a attachment upload now removes the attachment from the message. +- Updated `dio` and other dependencies to resolvable versions. ✅ Added diff --git a/packages/stream_chat_flutter/CHANGELOG.md b/packages/stream_chat_flutter/CHANGELOG.md index cf0d43729..61ab52ccc 100644 --- a/packages/stream_chat_flutter/CHANGELOG.md +++ b/packages/stream_chat_flutter/CHANGELOG.md @@ -12,7 +12,7 @@ 🔄 Changed -- Updated `share_plus` dependency to `^6.3.0` +- Updated dependencies to resolvable versions. ## 5.3.0 diff --git a/packages/stream_chat_flutter_core/CHANGELOG.md b/packages/stream_chat_flutter_core/CHANGELOG.md index 60d41e058..6f26af264 100644 --- a/packages/stream_chat_flutter_core/CHANGELOG.md +++ b/packages/stream_chat_flutter_core/CHANGELOG.md @@ -1,3 +1,7 @@ +## Upcoming + +- Updated dependencies to resolvable versions. + ## 5.3.0 - Updated `stream_chat` dependency to [`5.3.0`](https://pub.dev/packages/stream_chat/changelog). diff --git a/packages/stream_chat_persistence/CHANGELOG.md b/packages/stream_chat_persistence/CHANGELOG.md index 5622e0ab1..e0dabaa73 100644 --- a/packages/stream_chat_persistence/CHANGELOG.md +++ b/packages/stream_chat_persistence/CHANGELOG.md @@ -1,3 +1,7 @@ +## Upcoming + +- Updated dependencies to resolvable versions. + ## 5.1.0 - Reintroduce support for experimental indexedDB on Web. From 125014848af7bd11d75519ad4a4101e66bb65aaa Mon Sep 17 00:00:00 2001 From: Sahil Kumar Date: Tue, 4 Apr 2023 17:33:57 +0530 Subject: [PATCH 086/107] fix(llc): make message.i18n readonly Signed-off-by: xsahil03x --- packages/stream_chat/lib/src/core/models/message.dart | 2 +- packages/stream_chat/lib/src/core/models/message.g.dart | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/stream_chat/lib/src/core/models/message.dart b/packages/stream_chat/lib/src/core/models/message.dart index 017bb06fc..3645b00af 100644 --- a/packages/stream_chat/lib/src/core/models/message.dart +++ b/packages/stream_chat/lib/src/core/models/message.dart @@ -217,7 +217,7 @@ class Message extends Equatable { bool get isEphemeral => type == 'ephemeral'; /// A Map of translations. - @JsonKey(includeIfNull: false) + @JsonKey(includeIfNull: false, toJson: Serializer.readOnly) final Map? i18n; /// Known top level fields. diff --git a/packages/stream_chat/lib/src/core/models/message.g.dart b/packages/stream_chat/lib/src/core/models/message.g.dart index e2ff89b49..695e6332f 100644 --- a/packages/stream_chat/lib/src/core/models/message.g.dart +++ b/packages/stream_chat/lib/src/core/models/message.g.dart @@ -108,6 +108,6 @@ Map _$MessageToJson(Message instance) { val['pin_expires'] = instance.pinExpires?.toIso8601String(); val['pinned_by'] = readonly(instance.pinnedBy); val['extra_data'] = instance.extraData; - writeNotNull('i18n', instance.i18n); + writeNotNull('i18n', readonly(instance.i18n)); return val; } From 3bddca8b29c0b691b9187b1d7d0c943d30d2460a Mon Sep 17 00:00:00 2001 From: Sahil Kumar Date: Tue, 4 Apr 2023 17:34:52 +0530 Subject: [PATCH 087/107] chore(llc): update CHANGELOG.md Signed-off-by: xsahil03x --- packages/stream_chat/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/stream_chat/CHANGELOG.md b/packages/stream_chat/CHANGELOG.md index 04a47600d..cd32c621e 100644 --- a/packages/stream_chat/CHANGELOG.md +++ b/packages/stream_chat/CHANGELOG.md @@ -3,6 +3,7 @@ 🐞 Fixed - Fixed streamWatchers. Before it was always new, now it is possible to follow the watchers of a channel. +- Make `Message.i18n` field read-only. 🔄 Changed From 3e6fc826ee144768af2d58cb809d84d790f1f6d3 Mon Sep 17 00:00:00 2001 From: Sahil Kumar Date: Tue, 4 Apr 2023 18:09:08 +0530 Subject: [PATCH 088/107] chore(llc): json annotation changes Signed-off-by: xsahil03x --- .../lib/src/core/models/attachment.dart | 1 - .../lib/src/core/models/channel_model.dart | 1 - .../lib/src/core/models/message.dart | 9 ++--- .../lib/src/core/models/message.g.dart | 40 ++++++------------- .../lib/src/core/models/reaction.dart | 1 - .../stream_chat/lib/src/core/models/user.dart | 1 - .../lib/src/core/util/serializer.dart | 7 ---- 7 files changed, 17 insertions(+), 43 deletions(-) diff --git a/packages/stream_chat/lib/src/core/models/attachment.dart b/packages/stream_chat/lib/src/core/models/attachment.dart index c757a174d..bceaaacc8 100644 --- a/packages/stream_chat/lib/src/core/models/attachment.dart +++ b/packages/stream_chat/lib/src/core/models/attachment.dart @@ -135,7 +135,6 @@ class Attachment extends Equatable { late final UploadState uploadState; /// Map of custom channel extraData - @JsonKey(includeIfNull: false) final Map extraData; /// The attachment ID. diff --git a/packages/stream_chat/lib/src/core/models/channel_model.dart b/packages/stream_chat/lib/src/core/models/channel_model.dart index b3523743b..00fa1fccb 100644 --- a/packages/stream_chat/lib/src/core/models/channel_model.dart +++ b/packages/stream_chat/lib/src/core/models/channel_model.dart @@ -122,7 +122,6 @@ class ChannelModel { } /// Map of custom channel extraData - @JsonKey(includeIfNull: false) final Map extraData; /// The team the channel belongs to diff --git a/packages/stream_chat/lib/src/core/models/message.dart b/packages/stream_chat/lib/src/core/models/message.dart index 6f3a5b13d..f8631e1c0 100644 --- a/packages/stream_chat/lib/src/core/models/message.dart +++ b/packages/stream_chat/lib/src/core/models/message.dart @@ -131,7 +131,7 @@ class Message extends Equatable { final String? parentId; /// A quoted reply message. - @JsonKey(toJson: Serializer.readOnly) + @JsonKey(includeToJson: false) final Message? quotedMessage; final String? _quotedMessageId; @@ -185,7 +185,7 @@ class Message extends Equatable { final bool pinned; /// Reserved field indicating when the message was pinned. - @JsonKey(toJson: Serializer.readOnly) + @JsonKey(includeToJson: false) final DateTime? pinnedAt; /// Reserved field indicating when the message will expire. @@ -194,11 +194,10 @@ class Message extends Equatable { final DateTime? pinExpires; /// Reserved field indicating who pinned the message. - @JsonKey(toJson: Serializer.readOnly) + @JsonKey(includeToJson: false) final User? pinnedBy; /// Message custom extraData. - @JsonKey(includeIfNull: false) final Map extraData; /// True if the message is a system info. @@ -211,7 +210,7 @@ class Message extends Equatable { bool get isEphemeral => type == 'ephemeral'; /// A Map of translations. - @JsonKey(includeIfNull: false) + @JsonKey(includeToJson: false) final Map? i18n; /// Known top level fields. diff --git a/packages/stream_chat/lib/src/core/models/message.g.dart b/packages/stream_chat/lib/src/core/models/message.g.dart index cbf849cc0..506ac7a96 100644 --- a/packages/stream_chat/lib/src/core/models/message.g.dart +++ b/packages/stream_chat/lib/src/core/models/message.g.dart @@ -71,30 +71,16 @@ Message _$MessageFromJson(Map json) => Message( ), ); -Map _$MessageToJson(Message instance) { - final val = { - 'id': instance.id, - 'text': instance.text, - 'attachments': instance.attachments.map((e) => e.toJson()).toList(), - 'mentioned_users': User.toIds(instance.mentionedUsers), - 'parent_id': instance.parentId, - 'quoted_message': readonly(instance.quotedMessage), - 'quoted_message_id': instance.quotedMessageId, - 'show_in_channel': instance.showInChannel, - 'silent': instance.silent, - 'pinned': instance.pinned, - 'pinned_at': readonly(instance.pinnedAt), - 'pin_expires': instance.pinExpires?.toIso8601String(), - 'pinned_by': readonly(instance.pinnedBy), - 'extra_data': instance.extraData, - }; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('i18n', instance.i18n); - return val; -} +Map _$MessageToJson(Message instance) => { + 'id': instance.id, + 'text': instance.text, + 'attachments': instance.attachments.map((e) => e.toJson()).toList(), + 'mentioned_users': User.toIds(instance.mentionedUsers), + 'parent_id': instance.parentId, + 'quoted_message_id': instance.quotedMessageId, + 'show_in_channel': instance.showInChannel, + 'silent': instance.silent, + 'pinned': instance.pinned, + 'pin_expires': instance.pinExpires?.toIso8601String(), + 'extra_data': instance.extraData, + }; diff --git a/packages/stream_chat/lib/src/core/models/reaction.dart b/packages/stream_chat/lib/src/core/models/reaction.dart index 2bc6f52ba..474b6dff6 100644 --- a/packages/stream_chat/lib/src/core/models/reaction.dart +++ b/packages/stream_chat/lib/src/core/models/reaction.dart @@ -48,7 +48,6 @@ class Reaction { final String? userId; /// Reaction custom extraData - @JsonKey(includeIfNull: false) final Map extraData; /// Map of custom user extraData diff --git a/packages/stream_chat/lib/src/core/models/user.dart b/packages/stream_chat/lib/src/core/models/user.dart index ca60e6148..a280d18c5 100644 --- a/packages/stream_chat/lib/src/core/models/user.dart +++ b/packages/stream_chat/lib/src/core/models/user.dart @@ -131,7 +131,6 @@ class User extends Equatable { final String? language; /// Map of custom user extraData. - @JsonKey(includeIfNull: false) final Map extraData; /// List of users to list of userIds. diff --git a/packages/stream_chat/lib/src/core/util/serializer.dart b/packages/stream_chat/lib/src/core/util/serializer.dart index 2bf92e39a..9c1cb71f6 100644 --- a/packages/stream_chat/lib/src/core/util/serializer.dart +++ b/packages/stream_chat/lib/src/core/util/serializer.dart @@ -1,12 +1,5 @@ -/// Used to avoid to serialize properties to json -// ignore: prefer_void_to_null -Null readonly(_) => null; - /// Helper class for serialization to and from json class Serializer { - /// Used to avoid to serialize properties to json - static const Function readOnly = readonly; - /// Takes unknown json keys and puts them in the `extra_data` key static Map moveToExtraDataFromRoot( Map json, From 05681f73a9cb626ce455038a833a8168792faf75 Mon Sep 17 00:00:00 2001 From: Sahil Kumar Date: Wed, 5 Apr 2023 15:22:14 +0530 Subject: [PATCH 089/107] test(llc): fix test Signed-off-by: xsahil03x --- .../stream_chat/test/src/core/api/message_api_test.dart | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/stream_chat/test/src/core/api/message_api_test.dart b/packages/stream_chat/test/src/core/api/message_api_test.dart index ed7fefd62..8ae82e94f 100644 --- a/packages/stream_chat/test/src/core/api/message_api_test.dart +++ b/packages/stream_chat/test/src/core/api/message_api_test.dart @@ -394,7 +394,12 @@ void main() { path, data: {'language': language}, )).thenAnswer((_) async => successResponse(path, data: { - 'message': translatedMessage.toJson(), + 'message': { + ...translatedMessage.toJson(), + 'i18n': { + language: translatedMessageText, + }, + }, })); final res = await messageApi.translateMessage(messageId, language); From 19339c1fde6fcfa51a9fa6da8d7461e681bb712c Mon Sep 17 00:00:00 2001 From: Sahil Kumar Date: Wed, 5 Apr 2023 16:25:57 +0530 Subject: [PATCH 090/107] test(llc): fix test Signed-off-by: xsahil03x --- .../test/fixtures/channel_state_to_json.json | 126 ++++-------------- .../test/fixtures/message_to_json.json | 3 - 2 files changed, 25 insertions(+), 104 deletions(-) diff --git a/packages/stream_chat/test/fixtures/channel_state_to_json.json b/packages/stream_chat/test/fixtures/channel_state_to_json.json index c0c06f9ea..aedc5ccd5 100644 --- a/packages/stream_chat/test/fixtures/channel_state_to_json.json +++ b/packages/stream_chat/test/fixtures/channel_state_to_json.json @@ -1,4 +1,3 @@ - { "channel": { "id": "dev", @@ -18,400 +17,325 @@ "text": "fasdfa", "attachments": [], "parent_id": null, - "quoted_message": null, "quoted_message_id": null, "show_in_channel": null, "mentioned_users": [], "status": "SENT", "silent": false, "pinned": false, - "pinned_at": null, - "pin_expires": null, - "pinned_by": null + "pin_expires": null }, { "id": "dry-meadow-0-e8e74482-b4cd-48db-9d1e-30e6c191786f", "text": "test message", "attachments": [], "parent_id": null, - "quoted_message": null, "quoted_message_id": null, "show_in_channel": null, "mentioned_users": [], "status": "SENT", "silent": false, "pinned": false, - "pinned_at": null, - "pin_expires": null, - "pinned_by": null + "pin_expires": null }, { "id": "dry-meadow-0-53e6299f-9b97-4a9c-a27e-7e2dde49b7e0", "text": "test message", "attachments": [], "parent_id": null, - "quoted_message": null, "quoted_message_id": null, "show_in_channel": null, "mentioned_users": [], "status": "SENT", "silent": false, "pinned": false, - "pinned_at": null, - "pin_expires": null, - "pinned_by": null + "pin_expires": null }, { "id": "dry-meadow-0-80925be0-786e-40a5-b225-486518dafd35", "text": "asdfadf", "attachments": [], "parent_id": null, - "quoted_message": null, "quoted_message_id": null, "show_in_channel": null, "mentioned_users": [], "status": "SENT", "silent": false, "pinned": false, - "pinned_at": null, - "pin_expires": null, - "pinned_by": null + "pin_expires": null }, { "id": "dry-meadow-0-64d7970f-ede8-4b31-9738-1bc1756d2bfe", "text": "test", "attachments": [], "parent_id": null, - "quoted_message": null, "quoted_message_id": null, "show_in_channel": null, "mentioned_users": [], "status": "SENT", "silent": false, "pinned": false, - "pinned_at": null, - "pin_expires": null, - "pinned_by": null + "pin_expires": null }, { "id": "withered-cell-0-84cbd760-cf55-4f7e-9207-c5f66cccc6dc", "text": "hi", "attachments": [], "parent_id": null, - "quoted_message": null, "quoted_message_id": null, "show_in_channel": null, "mentioned_users": [], "status": "SENT", "silent": false, "pinned": false, - "pinned_at": null, - "pin_expires": null, - "pinned_by": null + "pin_expires": null }, { "id": "dry-meadow-0-e9203588-43c3-40b1-91f7-f217fc42aa53", "text": "fantastic", "attachments": [], "parent_id": null, - "quoted_message": null, "quoted_message_id": null, "show_in_channel": null, "mentioned_users": [], "status": "SENT", "silent": false, "pinned": false, - "pinned_at": null, - "pin_expires": null, - "pinned_by": null + "pin_expires": null }, { "id": "withered-cell-0-7e3552d7-7a0d-45f2-a856-e91b23a7e240", "text": "nice to meet you", "attachments": [], "parent_id": null, - "quoted_message": null, "quoted_message_id": null, "show_in_channel": null, "mentioned_users": [], "status": "SENT", "silent": false, "pinned": false, - "pinned_at": null, - "pin_expires": null, - "pinned_by": null + "pin_expires": null }, { "id": "dry-meadow-0-1ffeafd4-e4fc-4c84-9394-9d7cb10fff42", "text": "hey", "attachments": [], "parent_id": null, - "quoted_message": null, "quoted_message_id": null, "show_in_channel": null, "mentioned_users": [], "status": "SENT", "silent": false, "pinned": false, - "pinned_at": null, - "pin_expires": null, - "pinned_by": null + "pin_expires": null }, { "id": "dry-meadow-0-3f147324-12c8-4b41-9fb5-2db88d065efa", "text": "hello, everyone", "attachments": [], "parent_id": null, - "quoted_message": null, "quoted_message_id": null, "show_in_channel": null, "mentioned_users": [], "status": "SENT", "silent": false, "pinned": false, - "pinned_at": null, - "pin_expires": null, - "pinned_by": null + "pin_expires": null }, { "id": "dry-meadow-0-51a348ae-0c0a-44de-a556-eac7891c0cf0", "text": "who is there?", "attachments": [], "parent_id": null, - "quoted_message": null, "quoted_message_id": null, "show_in_channel": null, "mentioned_users": [], "status": "SENT", "silent": false, "pinned": false, - "pinned_at": null, - "pin_expires": null, - "pinned_by": null + "pin_expires": null }, { "id": "icy-recipe-7-a29e237b-8d81-4a97-9bc8-d42bca3f1356", "text": "하이", "attachments": [], "parent_id": null, - "quoted_message": null, "quoted_message_id": null, "show_in_channel": null, "mentioned_users": [], "status": "SENT", "silent": false, "pinned": false, - "pinned_at": null, - "pin_expires": null, - "pinned_by": null + "pin_expires": null }, { "id": "icy-recipe-7-935c396e-ddf8-4a9a-951c-0a12fa5bf055", "text": "what are you doing?", "attachments": [], "parent_id": null, - "quoted_message": null, "quoted_message_id": null, "show_in_channel": null, "mentioned_users": [], "status": "SENT", "silent": false, "pinned": false, - "pinned_at": null, - "pin_expires": null, - "pinned_by": null + "pin_expires": null }, { "id": "throbbing-boat-5-1e4d5730-5ff0-4d25-9948-9f34ffda43e4", "text": "👍", "attachments": [], "parent_id": null, - "quoted_message": null, "quoted_message_id": null, "show_in_channel": null, "mentioned_users": [], "status": "SENT", "silent": false, "pinned": false, - "pinned_at": null, - "pin_expires": null, - "pinned_by": null + "pin_expires": null }, { "id": "snowy-credit-3-3e0c1a0d-d22f-42ee-b2a1-f9f49477bf21", "text": "sdasas", "attachments": [], "parent_id": null, - "quoted_message": null, "quoted_message_id": null, "show_in_channel": null, "mentioned_users": [], "status": "SENT", "silent": false, "pinned": false, - "pinned_at": null, - "pin_expires": null, - "pinned_by": null + "pin_expires": null }, { "id": "snowy-credit-3-3319537e-2d0e-4876-8170-a54f046e4b7d", "text": "cjshsa", "attachments": [], "parent_id": null, - "quoted_message": null, "quoted_message_id": null, "show_in_channel": null, "mentioned_users": [], "status": "SENT", "silent": false, "pinned": false, - "pinned_at": null, - "pin_expires": null, - "pinned_by": null + "pin_expires": null }, { "id": "snowy-credit-3-cfaf0b46-1daa-49c5-947c-b16d6697487d", "text": "nhisagdhsadz", "attachments": [], "parent_id": null, - "quoted_message": null, "quoted_message_id": null, "show_in_channel": null, "mentioned_users": [], "status": "SENT", "silent": false, "pinned": false, - "pinned_at": null, - "pin_expires": null, - "pinned_by": null + "pin_expires": null }, { "id": "snowy-credit-3-cebe25a7-a3a3-49fc-9919-91c6725e81f3", "text": "hvadhsahzd", "attachments": [], "parent_id": null, - "quoted_message": null, "quoted_message_id": null, "show_in_channel": null, "mentioned_users": [], "status": "SENT", "silent": false, "pinned": false, - "pinned_at": null, - "pin_expires": null, - "pinned_by": null + "pin_expires": null }, { "id": "divine-glade-9-0cea9262-5766-48e9-8b22-311870aed3bf", "text": "hello", "attachments": [], "parent_id": null, - "quoted_message": null, "quoted_message_id": null, "show_in_channel": null, "mentioned_users": [], "status": "SENT", "silent": false, "pinned": false, - "pinned_at": null, - "pin_expires": null, - "pinned_by": null + "pin_expires": null }, { "id": "red-firefly-9-c4e9007b-bb7d-4238-ae08-5f8e3cd03d73", "text": "hello", "attachments": [], "parent_id": null, - "quoted_message": null, "quoted_message_id": null, "show_in_channel": null, "mentioned_users": [], "status": "SENT", "silent": false, "pinned": false, - "pinned_at": null, - "pin_expires": null, - "pinned_by": null + "pin_expires": null }, { "id": "bitter-glade-2-02aee4eb-4093-4736-808b-2de75820e854", "text": "hello", "attachments": [], "parent_id": null, - "quoted_message": null, "quoted_message_id": null, "show_in_channel": null, "mentioned_users": [], "status": "SENT", "silent": false, "pinned": false, - "pinned_at": null, - "pin_expires": null, - "pinned_by": null + "pin_expires": null }, { "id": "morning-sea-1-0c700bcb-46dd-4224-b590-e77bdbccc480", "text": "http://jaeger.ui.gtstrm.com/", "attachments": [], "parent_id": null, - "quoted_message": null, "quoted_message_id": null, "show_in_channel": null, "mentioned_users": [], "status": "SENT", "silent": false, "pinned": false, - "pinned_at": null, - "pin_expires": null, - "pinned_by": null + "pin_expires": null }, { "id": "ancient-salad-0-53e8b4e6-5b7b-43ad-aeee-8bfb6a9ed0be", "text": "hi", "attachments": [], "parent_id": null, - "quoted_message": null, "quoted_message_id": null, "show_in_channel": null, "mentioned_users": [], "status": "SENT", "silent": false, "pinned": false, - "pinned_at": null, - "pin_expires": null, - "pinned_by": null + "pin_expires": null }, { "id": "ancient-salad-0-8c225075-bd4c-42e2-8024-530aae13cd40", "text": "hi", "attachments": [], "parent_id": null, - "quoted_message": null, "quoted_message_id": null, "show_in_channel": null, "mentioned_users": [], "status": "SENT", "silent": false, "pinned": false, - "pinned_at": null, - "pin_expires": null, - "pinned_by": null + "pin_expires": null }, { "id": "proud-sea-7-17802096-cbf8-4e3c-addd-4ee31f4c8b5c", "text": "😃", "attachments": [], "parent_id": null, - "quoted_message": null, "quoted_message_id": null, "show_in_channel": null, "mentioned_users": [], "status": "SENT", "silent": false, "pinned": false, - "pinned_at": null, - "pin_expires": null, - "pinned_by": null + "pin_expires": null } ], "pinned_messages": [], diff --git a/packages/stream_chat/test/fixtures/message_to_json.json b/packages/stream_chat/test/fixtures/message_to_json.json index b3b1dd6b3..bfd9d71c3 100644 --- a/packages/stream_chat/test/fixtures/message_to_json.json +++ b/packages/stream_chat/test/fixtures/message_to_json.json @@ -18,12 +18,9 @@ ], "mentioned_users": [], "parent_id": "parentId", - "quoted_message": null, "quoted_message_id": null, "pinned": false, - "pinned_at": null, "pin_expires": null, - "pinned_by": null, "show_in_channel": true, "hey": "test" } \ No newline at end of file From d94a059c55525fedbdcadf20cde627faa838ea46 Mon Sep 17 00:00:00 2001 From: Sahil Kumar Date: Fri, 7 Apr 2023 02:08:04 +0530 Subject: [PATCH 091/107] update .styles Signed-off-by: xsahil03x --- .styles/Google/We.yml | 11 ----------- .vale.ini | 8 +++----- 2 files changed, 3 insertions(+), 16 deletions(-) delete mode 100644 .styles/Google/We.yml diff --git a/.styles/Google/We.yml b/.styles/Google/We.yml deleted file mode 100644 index c7ac7d362..000000000 --- a/.styles/Google/We.yml +++ /dev/null @@ -1,11 +0,0 @@ -extends: existence -message: "Try to avoid using first-person plural like '%s'." -link: 'https://developers.google.com/style/pronouns#personal-pronouns' -level: warning -ignorecase: true -tokens: - - we - - we'(?:ve|re) - - ours? - - us - - let's diff --git a/.vale.ini b/.vale.ini index 5e1c46bf7..f295edcae 100644 --- a/.vale.ini +++ b/.vale.ini @@ -9,11 +9,9 @@ Packages = Google # with one of Vale's supported formats. [formats] mdx = md - + # Since we mapped `mdx` to `md` in the `formats`section we have to declare our format to be `md` [*.md] BasedOnStyles = Vale, Google -# TokenIgnores = ("integrationguide"), ^<[ ]{0}img(.*)+[ ]{0}/>$, <[ ]{0}img(.*\n)+/> -# BlockIgnores = import \w* from '.*', \w*\.gradle - - +BlockIgnores = (^import .*;), (import .*;), (\n(.*\n)+
), (\| .* \|) +TokenIgnores = (^import .*;),(import .*;) From d7e6878a6006b164b10146937ff681f31742ca85 Mon Sep 17 00:00:00 2001 From: Sahil Kumar Date: Fri, 7 Apr 2023 02:21:54 +0530 Subject: [PATCH 092/107] update vale workflow and lints. Signed-off-by: xsahil03x --- .github/workflows/vale-doc-lint.yml | 17 ++++++++++------- .../adding_push_notifications_v2.mdx | 18 +++++++++--------- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/.github/workflows/vale-doc-lint.yml b/.github/workflows/vale-doc-lint.yml index 2ef15f471..d0253fb43 100644 --- a/.github/workflows/vale-doc-lint.yml +++ b/.github/workflows/vale-doc-lint.yml @@ -1,4 +1,4 @@ -name: Check Docusaurus docs with Vale linter +name: Check Docusaurus docs with vale linter on: [pull_request] @@ -7,16 +7,19 @@ jobs: name: Vale doc linter runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: errata-ai/vale-action@reviewdog with: # added, diff_context, file, nofilter + # Default is added: results are filtered for added/modified files. Set to no filter when all files need to be checked. + # More info: https://github.com/errata-ai/vale-action and https://github.com/reviewdog/reviewdog#filter-mode filter_mode: nofilter # github-pr-check, github-pr-review, github-check reporter: github-pr-check + # Set fail_on_error to true to make sure builds fail. fail_on_error: true - files: docusaurus - env: - # Required, set by GitHub actions automatically: - # https://docs.github.com/en/actions/security-guides/automatic-token-authentication#about-the-github_token-secret - GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} + files: '["docusaurus", "README.md"]' + env: + # Required, set by GitHub actions automatically: + # https://docs.github.com/en/actions/security-guides/automatic-token-authentication#about-the-github_token-secret + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} diff --git a/docusaurus/docs/Flutter/05-guides/05-push-notifications/adding_push_notifications_v2.mdx b/docusaurus/docs/Flutter/05-guides/05-push-notifications/adding_push_notifications_v2.mdx index 8459b3234..c0678e3b0 100644 --- a/docusaurus/docs/Flutter/05-guides/05-push-notifications/adding_push_notifications_v2.mdx +++ b/docusaurus/docs/Flutter/05-guides/05-push-notifications/adding_push_notifications_v2.mdx @@ -54,7 +54,7 @@ Push notifications require membership. Watching a channel isn't enough. ### Setup FCM -To integrate push notifications in your Flutter app, you need to use the package [firebase_messaging](https://pub.dev/packages/firebase_messaging). +To integrate push notifications in your Flutter app, you need to use the package [`firebase_messaging`](https://pub.dev/packages/firebase_messaging). Follow the [Flutter Firebase documentation](https://firebase.flutter.dev/docs/messaging/overview/) to set up the plugin for Android and iOS. Additional setup and instructions can be found [here](https://firebase.google.com/docs/cloud-messaging/flutter/client). Be sure to read this documentation to understand Firebase messaging functionality. @@ -91,7 +91,7 @@ You can upload your Firebase credentials using either the dashboard or the app s ![](../../assets/firebase_notifications_toggle-5aeabfcbdc24cb8f1fea7d41d0e845fc.png) -3. Enter your Firebase Credentials and press "Save". +3. Enter your Firebase Credentials and press `"Save"`. ##### Using the API @@ -123,7 +123,7 @@ firebaseMessaging.onTokenRefresh.listen((token) { }); ``` -Push Notifications v2 also supports specifying a name for the push device tokens you register. By setting the optional `pushProviderName` param in the `addDevice` call, you can support different configurations between the device and the `PushProvider`. +Push Notifications v2 also supports specifying a name for the push device tokens you register. By setting the optional `pushProviderName` parameter in the `addDevice` call, you can support different configurations between the device and the `PushProvider`. ```dart firebaseMessaging.onTokenRefresh.listen((token) { @@ -181,7 +181,7 @@ The code below demonstrates how to generate a notification when a **data-only** There are a few things to keep in mind about your background message handler: 1. It must not be an anonymous function. -2. It must be a top-level function (e.g. not a class method which requires initialization). +2. It must be a top-level function (not a class method which requires initialization). 3. It must be annotated with @pragma('vm:entry-point') right above the function declaration (otherwise it may be removed during tree shaking for release mode). For additional information on background messages, please see the [Firebase documentation](https://firebase.google.com/docs/cloud-messaging/flutter/receive#background_messages). @@ -228,7 +228,7 @@ void handleNotification( FirebaseMessaging.onBackgroundMessage(onBackgroundMessage); ``` -In the above example, you get the message details using the `getMessage` method, and then you use the [flutter_local_notifications](https://pub.dev/packages/flutter_local_notifications) package to show the actual notification. +In the above example, you get the message details using the `getMessage` method, and then you use the [`flutter_local_notifications`](https://pub.dev/packages/flutter_local_notifications) package to show the actual notification. ##### Using a Template on Android @@ -258,12 +258,12 @@ Make sure to read the [general push notification docs](https://getstream.io/chat ### Testing if Push Notifications are Setup Correctly -If you're not sure whether you've set up push notifications correctly, for example, you don't always receive them, or they don’t work reliably, then you can follow these steps to make sure your config is correct and working: +If you're not sure whether you've set up push notifications correctly, for example, you don't always receive them, or they don’t work reliably, then you can follow these steps to make sure your configuration is correct and working: -1. Clone our repo for push testing: `git clone git@github.com:GetStream/chat-push-test.git` +1. Clone our repository for push testing: `git clone git@github.com:GetStream/chat-push-test.git` 2. `cd flutter` 3. In that folder run `flutter pub get` -4. Input your api key and secret in `lib/main.dart` +4. Input your API key and secret in `lib/main.dart` 5. Change the bundle identifier/application ID and development team/user so you can run the app on your physical device.**Do not** run on an iOS simulator, as it will not work. Testing on an Android emulator is fine. 6. Add your `google-services.json/GoogleService-Info.plist` 7. Run the app @@ -306,7 +306,7 @@ Take a look at the [Stream Chat v1 sample app](https://github.com/GetStream/flut When the app is closed, you can save incoming messages when you receive them via a notification so that they're already there later when you open the app. -To do this, you need to integrate the package [stream_chat_persistence](https://pub.dev/packages/stream_chat_persistence) that exports a persistence client. See [here](https://pub.dev/packages/stream_chat_persistence#usage) for information on how to set it up. +To do this, you need to integrate the package [`stream_chat_persistence`](https://pub.dev/packages/stream_chat_persistence) that exports a persistence client. See [here](https://pub.dev/packages/stream_chat_persistence#usage) for information on how to set it up. Then calling `FirebaseMessaging.onBackgroundMessage(...)` you need to use a TOP-LEVEL or STATIC function to handle background messages. From eabb9d778b68b3990b8fe6da171fdc1721062c14 Mon Sep 17 00:00:00 2001 From: Sahil Kumar Date: Fri, 7 Apr 2023 02:28:18 +0530 Subject: [PATCH 093/107] add path check to package workflows Signed-off-by: xsahil03x --- .github/workflows/dart_code_metrics.yaml | 2 ++ .github/workflows/stream_flutter_workflow.yml | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/dart_code_metrics.yaml b/.github/workflows/dart_code_metrics.yaml index 52837c1e0..a5ffc54df 100644 --- a/.github/workflows/dart_code_metrics.yaml +++ b/.github/workflows/dart_code_metrics.yaml @@ -6,6 +6,8 @@ env: on: pull_request: + paths: + - 'packages/**' push: branches: - master diff --git a/.github/workflows/stream_flutter_workflow.yml b/.github/workflows/stream_flutter_workflow.yml index 8e6df33b2..af57f49f6 100644 --- a/.github/workflows/stream_flutter_workflow.yml +++ b/.github/workflows/stream_flutter_workflow.yml @@ -6,7 +6,8 @@ env: on: pull_request: - types: [opened, synchronize, reopened, ready_for_review, converted_to_draft] + paths: + - 'packages/**' push: branches: - master From 3eb1756f706bd218a1b062309a72cf213d8ae195 Mon Sep 17 00:00:00 2001 From: Sahil Kumar Date: Fri, 7 Apr 2023 02:57:54 +0530 Subject: [PATCH 094/107] Update docusaurus.yml --- .github/workflows/docusaurus.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/docusaurus.yml b/.github/workflows/docusaurus.yml index fc29804f8..5a234e8f4 100644 --- a/.github/workflows/docusaurus.yml +++ b/.github/workflows/docusaurus.yml @@ -9,12 +9,17 @@ on: - docusaurus/** jobs: push_docusaurus: + name: Publish docusaurus docs runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 + - name: Setup Node 16 + uses: actions/setup-node@v3 + with: + node-version: 16 - name: push uses: GetStream/push-stream-chat-docusaurus-action@main with: target-branch: ${{ github.ref == 'refs/heads/master' && 'production' || 'staging' }} env: - DOCUSAURUS_GH_TOKEN: ${{ secrets.DOCUSAURUS_GH_TOKEN }} \ No newline at end of file + DOCUSAURUS_GH_TOKEN: ${{ secrets.DOCUSAURUS_GH_TOKEN }} From 69ec1d8935e56377318380bbd6d38973c986a1e5 Mon Sep 17 00:00:00 2001 From: Sahil Kumar Date: Fri, 7 Apr 2023 05:56:41 +0530 Subject: [PATCH 095/107] fix predicate checks only for keyUp events. Signed-off-by: xsahil03x --- .../message_input/stream_message_input.dart | 40 ++++++++++--------- .../lib/src/utils/typedefs.dart | 4 +- 2 files changed, 24 insertions(+), 20 deletions(-) diff --git a/packages/stream_chat_flutter/lib/src/message_input/stream_message_input.dart b/packages/stream_chat_flutter/lib/src/message_input/stream_message_input.dart index 747487c88..b479b5cea 100644 --- a/packages/stream_chat_flutter/lib/src/message_input/stream_message_input.dart +++ b/packages/stream_chat_flutter/lib/src/message_input/stream_message_input.dart @@ -117,10 +117,10 @@ class StreamMessageInput extends StatefulWidget { }); /// The predicate used to send a message on desktop/web - final RawKeyEventPredicate? sendMessageKeyPredicate; + final KeyEventPredicate sendMessageKeyPredicate; /// The predicate used to clear the quoted message on desktop/web - final RawKeyEventPredicate? clearQuotedMessageKeyPredicate; + final KeyEventPredicate clearQuotedMessageKeyPredicate; /// If true the message input will animate the actions while you type final bool enableActionAnimation; @@ -264,15 +264,19 @@ class StreamMessageInput extends StatefulWidget { static bool _defaultSendMessageKeyPredicate( FocusNode node, - RawKeyEvent event, - ) => - event.logicalKey == LogicalKeyboardKey.enter; + KeyEvent event, + ) { + // On desktop/web, send the message when the user presses the enter key. + return event is KeyUpEvent && event.logicalKey == LogicalKeyboardKey.enter; + } static bool _defaultClearQuotedMessageKeyPredicate( FocusNode node, - RawKeyEvent event, - ) => - event.logicalKey == LogicalKeyboardKey.escape; + KeyEvent event, + ) { + // On desktop/web, clear the quoted message when the user presses the escape key. + return event is KeyUpEvent && event.logicalKey == LogicalKeyboardKey.escape; + } @override StreamMessageInputState createState() => StreamMessageInputState(); @@ -773,11 +777,11 @@ class StreamMessageInputState extends State maxHeight: widget.maxHeight, child: PlatformWidgetBuilder( web: (context, child) => Focus( - onKey: _handleKeyPressed, + onKeyEvent: _handleKeyPressed, child: child!, ), desktop: (context, child) => Focus( - onKey: _handleKeyPressed, + onKeyEvent: _handleKeyPressed, child: child!, ), mobile: (context, child) => child, @@ -808,22 +812,22 @@ class StreamMessageInputState extends State ); } - KeyEventResult _handleKeyPressed( - FocusNode node, - RawKeyEvent event, - ) { - if (widget.sendMessageKeyPredicate != null && - widget.sendMessageKeyPredicate!(node, event)) { + KeyEventResult _handleKeyPressed(FocusNode node, KeyEvent event) { + // Check for send message key. + if (widget.sendMessageKeyPredicate(node, event)) { sendMessage(); return KeyEventResult.handled; - } else if (widget.clearQuotedMessageKeyPredicate != null && - widget.clearQuotedMessageKeyPredicate!(node, event)) { + } + + // Check for clear quoted message key. + if (widget.clearQuotedMessageKeyPredicate(node, event)) { if (_hasQuotedMessage && _effectiveController.text.isEmpty) { widget.onQuotedMessageCleared?.call(); } return KeyEventResult.handled; } + // Return ignored to allow other key events to be handled. return KeyEventResult.ignored; } diff --git a/packages/stream_chat_flutter/lib/src/utils/typedefs.dart b/packages/stream_chat_flutter/lib/src/utils/typedefs.dart index fda46b2dc..6cc581bf0 100644 --- a/packages/stream_chat_flutter/lib/src/utils/typedefs.dart +++ b/packages/stream_chat_flutter/lib/src/utils/typedefs.dart @@ -341,9 +341,9 @@ typedef DownloadedPathCallback = void Function(String? path); typedef UserTapCallback = void Function(User, Widget?); /// {@template rawKeyEventPredicate} -/// Callback called to react to a raw key event +/// Callback called to react to a key event /// {@endtemplate} -typedef RawKeyEventPredicate = bool Function(FocusNode, RawKeyEvent); +typedef KeyEventPredicate = bool Function(FocusNode, KeyEvent); /// {@template userItemBuilder} /// Builder used to create a custom [ListUserItem] from a [User] From 3dbe1c1f0b4f4a5837df863f7479d9e0ea031e31 Mon Sep 17 00:00:00 2001 From: Sahil Kumar Date: Thu, 20 Apr 2023 14:54:11 +0530 Subject: [PATCH 096/107] rename file to sending_indicator_builder.dart Signed-off-by: xsahil03x --- .../lib/src/channel/channel_preview.dart | 2 +- .../lib/src/message_widget/bottom_row.dart | 2 +- ...tor_wrapper.dart => sending_indicator_builder.dart} | 10 ++++++---- .../channel_scroll_view/stream_channel_list_tile.dart | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-) rename packages/stream_chat_flutter/lib/src/message_widget/{sending_indicator_wrapper.dart => sending_indicator_builder.dart} (93%) diff --git a/packages/stream_chat_flutter/lib/src/channel/channel_preview.dart b/packages/stream_chat_flutter/lib/src/channel/channel_preview.dart index 2626ad19e..2ce6983c8 100644 --- a/packages/stream_chat_flutter/lib/src/channel/channel_preview.dart +++ b/packages/stream_chat_flutter/lib/src/channel/channel_preview.dart @@ -6,7 +6,7 @@ import 'package:contextmenu/contextmenu.dart'; import 'package:flutter/material.dart'; import 'package:stream_chat_flutter/src/context_menu_items/stream_chat_context_menu_item.dart'; import 'package:stream_chat_flutter/src/dialogs/dialogs.dart'; -import 'package:stream_chat_flutter/src/message_widget/sending_indicator_wrapper.dart'; +import 'package:stream_chat_flutter/src/message_widget/sending_indicator_builder.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; /// {@template channelPreview} diff --git a/packages/stream_chat_flutter/lib/src/message_widget/bottom_row.dart b/packages/stream_chat_flutter/lib/src/message_widget/bottom_row.dart index 579dc65db..289088afb 100644 --- a/packages/stream_chat_flutter/lib/src/message_widget/bottom_row.dart +++ b/packages/stream_chat_flutter/lib/src/message_widget/bottom_row.dart @@ -1,5 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:stream_chat_flutter/src/message_widget/sending_indicator_wrapper.dart'; +import 'package:stream_chat_flutter/src/message_widget/sending_indicator_builder.dart'; import 'package:stream_chat_flutter/src/message_widget/thread_painter.dart'; import 'package:stream_chat_flutter/src/message_widget/thread_participants.dart'; import 'package:stream_chat_flutter/src/message_widget/username.dart'; diff --git a/packages/stream_chat_flutter/lib/src/message_widget/sending_indicator_wrapper.dart b/packages/stream_chat_flutter/lib/src/message_widget/sending_indicator_builder.dart similarity index 93% rename from packages/stream_chat_flutter/lib/src/message_widget/sending_indicator_wrapper.dart rename to packages/stream_chat_flutter/lib/src/message_widget/sending_indicator_builder.dart index 9b0b2819c..52ecc1cf4 100644 --- a/packages/stream_chat_flutter/lib/src/message_widget/sending_indicator_wrapper.dart +++ b/packages/stream_chat_flutter/lib/src/message_widget/sending_indicator_builder.dart @@ -39,8 +39,8 @@ class SendingIndicatorBuilder extends StatelessWidget { @override Widget build(BuildContext context) { final style = messageTheme.createdAtStyle; - final thisChannel = channel ?? StreamChannel.of(context).channel; - final memberCount = thisChannel.memberCount ?? 0; + final channel = this.channel ?? StreamChannel.of(context).channel; + final memberCount = channel.memberCount ?? 0; if (hasNonUrlAttachments && (message.status == MessageSendingStatus.sending || @@ -64,8 +64,8 @@ class SendingIndicatorBuilder extends StatelessWidget { } return BetterStreamBuilder>( - stream: thisChannel.state?.readStream, - initialData: thisChannel.state?.read, + stream: channel.state?.readStream, + initialData: channel.state?.read, builder: (context, data) { final readList = data.where((it) => it.user.id != streamChat.currentUser?.id && @@ -78,6 +78,7 @@ class SendingIndicatorBuilder extends StatelessWidget { isMessageRead: isMessageRead, size: style!.fontSize, ); + if (isMessageRead) { child = Row( mainAxisSize: MainAxisSize.min, @@ -94,6 +95,7 @@ class SendingIndicatorBuilder extends StatelessWidget { ], ); } + return child; }, ); diff --git a/packages/stream_chat_flutter/lib/src/scroll_view/channel_scroll_view/stream_channel_list_tile.dart b/packages/stream_chat_flutter/lib/src/scroll_view/channel_scroll_view/stream_channel_list_tile.dart index bf116bd81..ef665e324 100644 --- a/packages/stream_chat_flutter/lib/src/scroll_view/channel_scroll_view/stream_channel_list_tile.dart +++ b/packages/stream_chat_flutter/lib/src/scroll_view/channel_scroll_view/stream_channel_list_tile.dart @@ -1,6 +1,6 @@ import 'package:collection/collection.dart'; import 'package:flutter/material.dart'; -import 'package:stream_chat_flutter/src/message_widget/sending_indicator_wrapper.dart'; +import 'package:stream_chat_flutter/src/message_widget/sending_indicator_builder.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; /// A widget that displays a channel preview. From 1c4fda8465c3f9b625bba1df2becf441f3fe1d15 Mon Sep 17 00:00:00 2001 From: Sahil Kumar Date: Thu, 20 Apr 2023 17:18:59 +0530 Subject: [PATCH 097/107] fix pana checks Signed-off-by: xsahil03x --- .../src/element_registry.dart | 13 ++--- .../src/positioned_list.dart | 25 +++++----- .../src/post_mount_callback.dart | 5 +- .../src/scroll_view.dart | 37 +++++---------- .../src/scrollable_positioned_list.dart | 17 +++---- .../src/viewport.dart | 47 ++++++------------- packages/stream_chat_flutter/pubspec.yaml | 17 ++++++- .../src/stream_channel_list_controller.dart | 11 +++-- .../stream_chat_localizations/pubspec.yaml | 16 +++++++ 9 files changed, 91 insertions(+), 97 deletions(-) diff --git a/packages/stream_chat_flutter/lib/scrollable_positioned_list/src/element_registry.dart b/packages/stream_chat_flutter/lib/scrollable_positioned_list/src/element_registry.dart index 218e2ca0a..03f274f38 100644 --- a/packages/stream_chat_flutter/lib/scrollable_positioned_list/src/element_registry.dart +++ b/packages/stream_chat_flutter/lib/scrollable_positioned_list/src/element_registry.dart @@ -7,8 +7,7 @@ import 'package:flutter/widgets.dart'; /// A registry to track some [Element]s in the tree. class RegistryWidget extends StatefulWidget { /// Creates a [RegistryWidget]. - const RegistryWidget({Key? key, this.elementNotifier, required this.child}) - : super(key: key); + const RegistryWidget({super.key, this.elementNotifier, required this.child}); /// The widget below this widget in the tree. final Widget child; @@ -28,8 +27,7 @@ class RegistryWidget extends StatefulWidget { /// [RegistryWidget]. class RegisteredElementWidget extends ProxyWidget { /// Creates a [RegisteredElementWidget]. - const RegisteredElementWidget({Key? key, required Widget child}) - : super(key: key, child: child); + const RegisteredElementWidget({super.key, required super.child}); @override Element createElement() => _RegisteredElement(this); @@ -47,10 +45,9 @@ class _RegistryWidgetState extends State { class _InheritedRegistryWidget extends InheritedWidget { const _InheritedRegistryWidget({ - Key? key, required this.state, - required Widget child, - }) : super(key: key, child: child); + required super.child, + }); final _RegistryWidgetState state; @@ -59,7 +56,7 @@ class _InheritedRegistryWidget extends InheritedWidget { } class _RegisteredElement extends ProxyElement { - _RegisteredElement(ProxyWidget widget) : super(widget); + _RegisteredElement(super.widget); @override void notifyClients(ProxyWidget oldWidget) {} diff --git a/packages/stream_chat_flutter/lib/scrollable_positioned_list/src/positioned_list.dart b/packages/stream_chat_flutter/lib/scrollable_positioned_list/src/positioned_list.dart index 0814ef9a5..c62472caa 100644 --- a/packages/stream_chat_flutter/lib/scrollable_positioned_list/src/positioned_list.dart +++ b/packages/stream_chat_flutter/lib/scrollable_positioned_list/src/positioned_list.dart @@ -25,7 +25,7 @@ import 'package:stream_chat_flutter/scrollable_positioned_list/src/scroll_view.d class PositionedList extends StatefulWidget { /// Create a [PositionedList]. const PositionedList({ - Key? key, + super.key, required this.itemCount, required this.itemBuilder, this.separatorBuilder, @@ -44,9 +44,8 @@ class PositionedList extends StatefulWidget { this.addRepaintBoundaries = true, this.addAutomaticKeepAlives = true, this.keyboardDismissBehavior, - }) : assert((positionedIndex == 0) || (positionedIndex < itemCount), - 'positionedIndex cannot be 0 and must be smaller than itemCount'), - super(key: key); + }) : assert((positionedIndex == 0) || (positionedIndex < itemCount), + 'positionedIndex cannot be 0 and must be smaller than itemCount'); /// Called to find the new index of a child based on its key in case of /// reordering. @@ -272,7 +271,7 @@ class _PositionedListState extends State { : widget.reverse ? widget.padding?.copyWith(left: 0) : widget.padding?.copyWith(right: 0)) ?? - const EdgeInsets.all(0); + EdgeInsets.zero; EdgeInsets get _centerSliverPadding => widget.scrollDirection == Axis.vertical ? widget.reverse @@ -283,14 +282,14 @@ class _PositionedListState extends State { bottom: widget.positionedIndex == 0 ? widget.padding!.bottom : 0, ) ?? - const EdgeInsets.all(0) + EdgeInsets.zero : widget.padding?.copyWith( top: widget.positionedIndex == 0 ? widget.padding!.top : 0, bottom: widget.positionedIndex == widget.itemCount - 1 ? widget.padding!.bottom : 0, ) ?? - const EdgeInsets.all(0) + EdgeInsets.zero : widget.reverse ? widget.padding?.copyWith( left: widget.positionedIndex == widget.itemCount - 1 @@ -298,23 +297,23 @@ class _PositionedListState extends State { : 0, right: widget.positionedIndex == 0 ? widget.padding!.right : 0, ) ?? - const EdgeInsets.all(0) + EdgeInsets.zero : widget.padding?.copyWith( left: widget.positionedIndex == 0 ? widget.padding!.left : 0, right: widget.positionedIndex == widget.itemCount - 1 ? widget.padding!.right : 0, ) ?? - const EdgeInsets.all(0); + EdgeInsets.zero; EdgeInsets get _trailingSliverPadding => widget.scrollDirection == Axis.vertical ? widget.reverse - ? widget.padding?.copyWith(bottom: 0) ?? const EdgeInsets.all(0) - : widget.padding?.copyWith(top: 0) ?? const EdgeInsets.all(0) + ? widget.padding?.copyWith(bottom: 0) ?? EdgeInsets.zero + : widget.padding?.copyWith(top: 0) ?? EdgeInsets.zero : widget.reverse - ? widget.padding?.copyWith(right: 0) ?? const EdgeInsets.all(0) - : widget.padding?.copyWith(left: 0) ?? const EdgeInsets.all(0); + ? widget.padding?.copyWith(right: 0) ?? EdgeInsets.zero + : widget.padding?.copyWith(left: 0) ?? EdgeInsets.zero; void _schedulePositionNotificationUpdate() { if (!updateScheduled) { diff --git a/packages/stream_chat_flutter/lib/scrollable_positioned_list/src/post_mount_callback.dart b/packages/stream_chat_flutter/lib/scrollable_positioned_list/src/post_mount_callback.dart index ddb3e3d42..c79c275e7 100644 --- a/packages/stream_chat_flutter/lib/scrollable_positioned_list/src/post_mount_callback.dart +++ b/packages/stream_chat_flutter/lib/scrollable_positioned_list/src/post_mount_callback.dart @@ -7,8 +7,7 @@ import 'package:flutter/widgets.dart'; /// Widget whose [Element] calls a callback when the element is mounted. class PostMountCallback extends StatelessWidget { /// Creates a [PostMountCallback] widget. - const PostMountCallback({required this.child, this.callback, Key? key}) - : super(key: key); + const PostMountCallback({required this.child, this.callback, super.key}); /// The widget below this widget in the tree. final Widget child; @@ -24,7 +23,7 @@ class PostMountCallback extends StatelessWidget { } class _PostMountCallbackElement extends StatelessElement { - _PostMountCallbackElement(PostMountCallback widget) : super(widget); + _PostMountCallbackElement(PostMountCallback super.widget); @override void mount(Element? parent, dynamic newSlot) { diff --git a/packages/stream_chat_flutter/lib/scrollable_positioned_list/src/scroll_view.dart b/packages/stream_chat_flutter/lib/scrollable_positioned_list/src/scroll_view.dart index 8aebfb23f..13a7fdd39 100644 --- a/packages/stream_chat_flutter/lib/scrollable_positioned_list/src/scroll_view.dart +++ b/packages/stream_chat_flutter/lib/scrollable_positioned_list/src/scroll_view.dart @@ -2,7 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'package:flutter/gestures.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter/widgets.dart'; import 'package:stream_chat_flutter/scrollable_positioned_list/src/viewport.dart'; @@ -14,36 +13,24 @@ import 'package:stream_chat_flutter/scrollable_positioned_list/src/viewport.dart class UnboundedCustomScrollView extends CustomScrollView { /// {@macro custom_scroll_view} const UnboundedCustomScrollView({ - Key? key, - Axis scrollDirection = Axis.vertical, - bool reverse = false, - ScrollController? controller, - bool? primary, - ScrollPhysics? physics, - bool shrinkWrap = false, - Key? center, + super.key, + super.scrollDirection, + super.reverse, + super.controller, + super.primary, + super.physics, + super.shrinkWrap, + super.center, double anchor = 0.0, - double? cacheExtent, - List slivers = const [], - int? semanticChildCount, - DragStartBehavior dragStartBehavior = DragStartBehavior.start, + super.cacheExtent, + super.slivers, + super.semanticChildCount, + super.dragStartBehavior, ScrollViewKeyboardDismissBehavior? keyboardDismissBehavior, }) : _anchor = anchor, super( - key: key, keyboardDismissBehavior: keyboardDismissBehavior ?? ScrollViewKeyboardDismissBehavior.manual, - scrollDirection: scrollDirection, - reverse: reverse, - controller: controller, - primary: primary, - physics: physics, - shrinkWrap: shrinkWrap, - center: center, - cacheExtent: cacheExtent, - semanticChildCount: semanticChildCount, - dragStartBehavior: dragStartBehavior, - slivers: slivers, ); // [CustomScrollView] enforces constraints on [CustomScrollView.anchor], so diff --git a/packages/stream_chat_flutter/lib/scrollable_positioned_list/src/scrollable_positioned_list.dart b/packages/stream_chat_flutter/lib/scrollable_positioned_list/src/scrollable_positioned_list.dart index 72ebb6592..5d307158b 100644 --- a/packages/stream_chat_flutter/lib/scrollable_positioned_list/src/scrollable_positioned_list.dart +++ b/packages/stream_chat_flutter/lib/scrollable_positioned_list/src/scrollable_positioned_list.dart @@ -35,7 +35,7 @@ class ScrollablePositionedList extends StatefulWidget { const ScrollablePositionedList.builder({ required this.itemCount, required this.itemBuilder, - Key? key, + super.key, this.itemScrollController, ItemPositionsListener? itemPositionsListener, this.initialScrollIndex = 0, @@ -52,16 +52,15 @@ class ScrollablePositionedList extends StatefulWidget { this.findChildIndexCallback, this.keyboardDismissBehavior, }) : itemPositionsNotifier = itemPositionsListener as ItemPositionsNotifier?, - separatorBuilder = null, - super(key: key); + separatorBuilder = null; /// Create a [ScrollablePositionedList] whose items are provided by /// [itemBuilder] and separators provided by [separatorBuilder]. const ScrollablePositionedList.separated({ required this.itemCount, required this.itemBuilder, - required this.separatorBuilder, - Key? key, + required IndexedWidgetBuilder this.separatorBuilder, + super.key, this.itemScrollController, ItemPositionsListener? itemPositionsListener, this.initialScrollIndex = 0, @@ -77,9 +76,7 @@ class ScrollablePositionedList extends StatefulWidget { this.minCacheExtent, this.findChildIndexCallback, this.keyboardDismissBehavior, - }) : assert(separatorBuilder != null, 'seperatorBuilder cannot be null'), - itemPositionsNotifier = itemPositionsListener as ItemPositionsNotifier?, - super(key: key); + }) : itemPositionsNotifier = itemPositionsListener as ItemPositionsNotifier?; /// Called to find the new index of a child based on its key in case of /// reordering. @@ -280,7 +277,7 @@ class _ScrollablePositionedListState extends State void initState() { super.initState(); final ItemPosition? initialPosition = - PageStorage.of(context)!.readState(context); + PageStorage.of(context).readState(context); primary ..target = initialPosition?.index ?? widget.initialScrollIndex ..alignment = initialPosition?.itemLeadingEdge ?? widget.initialAlignment; @@ -572,7 +569,7 @@ class _ScrollablePositionedListState extends State .where((ItemPosition position) => position.itemLeadingEdge < 1 && position.itemTrailingEdge > 0); if (itemPositions.isNotEmpty) { - PageStorage.of(context)!.writeState( + PageStorage.of(context).writeState( context, itemPositions.reduce((value, element) => value.itemLeadingEdge < element.itemLeadingEdge ? value : element), diff --git a/packages/stream_chat_flutter/lib/scrollable_positioned_list/src/viewport.dart b/packages/stream_chat_flutter/lib/scrollable_positioned_list/src/viewport.dart index 01dce0228..7d2d6b9fd 100644 --- a/packages/stream_chat_flutter/lib/scrollable_positioned_list/src/viewport.dart +++ b/packages/stream_chat_flutter/lib/scrollable_positioned_list/src/viewport.dart @@ -19,24 +19,15 @@ import 'package:flutter/widgets.dart'; class UnboundedViewport extends Viewport { /// {@macro unbounded_viewport} UnboundedViewport({ - Key? key, - AxisDirection axisDirection = AxisDirection.down, - AxisDirection? crossAxisDirection, + super.key, + super.axisDirection, + super.crossAxisDirection, double anchor = 0.0, - required ViewportOffset offset, - Key? center, - double? cacheExtent, - List slivers = const [], - }) : _anchor = anchor, - super( - key: key, - axisDirection: axisDirection, - crossAxisDirection: crossAxisDirection, - offset: offset, - center: center, - cacheExtent: cacheExtent, - slivers: slivers, - ); + required super.offset, + super.center, + super.cacheExtent, + super.slivers, + }) : _anchor = anchor; // [Viewport] enforces constraints on [Viewport.anchor], so we need our own // version. @@ -68,22 +59,14 @@ class UnboundedViewport extends Viewport { class UnboundedRenderViewport extends RenderViewport { /// Creates a viewport for [RenderSliver] objects. UnboundedRenderViewport({ - AxisDirection axisDirection = AxisDirection.down, - required AxisDirection crossAxisDirection, - required ViewportOffset offset, + super.axisDirection, + required super.crossAxisDirection, + required super.offset, double anchor = 0.0, - List? children, - RenderSliver? center, - double? cacheExtent, - }) : _anchor = anchor, - super( - axisDirection: axisDirection, - crossAxisDirection: crossAxisDirection, - offset: offset, - center: center, - cacheExtent: cacheExtent, - children: children, - ); + super.children, + super.center, + super.cacheExtent, + }) : _anchor = anchor; static const int _maxLayoutCycles = 10; diff --git a/packages/stream_chat_flutter/pubspec.yaml b/packages/stream_chat_flutter/pubspec.yaml index d67aa740d..e740b0680 100644 --- a/packages/stream_chat_flutter/pubspec.yaml +++ b/packages/stream_chat_flutter/pubspec.yaml @@ -28,7 +28,7 @@ dependencies: http_parser: ^4.0.0 image_gallery_saver: ^1.7.1 image_picker: ^0.8.2 - jiffy: ^5.0.0 + jiffy: ^6.1.0 lottie: ^2.0.0 meta: ^1.8.0 path_provider: ^2.0.9 @@ -46,6 +46,21 @@ dependencies: video_thumbnail: ^0.5.0 flutter: + plugin: + platforms: + android: + default_package: stream_chat_flutter + ios: + default_package: stream_chat_flutter + windows: + default_package: stream_chat_flutter + linux: + default_package: stream_chat_flutter + macos: + default_package: stream_chat_flutter + web: + default_package: stream_chat_flutter + assets: - images/ - svgs/ diff --git a/packages/stream_chat_flutter_core/lib/src/stream_channel_list_controller.dart b/packages/stream_chat_flutter_core/lib/src/stream_channel_list_controller.dart index 71bc06947..7a7295122 100644 --- a/packages/stream_chat_flutter_core/lib/src/stream_channel_list_controller.dart +++ b/packages/stream_chat_flutter_core/lib/src/stream_channel_list_controller.dart @@ -3,7 +3,6 @@ import 'dart:math'; import 'package:stream_chat/stream_chat.dart' hide Success; import 'package:stream_chat_flutter_core/src/paged_value_notifier.dart'; - import 'package:stream_chat_flutter_core/src/stream_channel_list_event_handler.dart'; /// The default channel page limit to load. @@ -53,12 +52,12 @@ class StreamChannelListController extends PagedValueNotifier { this.limit = defaultChannelPagedLimit, this.messageLimit, this.memberLimit, - }) : _eventHandler = eventHandler ?? StreamChannelListEventHandler(), + }) + : _eventHandler = eventHandler ?? StreamChannelListEventHandler(), super(const PagedValue.loading()); /// Creates a [StreamChannelListController] from the passed [value]. - StreamChannelListController.fromValue( - super.value, { + StreamChannelListController.fromValue(super.value, { required this.client, StreamChannelListEventHandler? eventHandler, this.filter, @@ -247,8 +246,10 @@ class StreamChannelListController extends PagedValueNotifier { _channelEventSubscription = client .on() .skip(1) // Skipping the last emitted event. - // We only need to handle the latest events. + // We only need to handle the latest events. .listen((event) { + print('event: $event'); + // Only handle the event if the value is in success state. if (value.isNotSuccess) return; diff --git a/packages/stream_chat_localizations/pubspec.yaml b/packages/stream_chat_localizations/pubspec.yaml index 7462a2872..f1ec0fe91 100644 --- a/packages/stream_chat_localizations/pubspec.yaml +++ b/packages/stream_chat_localizations/pubspec.yaml @@ -20,3 +20,19 @@ dev_dependencies: dart_code_metrics: ^4.16.0 flutter_test: sdk: flutter + +flutter: + plugin: + platforms: + android: + default_package: stream_chat_localizations + ios: + default_package: stream_chat_localizations + windows: + default_package: stream_chat_localizations + linux: + default_package: stream_chat_localizations + macos: + default_package: stream_chat_localizations + web: + default_package: stream_chat_localizations From ccfacd4af1e663d76a5a2e1ddbc4443d658f9a86 Mon Sep 17 00:00:00 2001 From: Sahil Kumar Date: Thu, 20 Apr 2023 17:22:30 +0530 Subject: [PATCH 098/107] downgrade jiffy Signed-off-by: xsahil03x --- packages/stream_chat_flutter/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/stream_chat_flutter/pubspec.yaml b/packages/stream_chat_flutter/pubspec.yaml index e740b0680..f148c9df2 100644 --- a/packages/stream_chat_flutter/pubspec.yaml +++ b/packages/stream_chat_flutter/pubspec.yaml @@ -28,7 +28,7 @@ dependencies: http_parser: ^4.0.0 image_gallery_saver: ^1.7.1 image_picker: ^0.8.2 - jiffy: ^6.1.0 + jiffy: ^5.0.0 lottie: ^2.0.0 meta: ^1.8.0 path_provider: ^2.0.9 From a909261072ba3df157e9adab625fe56966564f95 Mon Sep 17 00:00:00 2001 From: Sahil Kumar Date: Thu, 20 Apr 2023 17:28:33 +0530 Subject: [PATCH 099/107] revert some changes Signed-off-by: xsahil03x --- .../scrollable_positioned_list/src/scroll_view.dart | 8 ++------ .../lib/src/stream_channel_list_controller.dart | 10 ++++------ 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/packages/stream_chat_flutter/lib/scrollable_positioned_list/src/scroll_view.dart b/packages/stream_chat_flutter/lib/scrollable_positioned_list/src/scroll_view.dart index 13a7fdd39..91ea8d0fc 100644 --- a/packages/stream_chat_flutter/lib/scrollable_positioned_list/src/scroll_view.dart +++ b/packages/stream_chat_flutter/lib/scrollable_positioned_list/src/scroll_view.dart @@ -26,12 +26,8 @@ class UnboundedCustomScrollView extends CustomScrollView { super.slivers, super.semanticChildCount, super.dragStartBehavior, - ScrollViewKeyboardDismissBehavior? keyboardDismissBehavior, - }) : _anchor = anchor, - super( - keyboardDismissBehavior: keyboardDismissBehavior ?? - ScrollViewKeyboardDismissBehavior.manual, - ); + super.keyboardDismissBehavior = ScrollViewKeyboardDismissBehavior.manual, + }) : _anchor = anchor; // [CustomScrollView] enforces constraints on [CustomScrollView.anchor], so // we need our own version. diff --git a/packages/stream_chat_flutter_core/lib/src/stream_channel_list_controller.dart b/packages/stream_chat_flutter_core/lib/src/stream_channel_list_controller.dart index 7a7295122..da93e7b8a 100644 --- a/packages/stream_chat_flutter_core/lib/src/stream_channel_list_controller.dart +++ b/packages/stream_chat_flutter_core/lib/src/stream_channel_list_controller.dart @@ -52,12 +52,12 @@ class StreamChannelListController extends PagedValueNotifier { this.limit = defaultChannelPagedLimit, this.messageLimit, this.memberLimit, - }) - : _eventHandler = eventHandler ?? StreamChannelListEventHandler(), + }) : _eventHandler = eventHandler ?? StreamChannelListEventHandler(), super(const PagedValue.loading()); /// Creates a [StreamChannelListController] from the passed [value]. - StreamChannelListController.fromValue(super.value, { + StreamChannelListController.fromValue( + super.value, { required this.client, StreamChannelListEventHandler? eventHandler, this.filter, @@ -246,10 +246,8 @@ class StreamChannelListController extends PagedValueNotifier { _channelEventSubscription = client .on() .skip(1) // Skipping the last emitted event. - // We only need to handle the latest events. + // We only need to handle the latest events. .listen((event) { - print('event: $event'); - // Only handle the event if the value is in success state. if (value.isNotSuccess) return; From a1a4e55e75050e2bdd54a2217521780043d08c6f Mon Sep 17 00:00:00 2001 From: Sahil Kumar Date: Thu, 20 Apr 2023 17:31:58 +0530 Subject: [PATCH 100/107] some more revert Signed-off-by: xsahil03x --- .../lib/scrollable_positioned_list/src/scroll_view.dart | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/stream_chat_flutter/lib/scrollable_positioned_list/src/scroll_view.dart b/packages/stream_chat_flutter/lib/scrollable_positioned_list/src/scroll_view.dart index 91ea8d0fc..13a7fdd39 100644 --- a/packages/stream_chat_flutter/lib/scrollable_positioned_list/src/scroll_view.dart +++ b/packages/stream_chat_flutter/lib/scrollable_positioned_list/src/scroll_view.dart @@ -26,8 +26,12 @@ class UnboundedCustomScrollView extends CustomScrollView { super.slivers, super.semanticChildCount, super.dragStartBehavior, - super.keyboardDismissBehavior = ScrollViewKeyboardDismissBehavior.manual, - }) : _anchor = anchor; + ScrollViewKeyboardDismissBehavior? keyboardDismissBehavior, + }) : _anchor = anchor, + super( + keyboardDismissBehavior: keyboardDismissBehavior ?? + ScrollViewKeyboardDismissBehavior.manual, + ); // [CustomScrollView] enforces constraints on [CustomScrollView.anchor], so // we need our own version. From fc05a9a4cf2af3cd8d789dbc31d502bdc89f7cfb Mon Sep 17 00:00:00 2001 From: Sahil Kumar Date: Thu, 20 Apr 2023 18:41:51 +0530 Subject: [PATCH 101/107] update drift to 2.7.0 Signed-off-by: xsahil03x --- packages/stream_chat/pubspec.yaml | 2 +- packages/stream_chat_flutter/pubspec.yaml | 2 +- .../stream_chat_flutter_core/pubspec.yaml | 2 +- .../stream_chat_localizations/pubspec.yaml | 2 +- packages/stream_chat_persistence/build.yaml | 1 - .../lib/src/converter/list_converter.dart | 18 +- .../lib/src/converter/map_converter.dart | 18 +- .../message_sending_status_converter.dart | 9 +- .../lib/src/dao/channel_dao.g.dart | 5 +- .../lib/src/dao/channel_query_dao.g.dart | 5 +- .../lib/src/dao/connection_event_dao.g.dart | 5 +- .../lib/src/dao/member_dao.g.dart | 5 +- .../lib/src/dao/message_dao.g.dart | 6 +- .../lib/src/dao/pinned_message_dao.g.dart | 6 +- .../dao/pinned_message_reaction_dao.g.dart | 5 +- .../lib/src/dao/reaction_dao.g.dart | 5 +- .../lib/src/dao/read_dao.g.dart | 5 +- .../lib/src/dao/user_dao.g.dart | 5 +- .../lib/src/db/drift_chat_database.dart | 9 +- .../lib/src/db/drift_chat_database.g.dart | 3376 +++++++++-------- .../lib/src/db/shared/native_db.dart | 5 +- .../lib/src/entity/messages.dart | 7 +- .../lib/src/entity/pinned_messages.dart | 1 - packages/stream_chat_persistence/pubspec.yaml | 6 +- .../src/converter/list_coverter_test.dart | 103 +- .../src/converter/map_converter_test.dart | 132 +- ...message_sending_status_converter_test.dart | 18 +- .../test/src/db/drift_chat_database_test.dart | 2 +- 28 files changed, 2023 insertions(+), 1742 deletions(-) diff --git a/packages/stream_chat/pubspec.yaml b/packages/stream_chat/pubspec.yaml index fe2bfe002..11571a815 100644 --- a/packages/stream_chat/pubspec.yaml +++ b/packages/stream_chat/pubspec.yaml @@ -27,7 +27,7 @@ dependencies: dev_dependencies: build_runner: ^2.3.3 - dart_code_metrics: ^5.7.0 + dart_code_metrics: ^5.7.2 freezed: ^2.3.2 json_serializable: ^6.6.1 mocktail: ^0.3.0 diff --git a/packages/stream_chat_flutter/pubspec.yaml b/packages/stream_chat_flutter/pubspec.yaml index f148c9df2..7ecb494c2 100644 --- a/packages/stream_chat_flutter/pubspec.yaml +++ b/packages/stream_chat_flutter/pubspec.yaml @@ -69,7 +69,7 @@ flutter: uses-material-design: true dev_dependencies: - dart_code_metrics: ^5.7.0 + dart_code_metrics: ^5.7.2 flutter_test: sdk: flutter golden_toolkit: ^0.15.0 diff --git a/packages/stream_chat_flutter_core/pubspec.yaml b/packages/stream_chat_flutter_core/pubspec.yaml index 78a3e813c..6e0868ae0 100644 --- a/packages/stream_chat_flutter_core/pubspec.yaml +++ b/packages/stream_chat_flutter_core/pubspec.yaml @@ -21,7 +21,7 @@ dependencies: dev_dependencies: build_runner: ^2.3.3 - dart_code_metrics: ^5.7.0 + dart_code_metrics: ^5.7.2 fake_async: ^1.2.0 flutter_test: sdk: flutter diff --git a/packages/stream_chat_localizations/pubspec.yaml b/packages/stream_chat_localizations/pubspec.yaml index f1ec0fe91..2fb2bbc39 100644 --- a/packages/stream_chat_localizations/pubspec.yaml +++ b/packages/stream_chat_localizations/pubspec.yaml @@ -17,7 +17,7 @@ dependencies: stream_chat_flutter: ^5.3.0 dev_dependencies: - dart_code_metrics: ^4.16.0 + dart_code_metrics: ^5.7.2 flutter_test: sdk: flutter diff --git a/packages/stream_chat_persistence/build.yaml b/packages/stream_chat_persistence/build.yaml index 9b9002357..1688f11b0 100644 --- a/packages/stream_chat_persistence/build.yaml +++ b/packages/stream_chat_persistence/build.yaml @@ -3,7 +3,6 @@ targets: builders: drift_dev: options: - generate_connect_constructor: true data_class_to_companions: false apply_converters_on_variables: true generate_values_in_copy_with: true diff --git a/packages/stream_chat_persistence/lib/src/converter/list_converter.dart b/packages/stream_chat_persistence/lib/src/converter/list_converter.dart index f1b8cec25..af5d0c15b 100644 --- a/packages/stream_chat_persistence/lib/src/converter/list_converter.dart +++ b/packages/stream_chat_persistence/lib/src/converter/list_converter.dart @@ -6,7 +6,21 @@ import 'package:drift/drift.dart'; /// by the sqlite backend. class ListConverter extends TypeConverter, String> { @override - List? mapToDart(String? fromDb) { + List fromSql(String fromDb) { + return List.from(jsonDecode(fromDb) ?? []); + } + + @override + String toSql(List value) { + return jsonEncode(value); + } +} + +/// Maps a nullable [List] of type [T] into a nullable [String] understood +/// by the sqlite backend. +class NullableListConverter extends TypeConverter?, String?> { + @override + List? fromSql(String? fromDb) { if (fromDb == null) { return null; } @@ -14,7 +28,7 @@ class ListConverter extends TypeConverter, String> { } @override - String? mapToSql(List? value) { + String? toSql(List? value) { if (value == null) { return null; } diff --git a/packages/stream_chat_persistence/lib/src/converter/map_converter.dart b/packages/stream_chat_persistence/lib/src/converter/map_converter.dart index 7afd9225c..cff5965b5 100644 --- a/packages/stream_chat_persistence/lib/src/converter/map_converter.dart +++ b/packages/stream_chat_persistence/lib/src/converter/map_converter.dart @@ -6,7 +6,21 @@ import 'package:drift/drift.dart'; /// by the sqlite backend. class MapConverter extends TypeConverter, String> { @override - Map? mapToDart(String? fromDb) { + Map fromSql(String fromDb) { + return Map.from(jsonDecode(fromDb) ?? {}); + } + + @override + String toSql(Map value) { + return jsonEncode(value); + } +} + +/// Maps a nullable [Map] of type [String], [T] into a nullable [String] +/// understood by the sqlite backend. +class NullableMapConverter extends TypeConverter?, String?> { + @override + Map? fromSql(String? fromDb) { if (fromDb == null) { return null; } @@ -14,7 +28,7 @@ class MapConverter extends TypeConverter, String> { } @override - String? mapToSql(Map? value) { + String? toSql(Map? value) { if (value == null) { return null; } diff --git a/packages/stream_chat_persistence/lib/src/converter/message_sending_status_converter.dart b/packages/stream_chat_persistence/lib/src/converter/message_sending_status_converter.dart index a6bb6d73b..7eb194a3c 100644 --- a/packages/stream_chat_persistence/lib/src/converter/message_sending_status_converter.dart +++ b/packages/stream_chat_persistence/lib/src/converter/message_sending_status_converter.dart @@ -6,7 +6,7 @@ import 'package:stream_chat/stream_chat.dart'; class MessageSendingStatusConverter extends TypeConverter { @override - MessageSendingStatus? mapToDart(int? fromDb) { + MessageSendingStatus fromSql(int fromDb) { switch (fromDb) { case 0: return MessageSendingStatus.sending; @@ -22,13 +22,12 @@ class MessageSendingStatusConverter return MessageSendingStatus.deleting; case 6: return MessageSendingStatus.failed_delete; - default: - return null; } + return MessageSendingStatus.sending; } @override - int? mapToSql(MessageSendingStatus? value) { + int toSql(MessageSendingStatus value) { switch (value) { case MessageSendingStatus.sending: return 0; @@ -44,8 +43,6 @@ class MessageSendingStatusConverter return 5; case MessageSendingStatus.failed_delete: return 6; - default: - return null; } } } diff --git a/packages/stream_chat_persistence/lib/src/dao/channel_dao.g.dart b/packages/stream_chat_persistence/lib/src/dao/channel_dao.g.dart index 5c4cce4a5..d90836751 100644 --- a/packages/stream_chat_persistence/lib/src/dao/channel_dao.g.dart +++ b/packages/stream_chat_persistence/lib/src/dao/channel_dao.g.dart @@ -2,10 +2,7 @@ part of 'channel_dao.dart'; -// ************************************************************************** -// DaoGenerator -// ************************************************************************** - +// ignore_for_file: type=lint mixin _$ChannelDaoMixin on DatabaseAccessor { $ChannelsTable get channels => attachedDatabase.channels; $UsersTable get users => attachedDatabase.users; diff --git a/packages/stream_chat_persistence/lib/src/dao/channel_query_dao.g.dart b/packages/stream_chat_persistence/lib/src/dao/channel_query_dao.g.dart index 3f8f94cbb..07a9dabbb 100644 --- a/packages/stream_chat_persistence/lib/src/dao/channel_query_dao.g.dart +++ b/packages/stream_chat_persistence/lib/src/dao/channel_query_dao.g.dart @@ -2,10 +2,7 @@ part of 'channel_query_dao.dart'; -// ************************************************************************** -// DaoGenerator -// ************************************************************************** - +// ignore_for_file: type=lint mixin _$ChannelQueryDaoMixin on DatabaseAccessor { $ChannelQueriesTable get channelQueries => attachedDatabase.channelQueries; $ChannelsTable get channels => attachedDatabase.channels; diff --git a/packages/stream_chat_persistence/lib/src/dao/connection_event_dao.g.dart b/packages/stream_chat_persistence/lib/src/dao/connection_event_dao.g.dart index ed29a03bb..32541de5d 100644 --- a/packages/stream_chat_persistence/lib/src/dao/connection_event_dao.g.dart +++ b/packages/stream_chat_persistence/lib/src/dao/connection_event_dao.g.dart @@ -2,10 +2,7 @@ part of 'connection_event_dao.dart'; -// ************************************************************************** -// DaoGenerator -// ************************************************************************** - +// ignore_for_file: type=lint mixin _$ConnectionEventDaoMixin on DatabaseAccessor { $ConnectionEventsTable get connectionEvents => attachedDatabase.connectionEvents; diff --git a/packages/stream_chat_persistence/lib/src/dao/member_dao.g.dart b/packages/stream_chat_persistence/lib/src/dao/member_dao.g.dart index e85b1858e..0e6ec2da8 100644 --- a/packages/stream_chat_persistence/lib/src/dao/member_dao.g.dart +++ b/packages/stream_chat_persistence/lib/src/dao/member_dao.g.dart @@ -2,10 +2,7 @@ part of 'member_dao.dart'; -// ************************************************************************** -// DaoGenerator -// ************************************************************************** - +// ignore_for_file: type=lint mixin _$MemberDaoMixin on DatabaseAccessor { $MembersTable get members => attachedDatabase.members; $UsersTable get users => attachedDatabase.users; diff --git a/packages/stream_chat_persistence/lib/src/dao/message_dao.g.dart b/packages/stream_chat_persistence/lib/src/dao/message_dao.g.dart index 42069b23d..15520a3f8 100644 --- a/packages/stream_chat_persistence/lib/src/dao/message_dao.g.dart +++ b/packages/stream_chat_persistence/lib/src/dao/message_dao.g.dart @@ -2,11 +2,9 @@ part of 'message_dao.dart'; -// ************************************************************************** -// DaoGenerator -// ************************************************************************** - +// ignore_for_file: type=lint mixin _$MessageDaoMixin on DatabaseAccessor { + $ChannelsTable get channels => attachedDatabase.channels; $MessagesTable get messages => attachedDatabase.messages; $UsersTable get users => attachedDatabase.users; } diff --git a/packages/stream_chat_persistence/lib/src/dao/pinned_message_dao.g.dart b/packages/stream_chat_persistence/lib/src/dao/pinned_message_dao.g.dart index f695bf085..09c8df615 100644 --- a/packages/stream_chat_persistence/lib/src/dao/pinned_message_dao.g.dart +++ b/packages/stream_chat_persistence/lib/src/dao/pinned_message_dao.g.dart @@ -2,11 +2,9 @@ part of 'pinned_message_dao.dart'; -// ************************************************************************** -// DaoGenerator -// ************************************************************************** - +// ignore_for_file: type=lint mixin _$PinnedMessageDaoMixin on DatabaseAccessor { + $ChannelsTable get channels => attachedDatabase.channels; $PinnedMessagesTable get pinnedMessages => attachedDatabase.pinnedMessages; $UsersTable get users => attachedDatabase.users; } diff --git a/packages/stream_chat_persistence/lib/src/dao/pinned_message_reaction_dao.g.dart b/packages/stream_chat_persistence/lib/src/dao/pinned_message_reaction_dao.g.dart index 48e212bf3..075044a42 100644 --- a/packages/stream_chat_persistence/lib/src/dao/pinned_message_reaction_dao.g.dart +++ b/packages/stream_chat_persistence/lib/src/dao/pinned_message_reaction_dao.g.dart @@ -2,10 +2,7 @@ part of 'pinned_message_reaction_dao.dart'; -// ************************************************************************** -// DaoGenerator -// ************************************************************************** - +// ignore_for_file: type=lint mixin _$PinnedMessageReactionDaoMixin on DatabaseAccessor { $PinnedMessageReactionsTable get pinnedMessageReactions => attachedDatabase.pinnedMessageReactions; diff --git a/packages/stream_chat_persistence/lib/src/dao/reaction_dao.g.dart b/packages/stream_chat_persistence/lib/src/dao/reaction_dao.g.dart index 2eefbceb6..2fcaeaf71 100644 --- a/packages/stream_chat_persistence/lib/src/dao/reaction_dao.g.dart +++ b/packages/stream_chat_persistence/lib/src/dao/reaction_dao.g.dart @@ -2,10 +2,7 @@ part of 'reaction_dao.dart'; -// ************************************************************************** -// DaoGenerator -// ************************************************************************** - +// ignore_for_file: type=lint mixin _$ReactionDaoMixin on DatabaseAccessor { $ReactionsTable get reactions => attachedDatabase.reactions; $UsersTable get users => attachedDatabase.users; diff --git a/packages/stream_chat_persistence/lib/src/dao/read_dao.g.dart b/packages/stream_chat_persistence/lib/src/dao/read_dao.g.dart index bfe5873c6..b176e4d0a 100644 --- a/packages/stream_chat_persistence/lib/src/dao/read_dao.g.dart +++ b/packages/stream_chat_persistence/lib/src/dao/read_dao.g.dart @@ -2,10 +2,7 @@ part of 'read_dao.dart'; -// ************************************************************************** -// DaoGenerator -// ************************************************************************** - +// ignore_for_file: type=lint mixin _$ReadDaoMixin on DatabaseAccessor { $ReadsTable get reads => attachedDatabase.reads; $UsersTable get users => attachedDatabase.users; diff --git a/packages/stream_chat_persistence/lib/src/dao/user_dao.g.dart b/packages/stream_chat_persistence/lib/src/dao/user_dao.g.dart index 94af53789..06186d0f4 100644 --- a/packages/stream_chat_persistence/lib/src/dao/user_dao.g.dart +++ b/packages/stream_chat_persistence/lib/src/dao/user_dao.g.dart @@ -2,10 +2,7 @@ part of 'user_dao.dart'; -// ************************************************************************** -// DaoGenerator -// ************************************************************************** - +// ignore_for_file: type=lint mixin _$UserDaoMixin on DatabaseAccessor { $UsersTable get users => attachedDatabase.users; } diff --git a/packages/stream_chat_persistence/lib/src/db/drift_chat_database.dart b/packages/stream_chat_persistence/lib/src/db/drift_chat_database.dart index f87aecc45..8098e837f 100644 --- a/packages/stream_chat_persistence/lib/src/db/drift_chat_database.dart +++ b/packages/stream_chat_persistence/lib/src/db/drift_chat_database.dart @@ -1,6 +1,5 @@ import 'package:drift/drift.dart'; import 'package:stream_chat/stream_chat.dart'; - import 'package:stream_chat_persistence/src/converter/converter.dart'; import 'package:stream_chat_persistence/src/dao/dao.dart'; import 'package:stream_chat_persistence/src/entity/entity.dart'; @@ -37,18 +36,12 @@ part 'drift_chat_database.g.dart'; ], ) class DriftChatDatabase extends _$DriftChatDatabase { - /// Creates a new moor chat database instance + /// Creates a new drift chat database instance DriftChatDatabase( this._userId, QueryExecutor executor, ) : super(executor); - /// Instantiate a new database instance - DriftChatDatabase.connect( - this._userId, - DatabaseConnection connection, - ) : super.connect(connection); - final String _userId; /// User id to which the database is connected diff --git a/packages/stream_chat_persistence/lib/src/db/drift_chat_database.g.dart b/packages/stream_chat_persistence/lib/src/db/drift_chat_database.g.dart index f84fbd6be..aa56b75ce 100644 --- a/packages/stream_chat_persistence/lib/src/db/drift_chat_database.g.dart +++ b/packages/stream_chat_persistence/lib/src/db/drift_chat_database.g.dart @@ -2,11 +2,242 @@ part of 'drift_chat_database.dart'; -// ************************************************************************** -// MoorGenerator -// ************************************************************************** - // ignore_for_file: type=lint +class $ChannelsTable extends Channels + with TableInfo<$ChannelsTable, ChannelEntity> { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + $ChannelsTable(this.attachedDatabase, [this._alias]); + static const VerificationMeta _idMeta = const VerificationMeta('id'); + @override + late final GeneratedColumn id = GeneratedColumn( + 'id', aliasedName, false, + type: DriftSqlType.string, requiredDuringInsert: true); + static const VerificationMeta _typeMeta = const VerificationMeta('type'); + @override + late final GeneratedColumn type = GeneratedColumn( + 'type', aliasedName, false, + type: DriftSqlType.string, requiredDuringInsert: true); + static const VerificationMeta _cidMeta = const VerificationMeta('cid'); + @override + late final GeneratedColumn cid = GeneratedColumn( + 'cid', aliasedName, false, + type: DriftSqlType.string, requiredDuringInsert: true); + static const VerificationMeta _ownCapabilitiesMeta = + const VerificationMeta('ownCapabilities'); + @override + late final GeneratedColumnWithTypeConverter?, String> + ownCapabilities = GeneratedColumn( + 'own_capabilities', aliasedName, true, + type: DriftSqlType.string, requiredDuringInsert: false) + .withConverter?>( + $ChannelsTable.$converterownCapabilitiesn); + static const VerificationMeta _configMeta = const VerificationMeta('config'); + @override + late final GeneratedColumnWithTypeConverter, String> + config = GeneratedColumn('config', aliasedName, false, + type: DriftSqlType.string, requiredDuringInsert: true) + .withConverter>($ChannelsTable.$converterconfig); + static const VerificationMeta _frozenMeta = const VerificationMeta('frozen'); + @override + late final GeneratedColumn frozen = + GeneratedColumn('frozen', aliasedName, false, + type: DriftSqlType.bool, + requiredDuringInsert: false, + defaultConstraints: GeneratedColumn.constraintsDependsOnDialect({ + SqlDialect.sqlite: 'CHECK ("frozen" IN (0, 1))', + SqlDialect.mysql: '', + SqlDialect.postgres: '', + }), + defaultValue: const Constant(false)); + static const VerificationMeta _lastMessageAtMeta = + const VerificationMeta('lastMessageAt'); + @override + late final GeneratedColumn lastMessageAt = + GeneratedColumn('last_message_at', aliasedName, true, + type: DriftSqlType.dateTime, requiredDuringInsert: false); + static const VerificationMeta _createdAtMeta = + const VerificationMeta('createdAt'); + @override + late final GeneratedColumn createdAt = GeneratedColumn( + 'created_at', aliasedName, false, + type: DriftSqlType.dateTime, + requiredDuringInsert: false, + defaultValue: currentDateAndTime); + static const VerificationMeta _updatedAtMeta = + const VerificationMeta('updatedAt'); + @override + late final GeneratedColumn updatedAt = GeneratedColumn( + 'updated_at', aliasedName, false, + type: DriftSqlType.dateTime, + requiredDuringInsert: false, + defaultValue: currentDateAndTime); + static const VerificationMeta _deletedAtMeta = + const VerificationMeta('deletedAt'); + @override + late final GeneratedColumn deletedAt = GeneratedColumn( + 'deleted_at', aliasedName, true, + type: DriftSqlType.dateTime, requiredDuringInsert: false); + static const VerificationMeta _memberCountMeta = + const VerificationMeta('memberCount'); + @override + late final GeneratedColumn memberCount = GeneratedColumn( + 'member_count', aliasedName, false, + type: DriftSqlType.int, + requiredDuringInsert: false, + defaultValue: const Constant(0)); + static const VerificationMeta _createdByIdMeta = + const VerificationMeta('createdById'); + @override + late final GeneratedColumn createdById = GeneratedColumn( + 'created_by_id', aliasedName, true, + type: DriftSqlType.string, requiredDuringInsert: false); + static const VerificationMeta _extraDataMeta = + const VerificationMeta('extraData'); + @override + late final GeneratedColumnWithTypeConverter?, String> + extraData = GeneratedColumn('extra_data', aliasedName, true, + type: DriftSqlType.string, requiredDuringInsert: false) + .withConverter?>( + $ChannelsTable.$converterextraDatan); + @override + List get $columns => [ + id, + type, + cid, + ownCapabilities, + config, + frozen, + lastMessageAt, + createdAt, + updatedAt, + deletedAt, + memberCount, + createdById, + extraData + ]; + @override + String get aliasedName => _alias ?? 'channels'; + @override + String get actualTableName => 'channels'; + @override + VerificationContext validateIntegrity(Insertable instance, + {bool isInserting = false}) { + final context = VerificationContext(); + final data = instance.toColumns(true); + if (data.containsKey('id')) { + context.handle(_idMeta, id.isAcceptableOrUnknown(data['id']!, _idMeta)); + } else if (isInserting) { + context.missing(_idMeta); + } + if (data.containsKey('type')) { + context.handle( + _typeMeta, type.isAcceptableOrUnknown(data['type']!, _typeMeta)); + } else if (isInserting) { + context.missing(_typeMeta); + } + if (data.containsKey('cid')) { + context.handle( + _cidMeta, cid.isAcceptableOrUnknown(data['cid']!, _cidMeta)); + } else if (isInserting) { + context.missing(_cidMeta); + } + context.handle(_ownCapabilitiesMeta, const VerificationResult.success()); + context.handle(_configMeta, const VerificationResult.success()); + if (data.containsKey('frozen')) { + context.handle(_frozenMeta, + frozen.isAcceptableOrUnknown(data['frozen']!, _frozenMeta)); + } + if (data.containsKey('last_message_at')) { + context.handle( + _lastMessageAtMeta, + lastMessageAt.isAcceptableOrUnknown( + data['last_message_at']!, _lastMessageAtMeta)); + } + if (data.containsKey('created_at')) { + context.handle(_createdAtMeta, + createdAt.isAcceptableOrUnknown(data['created_at']!, _createdAtMeta)); + } + if (data.containsKey('updated_at')) { + context.handle(_updatedAtMeta, + updatedAt.isAcceptableOrUnknown(data['updated_at']!, _updatedAtMeta)); + } + if (data.containsKey('deleted_at')) { + context.handle(_deletedAtMeta, + deletedAt.isAcceptableOrUnknown(data['deleted_at']!, _deletedAtMeta)); + } + if (data.containsKey('member_count')) { + context.handle( + _memberCountMeta, + memberCount.isAcceptableOrUnknown( + data['member_count']!, _memberCountMeta)); + } + if (data.containsKey('created_by_id')) { + context.handle( + _createdByIdMeta, + createdById.isAcceptableOrUnknown( + data['created_by_id']!, _createdByIdMeta)); + } + context.handle(_extraDataMeta, const VerificationResult.success()); + return context; + } + + @override + Set get $primaryKey => {cid}; + @override + ChannelEntity map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return ChannelEntity( + id: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}id'])!, + type: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}type'])!, + cid: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}cid'])!, + ownCapabilities: $ChannelsTable.$converterownCapabilitiesn.fromSql( + attachedDatabase.typeMapping.read( + DriftSqlType.string, data['${effectivePrefix}own_capabilities'])), + config: $ChannelsTable.$converterconfig.fromSql(attachedDatabase + .typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}config'])!), + frozen: attachedDatabase.typeMapping + .read(DriftSqlType.bool, data['${effectivePrefix}frozen'])!, + lastMessageAt: attachedDatabase.typeMapping.read( + DriftSqlType.dateTime, data['${effectivePrefix}last_message_at']), + createdAt: attachedDatabase.typeMapping + .read(DriftSqlType.dateTime, data['${effectivePrefix}created_at'])!, + updatedAt: attachedDatabase.typeMapping + .read(DriftSqlType.dateTime, data['${effectivePrefix}updated_at'])!, + deletedAt: attachedDatabase.typeMapping + .read(DriftSqlType.dateTime, data['${effectivePrefix}deleted_at']), + memberCount: attachedDatabase.typeMapping + .read(DriftSqlType.int, data['${effectivePrefix}member_count'])!, + createdById: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}created_by_id']), + extraData: $ChannelsTable.$converterextraDatan.fromSql(attachedDatabase + .typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}extra_data'])), + ); + } + + @override + $ChannelsTable createAlias(String alias) { + return $ChannelsTable(attachedDatabase, alias); + } + + static TypeConverter, String> $converterownCapabilities = + ListConverter(); + static TypeConverter?, String?> $converterownCapabilitiesn = + NullAwareTypeConverter.wrap($converterownCapabilities); + static TypeConverter, String> $converterconfig = + MapConverter(); + static TypeConverter, String> $converterextraData = + MapConverter(); + static TypeConverter?, String?> $converterextraDatan = + NullAwareTypeConverter.wrap($converterextraData); +} + class ChannelEntity extends DataClass implements Insertable { /// The id of this channel final String id; @@ -46,7 +277,7 @@ class ChannelEntity extends DataClass implements Insertable { /// Map of custom channel extraData final Map? extraData; - ChannelEntity( + const ChannelEntity( {required this.id, required this.type, required this.cid, @@ -60,37 +291,6 @@ class ChannelEntity extends DataClass implements Insertable { required this.memberCount, this.createdById, this.extraData}); - factory ChannelEntity.fromData(Map data, {String? prefix}) { - final effectivePrefix = prefix ?? ''; - return ChannelEntity( - id: const StringType() - .mapFromDatabaseResponse(data['${effectivePrefix}id'])!, - type: const StringType() - .mapFromDatabaseResponse(data['${effectivePrefix}type'])!, - cid: const StringType() - .mapFromDatabaseResponse(data['${effectivePrefix}cid'])!, - ownCapabilities: $ChannelsTable.$converter0.mapToDart(const StringType() - .mapFromDatabaseResponse(data['${effectivePrefix}own_capabilities'])), - config: $ChannelsTable.$converter1.mapToDart(const StringType() - .mapFromDatabaseResponse(data['${effectivePrefix}config']))!, - frozen: const BoolType() - .mapFromDatabaseResponse(data['${effectivePrefix}frozen'])!, - lastMessageAt: const DateTimeType() - .mapFromDatabaseResponse(data['${effectivePrefix}last_message_at']), - createdAt: const DateTimeType() - .mapFromDatabaseResponse(data['${effectivePrefix}created_at'])!, - updatedAt: const DateTimeType() - .mapFromDatabaseResponse(data['${effectivePrefix}updated_at'])!, - deletedAt: const DateTimeType() - .mapFromDatabaseResponse(data['${effectivePrefix}deleted_at']), - memberCount: const IntType() - .mapFromDatabaseResponse(data['${effectivePrefix}member_count'])!, - createdById: const StringType() - .mapFromDatabaseResponse(data['${effectivePrefix}created_by_id']), - extraData: $ChannelsTable.$converter2.mapToDart(const StringType() - .mapFromDatabaseResponse(data['${effectivePrefix}extra_data'])), - ); - } @override Map toColumns(bool nullToAbsent) { final map = {}; @@ -98,30 +298,30 @@ class ChannelEntity extends DataClass implements Insertable { map['type'] = Variable(type); map['cid'] = Variable(cid); if (!nullToAbsent || ownCapabilities != null) { - final converter = $ChannelsTable.$converter0; + final converter = $ChannelsTable.$converterownCapabilitiesn; map['own_capabilities'] = - Variable(converter.mapToSql(ownCapabilities)); + Variable(converter.toSql(ownCapabilities)); } { - final converter = $ChannelsTable.$converter1; - map['config'] = Variable(converter.mapToSql(config)!); + final converter = $ChannelsTable.$converterconfig; + map['config'] = Variable(converter.toSql(config)); } map['frozen'] = Variable(frozen); if (!nullToAbsent || lastMessageAt != null) { - map['last_message_at'] = Variable(lastMessageAt); + map['last_message_at'] = Variable(lastMessageAt); } map['created_at'] = Variable(createdAt); map['updated_at'] = Variable(updatedAt); if (!nullToAbsent || deletedAt != null) { - map['deleted_at'] = Variable(deletedAt); + map['deleted_at'] = Variable(deletedAt); } map['member_count'] = Variable(memberCount); if (!nullToAbsent || createdById != null) { - map['created_by_id'] = Variable(createdById); + map['created_by_id'] = Variable(createdById); } if (!nullToAbsent || extraData != null) { - final converter = $ChannelsTable.$converter2; - map['extra_data'] = Variable(converter.mapToSql(extraData)); + final converter = $ChannelsTable.$converterextraDatan; + map['extra_data'] = Variable(converter.toSql(extraData)); } return map; } @@ -266,6 +466,7 @@ class ChannelsCompanion extends UpdateCompanion { final Value memberCount; final Value createdById; final Value?> extraData; + final Value rowid; const ChannelsCompanion({ this.id = const Value.absent(), this.type = const Value.absent(), @@ -280,6 +481,7 @@ class ChannelsCompanion extends UpdateCompanion { this.memberCount = const Value.absent(), this.createdById = const Value.absent(), this.extraData = const Value.absent(), + this.rowid = const Value.absent(), }); ChannelsCompanion.insert({ required String id, @@ -295,6 +497,7 @@ class ChannelsCompanion extends UpdateCompanion { this.memberCount = const Value.absent(), this.createdById = const Value.absent(), this.extraData = const Value.absent(), + this.rowid = const Value.absent(), }) : id = Value(id), type = Value(type), cid = Value(cid), @@ -303,16 +506,17 @@ class ChannelsCompanion extends UpdateCompanion { Expression? id, Expression? type, Expression? cid, - Expression?>? ownCapabilities, - Expression>? config, + Expression? ownCapabilities, + Expression? config, Expression? frozen, - Expression? lastMessageAt, + Expression? lastMessageAt, Expression? createdAt, Expression? updatedAt, - Expression? deletedAt, + Expression? deletedAt, Expression? memberCount, - Expression? createdById, - Expression?>? extraData, + Expression? createdById, + Expression? extraData, + Expression? rowid, }) { return RawValuesInsertable({ if (id != null) 'id': id, @@ -328,6 +532,7 @@ class ChannelsCompanion extends UpdateCompanion { if (memberCount != null) 'member_count': memberCount, if (createdById != null) 'created_by_id': createdById, if (extraData != null) 'extra_data': extraData, + if (rowid != null) 'rowid': rowid, }); } @@ -344,7 +549,8 @@ class ChannelsCompanion extends UpdateCompanion { Value? deletedAt, Value? memberCount, Value? createdById, - Value?>? extraData}) { + Value?>? extraData, + Value? rowid}) { return ChannelsCompanion( id: id ?? this.id, type: type ?? this.type, @@ -359,6 +565,7 @@ class ChannelsCompanion extends UpdateCompanion { memberCount: memberCount ?? this.memberCount, createdById: createdById ?? this.createdById, extraData: extraData ?? this.extraData, + rowid: rowid ?? this.rowid, ); } @@ -375,19 +582,19 @@ class ChannelsCompanion extends UpdateCompanion { map['cid'] = Variable(cid.value); } if (ownCapabilities.present) { - final converter = $ChannelsTable.$converter0; + final converter = $ChannelsTable.$converterownCapabilitiesn; map['own_capabilities'] = - Variable(converter.mapToSql(ownCapabilities.value)); + Variable(converter.toSql(ownCapabilities.value)); } if (config.present) { - final converter = $ChannelsTable.$converter1; - map['config'] = Variable(converter.mapToSql(config.value)!); + final converter = $ChannelsTable.$converterconfig; + map['config'] = Variable(converter.toSql(config.value)); } if (frozen.present) { map['frozen'] = Variable(frozen.value); } if (lastMessageAt.present) { - map['last_message_at'] = Variable(lastMessageAt.value); + map['last_message_at'] = Variable(lastMessageAt.value); } if (createdAt.present) { map['created_at'] = Variable(createdAt.value); @@ -396,18 +603,20 @@ class ChannelsCompanion extends UpdateCompanion { map['updated_at'] = Variable(updatedAt.value); } if (deletedAt.present) { - map['deleted_at'] = Variable(deletedAt.value); + map['deleted_at'] = Variable(deletedAt.value); } if (memberCount.present) { map['member_count'] = Variable(memberCount.value); } if (createdById.present) { - map['created_by_id'] = Variable(createdById.value); + map['created_by_id'] = Variable(createdById.value); } if (extraData.present) { - final converter = $ChannelsTable.$converter2; - map['extra_data'] = - Variable(converter.mapToSql(extraData.value)); + final converter = $ChannelsTable.$converterextraDatan; + map['extra_data'] = Variable(converter.toSql(extraData.value)); + } + if (rowid.present) { + map['rowid'] = Variable(rowid.value); } return map; } @@ -427,122 +636,241 @@ class ChannelsCompanion extends UpdateCompanion { ..write('deletedAt: $deletedAt, ') ..write('memberCount: $memberCount, ') ..write('createdById: $createdById, ') - ..write('extraData: $extraData') + ..write('extraData: $extraData, ') + ..write('rowid: $rowid') ..write(')')) .toString(); } } -class $ChannelsTable extends Channels - with TableInfo<$ChannelsTable, ChannelEntity> { +class $MessagesTable extends Messages + with TableInfo<$MessagesTable, MessageEntity> { @override final GeneratedDatabase attachedDatabase; final String? _alias; - $ChannelsTable(this.attachedDatabase, [this._alias]); - final VerificationMeta _idMeta = const VerificationMeta('id'); + $MessagesTable(this.attachedDatabase, [this._alias]); + static const VerificationMeta _idMeta = const VerificationMeta('id'); @override - late final GeneratedColumn id = GeneratedColumn( + late final GeneratedColumn id = GeneratedColumn( 'id', aliasedName, false, - type: const StringType(), requiredDuringInsert: true); - final VerificationMeta _typeMeta = const VerificationMeta('type'); + type: DriftSqlType.string, requiredDuringInsert: true); + static const VerificationMeta _messageTextMeta = + const VerificationMeta('messageText'); @override - late final GeneratedColumn type = GeneratedColumn( - 'type', aliasedName, false, - type: const StringType(), requiredDuringInsert: true); - final VerificationMeta _cidMeta = const VerificationMeta('cid'); + late final GeneratedColumn messageText = GeneratedColumn( + 'message_text', aliasedName, true, + type: DriftSqlType.string, requiredDuringInsert: false); + static const VerificationMeta _attachmentsMeta = + const VerificationMeta('attachments'); @override - late final GeneratedColumn cid = GeneratedColumn( - 'cid', aliasedName, false, - type: const StringType(), requiredDuringInsert: true); - final VerificationMeta _ownCapabilitiesMeta = - const VerificationMeta('ownCapabilities'); + late final GeneratedColumnWithTypeConverter, String> + attachments = GeneratedColumn('attachments', aliasedName, false, + type: DriftSqlType.string, requiredDuringInsert: true) + .withConverter>($MessagesTable.$converterattachments); + static const VerificationMeta _statusMeta = const VerificationMeta('status'); @override - late final GeneratedColumnWithTypeConverter, String?> - ownCapabilities = GeneratedColumn( - 'own_capabilities', aliasedName, true, - type: const StringType(), requiredDuringInsert: false) - .withConverter>($ChannelsTable.$converter0); - final VerificationMeta _configMeta = const VerificationMeta('config'); - @override - late final GeneratedColumnWithTypeConverter, String?> - config = GeneratedColumn('config', aliasedName, false, - type: const StringType(), requiredDuringInsert: true) - .withConverter>($ChannelsTable.$converter1); - final VerificationMeta _frozenMeta = const VerificationMeta('frozen'); - @override - late final GeneratedColumn frozen = GeneratedColumn( - 'frozen', aliasedName, false, - type: const BoolType(), + late final GeneratedColumnWithTypeConverter + status = GeneratedColumn('status', aliasedName, false, + type: DriftSqlType.int, + requiredDuringInsert: false, + defaultValue: const Constant(1)) + .withConverter($MessagesTable.$converterstatus); + static const VerificationMeta _typeMeta = const VerificationMeta('type'); + @override + late final GeneratedColumn type = GeneratedColumn( + 'type', aliasedName, false, + type: DriftSqlType.string, requiredDuringInsert: false, - defaultConstraints: 'CHECK (frozen IN (0, 1))', - defaultValue: const Constant(false)); - final VerificationMeta _lastMessageAtMeta = - const VerificationMeta('lastMessageAt'); + defaultValue: const Constant('regular')); + static const VerificationMeta _mentionedUsersMeta = + const VerificationMeta('mentionedUsers'); @override - late final GeneratedColumn lastMessageAt = - GeneratedColumn('last_message_at', aliasedName, true, - type: const IntType(), requiredDuringInsert: false); - final VerificationMeta _createdAtMeta = const VerificationMeta('createdAt'); + late final GeneratedColumnWithTypeConverter, String> + mentionedUsers = GeneratedColumn( + 'mentioned_users', aliasedName, false, + type: DriftSqlType.string, requiredDuringInsert: true) + .withConverter>($MessagesTable.$convertermentionedUsers); + static const VerificationMeta _reactionCountsMeta = + const VerificationMeta('reactionCounts'); + @override + late final GeneratedColumnWithTypeConverter?, String> + reactionCounts = GeneratedColumn( + 'reaction_counts', aliasedName, true, + type: DriftSqlType.string, requiredDuringInsert: false) + .withConverter?>( + $MessagesTable.$converterreactionCountsn); + static const VerificationMeta _reactionScoresMeta = + const VerificationMeta('reactionScores'); + @override + late final GeneratedColumnWithTypeConverter?, String> + reactionScores = GeneratedColumn( + 'reaction_scores', aliasedName, true, + type: DriftSqlType.string, requiredDuringInsert: false) + .withConverter?>( + $MessagesTable.$converterreactionScoresn); + static const VerificationMeta _parentIdMeta = + const VerificationMeta('parentId'); + @override + late final GeneratedColumn parentId = GeneratedColumn( + 'parent_id', aliasedName, true, + type: DriftSqlType.string, requiredDuringInsert: false); + static const VerificationMeta _quotedMessageIdMeta = + const VerificationMeta('quotedMessageId'); @override - late final GeneratedColumn createdAt = GeneratedColumn( + late final GeneratedColumn quotedMessageId = GeneratedColumn( + 'quoted_message_id', aliasedName, true, + type: DriftSqlType.string, requiredDuringInsert: false); + static const VerificationMeta _replyCountMeta = + const VerificationMeta('replyCount'); + @override + late final GeneratedColumn replyCount = GeneratedColumn( + 'reply_count', aliasedName, true, + type: DriftSqlType.int, requiredDuringInsert: false); + static const VerificationMeta _showInChannelMeta = + const VerificationMeta('showInChannel'); + @override + late final GeneratedColumn showInChannel = + GeneratedColumn('show_in_channel', aliasedName, true, + type: DriftSqlType.bool, + requiredDuringInsert: false, + defaultConstraints: GeneratedColumn.constraintsDependsOnDialect({ + SqlDialect.sqlite: 'CHECK ("show_in_channel" IN (0, 1))', + SqlDialect.mysql: '', + SqlDialect.postgres: '', + })); + static const VerificationMeta _shadowedMeta = + const VerificationMeta('shadowed'); + @override + late final GeneratedColumn shadowed = + GeneratedColumn('shadowed', aliasedName, false, + type: DriftSqlType.bool, + requiredDuringInsert: false, + defaultConstraints: GeneratedColumn.constraintsDependsOnDialect({ + SqlDialect.sqlite: 'CHECK ("shadowed" IN (0, 1))', + SqlDialect.mysql: '', + SqlDialect.postgres: '', + }), + defaultValue: const Constant(false)); + static const VerificationMeta _commandMeta = + const VerificationMeta('command'); + @override + late final GeneratedColumn command = GeneratedColumn( + 'command', aliasedName, true, + type: DriftSqlType.string, requiredDuringInsert: false); + static const VerificationMeta _createdAtMeta = + const VerificationMeta('createdAt'); + @override + late final GeneratedColumn createdAt = GeneratedColumn( 'created_at', aliasedName, false, - type: const IntType(), + type: DriftSqlType.dateTime, requiredDuringInsert: false, defaultValue: currentDateAndTime); - final VerificationMeta _updatedAtMeta = const VerificationMeta('updatedAt'); + static const VerificationMeta _updatedAtMeta = + const VerificationMeta('updatedAt'); @override - late final GeneratedColumn updatedAt = GeneratedColumn( + late final GeneratedColumn updatedAt = GeneratedColumn( 'updated_at', aliasedName, false, - type: const IntType(), + type: DriftSqlType.dateTime, requiredDuringInsert: false, defaultValue: currentDateAndTime); - final VerificationMeta _deletedAtMeta = const VerificationMeta('deletedAt'); + static const VerificationMeta _deletedAtMeta = + const VerificationMeta('deletedAt'); @override - late final GeneratedColumn deletedAt = GeneratedColumn( + late final GeneratedColumn deletedAt = GeneratedColumn( 'deleted_at', aliasedName, true, - type: const IntType(), requiredDuringInsert: false); - final VerificationMeta _memberCountMeta = - const VerificationMeta('memberCount'); + type: DriftSqlType.dateTime, requiredDuringInsert: false); + static const VerificationMeta _userIdMeta = const VerificationMeta('userId'); @override - late final GeneratedColumn memberCount = GeneratedColumn( - 'member_count', aliasedName, false, - type: const IntType(), - requiredDuringInsert: false, - defaultValue: const Constant(0)); - final VerificationMeta _createdByIdMeta = - const VerificationMeta('createdById'); + late final GeneratedColumn userId = GeneratedColumn( + 'user_id', aliasedName, true, + type: DriftSqlType.string, requiredDuringInsert: false); + static const VerificationMeta _pinnedMeta = const VerificationMeta('pinned'); + @override + late final GeneratedColumn pinned = + GeneratedColumn('pinned', aliasedName, false, + type: DriftSqlType.bool, + requiredDuringInsert: false, + defaultConstraints: GeneratedColumn.constraintsDependsOnDialect({ + SqlDialect.sqlite: 'CHECK ("pinned" IN (0, 1))', + SqlDialect.mysql: '', + SqlDialect.postgres: '', + }), + defaultValue: const Constant(false)); + static const VerificationMeta _pinnedAtMeta = + const VerificationMeta('pinnedAt'); + @override + late final GeneratedColumn pinnedAt = GeneratedColumn( + 'pinned_at', aliasedName, true, + type: DriftSqlType.dateTime, requiredDuringInsert: false); + static const VerificationMeta _pinExpiresMeta = + const VerificationMeta('pinExpires'); @override - late final GeneratedColumn createdById = GeneratedColumn( - 'created_by_id', aliasedName, true, - type: const StringType(), requiredDuringInsert: false); - final VerificationMeta _extraDataMeta = const VerificationMeta('extraData'); + late final GeneratedColumn pinExpires = GeneratedColumn( + 'pin_expires', aliasedName, true, + type: DriftSqlType.dateTime, requiredDuringInsert: false); + static const VerificationMeta _pinnedByUserIdMeta = + const VerificationMeta('pinnedByUserId'); @override - late final GeneratedColumnWithTypeConverter, String?> - extraData = GeneratedColumn('extra_data', aliasedName, true, - type: const StringType(), requiredDuringInsert: false) - .withConverter>($ChannelsTable.$converter2); + late final GeneratedColumn pinnedByUserId = GeneratedColumn( + 'pinned_by_user_id', aliasedName, true, + type: DriftSqlType.string, requiredDuringInsert: false); + static const VerificationMeta _channelCidMeta = + const VerificationMeta('channelCid'); + @override + late final GeneratedColumn channelCid = GeneratedColumn( + 'channel_cid', aliasedName, false, + type: DriftSqlType.string, + requiredDuringInsert: true, + defaultConstraints: GeneratedColumn.constraintIsAlways( + 'REFERENCES channels (cid) ON DELETE CASCADE')); + static const VerificationMeta _i18nMeta = const VerificationMeta('i18n'); + @override + late final GeneratedColumnWithTypeConverter?, String> + i18n = GeneratedColumn('i18n', aliasedName, true, + type: DriftSqlType.string, requiredDuringInsert: false) + .withConverter?>($MessagesTable.$converteri18n); + static const VerificationMeta _extraDataMeta = + const VerificationMeta('extraData'); + @override + late final GeneratedColumnWithTypeConverter?, String> + extraData = GeneratedColumn('extra_data', aliasedName, true, + type: DriftSqlType.string, requiredDuringInsert: false) + .withConverter?>( + $MessagesTable.$converterextraDatan); @override List get $columns => [ id, + messageText, + attachments, + status, type, - cid, - ownCapabilities, - config, - frozen, - lastMessageAt, + mentionedUsers, + reactionCounts, + reactionScores, + parentId, + quotedMessageId, + replyCount, + showInChannel, + shadowed, + command, createdAt, updatedAt, deletedAt, - memberCount, - createdById, + userId, + pinned, + pinnedAt, + pinExpires, + pinnedByUserId, + channelCid, + i18n, extraData ]; @override - String get aliasedName => _alias ?? 'channels'; + String get aliasedName => _alias ?? 'messages'; @override - String get actualTableName => 'channels'; + String get actualTableName => 'messages'; @override - VerificationContext validateIntegrity(Insertable instance, + VerificationContext validateIntegrity(Insertable instance, {bool isInserting = false}) { final context = VerificationContext(); final data = instance.toColumns(true); @@ -551,29 +879,50 @@ class $ChannelsTable extends Channels } else if (isInserting) { context.missing(_idMeta); } + if (data.containsKey('message_text')) { + context.handle( + _messageTextMeta, + messageText.isAcceptableOrUnknown( + data['message_text']!, _messageTextMeta)); + } + context.handle(_attachmentsMeta, const VerificationResult.success()); + context.handle(_statusMeta, const VerificationResult.success()); if (data.containsKey('type')) { context.handle( _typeMeta, type.isAcceptableOrUnknown(data['type']!, _typeMeta)); - } else if (isInserting) { - context.missing(_typeMeta); } - if (data.containsKey('cid')) { + context.handle(_mentionedUsersMeta, const VerificationResult.success()); + context.handle(_reactionCountsMeta, const VerificationResult.success()); + context.handle(_reactionScoresMeta, const VerificationResult.success()); + if (data.containsKey('parent_id')) { + context.handle(_parentIdMeta, + parentId.isAcceptableOrUnknown(data['parent_id']!, _parentIdMeta)); + } + if (data.containsKey('quoted_message_id')) { context.handle( - _cidMeta, cid.isAcceptableOrUnknown(data['cid']!, _cidMeta)); - } else if (isInserting) { - context.missing(_cidMeta); + _quotedMessageIdMeta, + quotedMessageId.isAcceptableOrUnknown( + data['quoted_message_id']!, _quotedMessageIdMeta)); } - context.handle(_ownCapabilitiesMeta, const VerificationResult.success()); - context.handle(_configMeta, const VerificationResult.success()); - if (data.containsKey('frozen')) { - context.handle(_frozenMeta, - frozen.isAcceptableOrUnknown(data['frozen']!, _frozenMeta)); + if (data.containsKey('reply_count')) { + context.handle( + _replyCountMeta, + replyCount.isAcceptableOrUnknown( + data['reply_count']!, _replyCountMeta)); } - if (data.containsKey('last_message_at')) { + if (data.containsKey('show_in_channel')) { context.handle( - _lastMessageAtMeta, - lastMessageAt.isAcceptableOrUnknown( - data['last_message_at']!, _lastMessageAtMeta)); + _showInChannelMeta, + showInChannel.isAcceptableOrUnknown( + data['show_in_channel']!, _showInChannelMeta)); + } + if (data.containsKey('shadowed')) { + context.handle(_shadowedMeta, + shadowed.isAcceptableOrUnknown(data['shadowed']!, _shadowedMeta)); + } + if (data.containsKey('command')) { + context.handle(_commandMeta, + command.isAcceptableOrUnknown(data['command']!, _commandMeta)); } if (data.containsKey('created_at')) { context.handle(_createdAtMeta, @@ -587,41 +936,133 @@ class $ChannelsTable extends Channels context.handle(_deletedAtMeta, deletedAt.isAcceptableOrUnknown(data['deleted_at']!, _deletedAtMeta)); } - if (data.containsKey('member_count')) { + if (data.containsKey('user_id')) { + context.handle(_userIdMeta, + userId.isAcceptableOrUnknown(data['user_id']!, _userIdMeta)); + } + if (data.containsKey('pinned')) { + context.handle(_pinnedMeta, + pinned.isAcceptableOrUnknown(data['pinned']!, _pinnedMeta)); + } + if (data.containsKey('pinned_at')) { + context.handle(_pinnedAtMeta, + pinnedAt.isAcceptableOrUnknown(data['pinned_at']!, _pinnedAtMeta)); + } + if (data.containsKey('pin_expires')) { context.handle( - _memberCountMeta, - memberCount.isAcceptableOrUnknown( - data['member_count']!, _memberCountMeta)); + _pinExpiresMeta, + pinExpires.isAcceptableOrUnknown( + data['pin_expires']!, _pinExpiresMeta)); } - if (data.containsKey('created_by_id')) { + if (data.containsKey('pinned_by_user_id')) { context.handle( - _createdByIdMeta, - createdById.isAcceptableOrUnknown( - data['created_by_id']!, _createdByIdMeta)); + _pinnedByUserIdMeta, + pinnedByUserId.isAcceptableOrUnknown( + data['pinned_by_user_id']!, _pinnedByUserIdMeta)); + } + if (data.containsKey('channel_cid')) { + context.handle( + _channelCidMeta, + channelCid.isAcceptableOrUnknown( + data['channel_cid']!, _channelCidMeta)); + } else if (isInserting) { + context.missing(_channelCidMeta); } + context.handle(_i18nMeta, const VerificationResult.success()); context.handle(_extraDataMeta, const VerificationResult.success()); return context; } @override - Set get $primaryKey => {cid}; + Set get $primaryKey => {id}; @override - ChannelEntity map(Map data, {String? tablePrefix}) { - return ChannelEntity.fromData(data, - prefix: tablePrefix != null ? '$tablePrefix.' : null); + MessageEntity map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return MessageEntity( + id: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}id'])!, + messageText: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}message_text']), + attachments: $MessagesTable.$converterattachments.fromSql(attachedDatabase + .typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}attachments'])!), + status: $MessagesTable.$converterstatus.fromSql(attachedDatabase + .typeMapping + .read(DriftSqlType.int, data['${effectivePrefix}status'])!), + type: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}type'])!, + mentionedUsers: $MessagesTable.$convertermentionedUsers.fromSql( + attachedDatabase.typeMapping.read( + DriftSqlType.string, data['${effectivePrefix}mentioned_users'])!), + reactionCounts: $MessagesTable.$converterreactionCountsn.fromSql( + attachedDatabase.typeMapping.read( + DriftSqlType.string, data['${effectivePrefix}reaction_counts'])), + reactionScores: $MessagesTable.$converterreactionScoresn.fromSql( + attachedDatabase.typeMapping.read( + DriftSqlType.string, data['${effectivePrefix}reaction_scores'])), + parentId: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}parent_id']), + quotedMessageId: attachedDatabase.typeMapping.read( + DriftSqlType.string, data['${effectivePrefix}quoted_message_id']), + replyCount: attachedDatabase.typeMapping + .read(DriftSqlType.int, data['${effectivePrefix}reply_count']), + showInChannel: attachedDatabase.typeMapping + .read(DriftSqlType.bool, data['${effectivePrefix}show_in_channel']), + shadowed: attachedDatabase.typeMapping + .read(DriftSqlType.bool, data['${effectivePrefix}shadowed'])!, + command: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}command']), + createdAt: attachedDatabase.typeMapping + .read(DriftSqlType.dateTime, data['${effectivePrefix}created_at'])!, + updatedAt: attachedDatabase.typeMapping + .read(DriftSqlType.dateTime, data['${effectivePrefix}updated_at'])!, + deletedAt: attachedDatabase.typeMapping + .read(DriftSqlType.dateTime, data['${effectivePrefix}deleted_at']), + userId: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}user_id']), + pinned: attachedDatabase.typeMapping + .read(DriftSqlType.bool, data['${effectivePrefix}pinned'])!, + pinnedAt: attachedDatabase.typeMapping + .read(DriftSqlType.dateTime, data['${effectivePrefix}pinned_at']), + pinExpires: attachedDatabase.typeMapping + .read(DriftSqlType.dateTime, data['${effectivePrefix}pin_expires']), + pinnedByUserId: attachedDatabase.typeMapping.read( + DriftSqlType.string, data['${effectivePrefix}pinned_by_user_id']), + channelCid: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}channel_cid'])!, + i18n: $MessagesTable.$converteri18n.fromSql(attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}i18n'])), + extraData: $MessagesTable.$converterextraDatan.fromSql(attachedDatabase + .typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}extra_data'])), + ); } @override - $ChannelsTable createAlias(String alias) { - return $ChannelsTable(attachedDatabase, alias); + $MessagesTable createAlias(String alias) { + return $MessagesTable(attachedDatabase, alias); } - static TypeConverter, String> $converter0 = + static TypeConverter, String> $converterattachments = ListConverter(); - static TypeConverter, String> $converter1 = - MapConverter(); - static TypeConverter, String> $converter2 = + static TypeConverter $converterstatus = + MessageSendingStatusConverter(); + static TypeConverter, String> $convertermentionedUsers = + ListConverter(); + static TypeConverter, String> $converterreactionCounts = + MapConverter(); + static TypeConverter?, String?> $converterreactionCountsn = + NullAwareTypeConverter.wrap($converterreactionCounts); + static TypeConverter, String> $converterreactionScores = + MapConverter(); + static TypeConverter?, String?> $converterreactionScoresn = + NullAwareTypeConverter.wrap($converterreactionScores); + static TypeConverter?, String?> $converteri18n = + NullableMapConverter(); + static TypeConverter, String> $converterextraData = MapConverter(); + static TypeConverter?, String?> $converterextraDatan = + NullAwareTypeConverter.wrap($converterextraData); } class MessageEntity extends DataClass implements Insertable { @@ -700,7 +1141,7 @@ class MessageEntity extends DataClass implements Insertable { /// Message custom extraData final Map? extraData; - MessageEntity( + const MessageEntity( {required this.id, this.messageText, required this.attachments, @@ -726,134 +1167,79 @@ class MessageEntity extends DataClass implements Insertable { required this.channelCid, this.i18n, this.extraData}); - factory MessageEntity.fromData(Map data, {String? prefix}) { - final effectivePrefix = prefix ?? ''; - return MessageEntity( - id: const StringType() - .mapFromDatabaseResponse(data['${effectivePrefix}id'])!, - messageText: const StringType() - .mapFromDatabaseResponse(data['${effectivePrefix}message_text']), - attachments: $MessagesTable.$converter0.mapToDart(const StringType() - .mapFromDatabaseResponse(data['${effectivePrefix}attachments']))!, - status: $MessagesTable.$converter1.mapToDart(const IntType() - .mapFromDatabaseResponse(data['${effectivePrefix}status']))!, - type: const StringType() - .mapFromDatabaseResponse(data['${effectivePrefix}type'])!, - mentionedUsers: $MessagesTable.$converter2.mapToDart(const StringType() - .mapFromDatabaseResponse(data['${effectivePrefix}mentioned_users']))!, - reactionCounts: $MessagesTable.$converter3.mapToDart(const StringType() - .mapFromDatabaseResponse(data['${effectivePrefix}reaction_counts'])), - reactionScores: $MessagesTable.$converter4.mapToDart(const StringType() - .mapFromDatabaseResponse(data['${effectivePrefix}reaction_scores'])), - parentId: const StringType() - .mapFromDatabaseResponse(data['${effectivePrefix}parent_id']), - quotedMessageId: const StringType() - .mapFromDatabaseResponse(data['${effectivePrefix}quoted_message_id']), - replyCount: const IntType() - .mapFromDatabaseResponse(data['${effectivePrefix}reply_count']), - showInChannel: const BoolType() - .mapFromDatabaseResponse(data['${effectivePrefix}show_in_channel']), - shadowed: const BoolType() - .mapFromDatabaseResponse(data['${effectivePrefix}shadowed'])!, - command: const StringType() - .mapFromDatabaseResponse(data['${effectivePrefix}command']), - createdAt: const DateTimeType() - .mapFromDatabaseResponse(data['${effectivePrefix}created_at'])!, - updatedAt: const DateTimeType() - .mapFromDatabaseResponse(data['${effectivePrefix}updated_at'])!, - deletedAt: const DateTimeType() - .mapFromDatabaseResponse(data['${effectivePrefix}deleted_at']), - userId: const StringType() - .mapFromDatabaseResponse(data['${effectivePrefix}user_id']), - pinned: const BoolType() - .mapFromDatabaseResponse(data['${effectivePrefix}pinned'])!, - pinnedAt: const DateTimeType() - .mapFromDatabaseResponse(data['${effectivePrefix}pinned_at']), - pinExpires: const DateTimeType() - .mapFromDatabaseResponse(data['${effectivePrefix}pin_expires']), - pinnedByUserId: const StringType() - .mapFromDatabaseResponse(data['${effectivePrefix}pinned_by_user_id']), - channelCid: const StringType() - .mapFromDatabaseResponse(data['${effectivePrefix}channel_cid'])!, - i18n: $MessagesTable.$converter5.mapToDart(const StringType() - .mapFromDatabaseResponse(data['${effectivePrefix}i18n'])), - extraData: $MessagesTable.$converter6.mapToDart(const StringType() - .mapFromDatabaseResponse(data['${effectivePrefix}extra_data'])), - ); - } @override Map toColumns(bool nullToAbsent) { final map = {}; map['id'] = Variable(id); if (!nullToAbsent || messageText != null) { - map['message_text'] = Variable(messageText); + map['message_text'] = Variable(messageText); } { - final converter = $MessagesTable.$converter0; - map['attachments'] = Variable(converter.mapToSql(attachments)!); + final converter = $MessagesTable.$converterattachments; + map['attachments'] = Variable(converter.toSql(attachments)); } { - final converter = $MessagesTable.$converter1; - map['status'] = Variable(converter.mapToSql(status)!); + final converter = $MessagesTable.$converterstatus; + map['status'] = Variable(converter.toSql(status)); } map['type'] = Variable(type); { - final converter = $MessagesTable.$converter2; + final converter = $MessagesTable.$convertermentionedUsers; map['mentioned_users'] = - Variable(converter.mapToSql(mentionedUsers)!); + Variable(converter.toSql(mentionedUsers)); } if (!nullToAbsent || reactionCounts != null) { - final converter = $MessagesTable.$converter3; + final converter = $MessagesTable.$converterreactionCountsn; map['reaction_counts'] = - Variable(converter.mapToSql(reactionCounts)); + Variable(converter.toSql(reactionCounts)); } if (!nullToAbsent || reactionScores != null) { - final converter = $MessagesTable.$converter4; + final converter = $MessagesTable.$converterreactionScoresn; map['reaction_scores'] = - Variable(converter.mapToSql(reactionScores)); + Variable(converter.toSql(reactionScores)); } if (!nullToAbsent || parentId != null) { - map['parent_id'] = Variable(parentId); + map['parent_id'] = Variable(parentId); } if (!nullToAbsent || quotedMessageId != null) { - map['quoted_message_id'] = Variable(quotedMessageId); + map['quoted_message_id'] = Variable(quotedMessageId); } if (!nullToAbsent || replyCount != null) { - map['reply_count'] = Variable(replyCount); + map['reply_count'] = Variable(replyCount); } if (!nullToAbsent || showInChannel != null) { - map['show_in_channel'] = Variable(showInChannel); + map['show_in_channel'] = Variable(showInChannel); } map['shadowed'] = Variable(shadowed); if (!nullToAbsent || command != null) { - map['command'] = Variable(command); + map['command'] = Variable(command); } map['created_at'] = Variable(createdAt); map['updated_at'] = Variable(updatedAt); if (!nullToAbsent || deletedAt != null) { - map['deleted_at'] = Variable(deletedAt); + map['deleted_at'] = Variable(deletedAt); } if (!nullToAbsent || userId != null) { - map['user_id'] = Variable(userId); + map['user_id'] = Variable(userId); } map['pinned'] = Variable(pinned); if (!nullToAbsent || pinnedAt != null) { - map['pinned_at'] = Variable(pinnedAt); + map['pinned_at'] = Variable(pinnedAt); } if (!nullToAbsent || pinExpires != null) { - map['pin_expires'] = Variable(pinExpires); + map['pin_expires'] = Variable(pinExpires); } if (!nullToAbsent || pinnedByUserId != null) { - map['pinned_by_user_id'] = Variable(pinnedByUserId); + map['pinned_by_user_id'] = Variable(pinnedByUserId); } map['channel_cid'] = Variable(channelCid); if (!nullToAbsent || i18n != null) { - final converter = $MessagesTable.$converter5; - map['i18n'] = Variable(converter.mapToSql(i18n)); + final converter = $MessagesTable.$converteri18n; + map['i18n'] = Variable(converter.toSql(i18n)); } if (!nullToAbsent || extraData != null) { - final converter = $MessagesTable.$converter6; - map['extra_data'] = Variable(converter.mapToSql(extraData)); + final converter = $MessagesTable.$converterextraDatan; + map['extra_data'] = Variable(converter.toSql(extraData)); } return map; } @@ -1099,6 +1485,7 @@ class MessagesCompanion extends UpdateCompanion { final Value channelCid; final Value?> i18n; final Value?> extraData; + final Value rowid; const MessagesCompanion({ this.id = const Value.absent(), this.messageText = const Value.absent(), @@ -1125,6 +1512,7 @@ class MessagesCompanion extends UpdateCompanion { this.channelCid = const Value.absent(), this.i18n = const Value.absent(), this.extraData = const Value.absent(), + this.rowid = const Value.absent(), }); MessagesCompanion.insert({ required String id, @@ -1152,36 +1540,38 @@ class MessagesCompanion extends UpdateCompanion { required String channelCid, this.i18n = const Value.absent(), this.extraData = const Value.absent(), + this.rowid = const Value.absent(), }) : id = Value(id), attachments = Value(attachments), mentionedUsers = Value(mentionedUsers), channelCid = Value(channelCid); static Insertable custom({ Expression? id, - Expression? messageText, - Expression>? attachments, - Expression? status, + Expression? messageText, + Expression? attachments, + Expression? status, Expression? type, - Expression>? mentionedUsers, - Expression?>? reactionCounts, - Expression?>? reactionScores, - Expression? parentId, - Expression? quotedMessageId, - Expression? replyCount, - Expression? showInChannel, + Expression? mentionedUsers, + Expression? reactionCounts, + Expression? reactionScores, + Expression? parentId, + Expression? quotedMessageId, + Expression? replyCount, + Expression? showInChannel, Expression? shadowed, - Expression? command, + Expression? command, Expression? createdAt, Expression? updatedAt, - Expression? deletedAt, - Expression? userId, + Expression? deletedAt, + Expression? userId, Expression? pinned, - Expression? pinnedAt, - Expression? pinExpires, - Expression? pinnedByUserId, + Expression? pinnedAt, + Expression? pinExpires, + Expression? pinnedByUserId, Expression? channelCid, - Expression?>? i18n, - Expression?>? extraData, + Expression? i18n, + Expression? extraData, + Expression? rowid, }) { return RawValuesInsertable({ if (id != null) 'id': id, @@ -1209,6 +1599,7 @@ class MessagesCompanion extends UpdateCompanion { if (channelCid != null) 'channel_cid': channelCid, if (i18n != null) 'i18n': i18n, if (extraData != null) 'extra_data': extraData, + if (rowid != null) 'rowid': rowid, }); } @@ -1237,7 +1628,8 @@ class MessagesCompanion extends UpdateCompanion { Value? pinnedByUserId, Value? channelCid, Value?>? i18n, - Value?>? extraData}) { + Value?>? extraData, + Value? rowid}) { return MessagesCompanion( id: id ?? this.id, messageText: messageText ?? this.messageText, @@ -1264,6 +1656,7 @@ class MessagesCompanion extends UpdateCompanion { channelCid: channelCid ?? this.channelCid, i18n: i18n ?? this.i18n, extraData: extraData ?? this.extraData, + rowid: rowid ?? this.rowid, ); } @@ -1274,52 +1667,51 @@ class MessagesCompanion extends UpdateCompanion { map['id'] = Variable(id.value); } if (messageText.present) { - map['message_text'] = Variable(messageText.value); + map['message_text'] = Variable(messageText.value); } if (attachments.present) { - final converter = $MessagesTable.$converter0; - map['attachments'] = - Variable(converter.mapToSql(attachments.value)!); + final converter = $MessagesTable.$converterattachments; + map['attachments'] = Variable(converter.toSql(attachments.value)); } if (status.present) { - final converter = $MessagesTable.$converter1; - map['status'] = Variable(converter.mapToSql(status.value)!); + final converter = $MessagesTable.$converterstatus; + map['status'] = Variable(converter.toSql(status.value)); } if (type.present) { map['type'] = Variable(type.value); } if (mentionedUsers.present) { - final converter = $MessagesTable.$converter2; + final converter = $MessagesTable.$convertermentionedUsers; map['mentioned_users'] = - Variable(converter.mapToSql(mentionedUsers.value)!); + Variable(converter.toSql(mentionedUsers.value)); } if (reactionCounts.present) { - final converter = $MessagesTable.$converter3; + final converter = $MessagesTable.$converterreactionCountsn; map['reaction_counts'] = - Variable(converter.mapToSql(reactionCounts.value)); + Variable(converter.toSql(reactionCounts.value)); } if (reactionScores.present) { - final converter = $MessagesTable.$converter4; + final converter = $MessagesTable.$converterreactionScoresn; map['reaction_scores'] = - Variable(converter.mapToSql(reactionScores.value)); + Variable(converter.toSql(reactionScores.value)); } if (parentId.present) { - map['parent_id'] = Variable(parentId.value); + map['parent_id'] = Variable(parentId.value); } if (quotedMessageId.present) { - map['quoted_message_id'] = Variable(quotedMessageId.value); + map['quoted_message_id'] = Variable(quotedMessageId.value); } if (replyCount.present) { - map['reply_count'] = Variable(replyCount.value); + map['reply_count'] = Variable(replyCount.value); } if (showInChannel.present) { - map['show_in_channel'] = Variable(showInChannel.value); + map['show_in_channel'] = Variable(showInChannel.value); } if (shadowed.present) { map['shadowed'] = Variable(shadowed.value); } if (command.present) { - map['command'] = Variable(command.value); + map['command'] = Variable(command.value); } if (createdAt.present) { map['created_at'] = Variable(createdAt.value); @@ -1328,34 +1720,36 @@ class MessagesCompanion extends UpdateCompanion { map['updated_at'] = Variable(updatedAt.value); } if (deletedAt.present) { - map['deleted_at'] = Variable(deletedAt.value); + map['deleted_at'] = Variable(deletedAt.value); } if (userId.present) { - map['user_id'] = Variable(userId.value); + map['user_id'] = Variable(userId.value); } if (pinned.present) { map['pinned'] = Variable(pinned.value); } if (pinnedAt.present) { - map['pinned_at'] = Variable(pinnedAt.value); + map['pinned_at'] = Variable(pinnedAt.value); } if (pinExpires.present) { - map['pin_expires'] = Variable(pinExpires.value); + map['pin_expires'] = Variable(pinExpires.value); } if (pinnedByUserId.present) { - map['pinned_by_user_id'] = Variable(pinnedByUserId.value); + map['pinned_by_user_id'] = Variable(pinnedByUserId.value); } if (channelCid.present) { map['channel_cid'] = Variable(channelCid.value); } if (i18n.present) { - final converter = $MessagesTable.$converter5; - map['i18n'] = Variable(converter.mapToSql(i18n.value)); + final converter = $MessagesTable.$converteri18n; + map['i18n'] = Variable(converter.toSql(i18n.value)); } if (extraData.present) { - final converter = $MessagesTable.$converter6; - map['extra_data'] = - Variable(converter.mapToSql(extraData.value)); + final converter = $MessagesTable.$converterextraDatan; + map['extra_data'] = Variable(converter.toSql(extraData.value)); + } + if (rowid.present) { + map['rowid'] = Variable(rowid.value); } return map; } @@ -1387,179 +1781,211 @@ class MessagesCompanion extends UpdateCompanion { ..write('pinnedByUserId: $pinnedByUserId, ') ..write('channelCid: $channelCid, ') ..write('i18n: $i18n, ') - ..write('extraData: $extraData') + ..write('extraData: $extraData, ') + ..write('rowid: $rowid') ..write(')')) .toString(); } } -class $MessagesTable extends Messages - with TableInfo<$MessagesTable, MessageEntity> { +class $PinnedMessagesTable extends PinnedMessages + with TableInfo<$PinnedMessagesTable, PinnedMessageEntity> { @override final GeneratedDatabase attachedDatabase; final String? _alias; - $MessagesTable(this.attachedDatabase, [this._alias]); - final VerificationMeta _idMeta = const VerificationMeta('id'); + $PinnedMessagesTable(this.attachedDatabase, [this._alias]); + static const VerificationMeta _idMeta = const VerificationMeta('id'); @override - late final GeneratedColumn id = GeneratedColumn( + late final GeneratedColumn id = GeneratedColumn( 'id', aliasedName, false, - type: const StringType(), requiredDuringInsert: true); - final VerificationMeta _messageTextMeta = + type: DriftSqlType.string, requiredDuringInsert: true); + static const VerificationMeta _messageTextMeta = const VerificationMeta('messageText'); @override - late final GeneratedColumn messageText = GeneratedColumn( + late final GeneratedColumn messageText = GeneratedColumn( 'message_text', aliasedName, true, - type: const StringType(), requiredDuringInsert: false); - final VerificationMeta _attachmentsMeta = + type: DriftSqlType.string, requiredDuringInsert: false); + static const VerificationMeta _attachmentsMeta = const VerificationMeta('attachments'); @override - late final GeneratedColumnWithTypeConverter, String?> - attachments = GeneratedColumn('attachments', aliasedName, false, - type: const StringType(), requiredDuringInsert: true) - .withConverter>($MessagesTable.$converter0); - final VerificationMeta _statusMeta = const VerificationMeta('status'); + late final GeneratedColumnWithTypeConverter, String> + attachments = GeneratedColumn('attachments', aliasedName, false, + type: DriftSqlType.string, requiredDuringInsert: true) + .withConverter>( + $PinnedMessagesTable.$converterattachments); + static const VerificationMeta _statusMeta = const VerificationMeta('status'); @override - late final GeneratedColumnWithTypeConverter - status = GeneratedColumn('status', aliasedName, false, - type: const IntType(), + late final GeneratedColumnWithTypeConverter + status = GeneratedColumn('status', aliasedName, false, + type: DriftSqlType.int, requiredDuringInsert: false, defaultValue: const Constant(1)) - .withConverter($MessagesTable.$converter1); - final VerificationMeta _typeMeta = const VerificationMeta('type'); + .withConverter( + $PinnedMessagesTable.$converterstatus); + static const VerificationMeta _typeMeta = const VerificationMeta('type'); @override - late final GeneratedColumn type = GeneratedColumn( + late final GeneratedColumn type = GeneratedColumn( 'type', aliasedName, false, - type: const StringType(), + type: DriftSqlType.string, requiredDuringInsert: false, defaultValue: const Constant('regular')); - final VerificationMeta _mentionedUsersMeta = + static const VerificationMeta _mentionedUsersMeta = const VerificationMeta('mentionedUsers'); @override - late final GeneratedColumnWithTypeConverter, String?> - mentionedUsers = GeneratedColumn( + late final GeneratedColumnWithTypeConverter, String> + mentionedUsers = GeneratedColumn( 'mentioned_users', aliasedName, false, - type: const StringType(), requiredDuringInsert: true) - .withConverter>($MessagesTable.$converter2); - final VerificationMeta _reactionCountsMeta = + type: DriftSqlType.string, requiredDuringInsert: true) + .withConverter>( + $PinnedMessagesTable.$convertermentionedUsers); + static const VerificationMeta _reactionCountsMeta = const VerificationMeta('reactionCounts'); @override - late final GeneratedColumnWithTypeConverter, String?> - reactionCounts = GeneratedColumn( + late final GeneratedColumnWithTypeConverter?, String> + reactionCounts = GeneratedColumn( 'reaction_counts', aliasedName, true, - type: const StringType(), requiredDuringInsert: false) - .withConverter>($MessagesTable.$converter3); - final VerificationMeta _reactionScoresMeta = + type: DriftSqlType.string, requiredDuringInsert: false) + .withConverter?>( + $PinnedMessagesTable.$converterreactionCountsn); + static const VerificationMeta _reactionScoresMeta = const VerificationMeta('reactionScores'); @override - late final GeneratedColumnWithTypeConverter, String?> - reactionScores = GeneratedColumn( + late final GeneratedColumnWithTypeConverter?, String> + reactionScores = GeneratedColumn( 'reaction_scores', aliasedName, true, - type: const StringType(), requiredDuringInsert: false) - .withConverter>($MessagesTable.$converter4); - final VerificationMeta _parentIdMeta = const VerificationMeta('parentId'); + type: DriftSqlType.string, requiredDuringInsert: false) + .withConverter?>( + $PinnedMessagesTable.$converterreactionScoresn); + static const VerificationMeta _parentIdMeta = + const VerificationMeta('parentId'); @override - late final GeneratedColumn parentId = GeneratedColumn( + late final GeneratedColumn parentId = GeneratedColumn( 'parent_id', aliasedName, true, - type: const StringType(), requiredDuringInsert: false); - final VerificationMeta _quotedMessageIdMeta = + type: DriftSqlType.string, requiredDuringInsert: false); + static const VerificationMeta _quotedMessageIdMeta = const VerificationMeta('quotedMessageId'); @override - late final GeneratedColumn quotedMessageId = - GeneratedColumn('quoted_message_id', aliasedName, true, - type: const StringType(), requiredDuringInsert: false); - final VerificationMeta _replyCountMeta = const VerificationMeta('replyCount'); + late final GeneratedColumn quotedMessageId = GeneratedColumn( + 'quoted_message_id', aliasedName, true, + type: DriftSqlType.string, requiredDuringInsert: false); + static const VerificationMeta _replyCountMeta = + const VerificationMeta('replyCount'); @override - late final GeneratedColumn replyCount = GeneratedColumn( + late final GeneratedColumn replyCount = GeneratedColumn( 'reply_count', aliasedName, true, - type: const IntType(), requiredDuringInsert: false); - final VerificationMeta _showInChannelMeta = + type: DriftSqlType.int, requiredDuringInsert: false); + static const VerificationMeta _showInChannelMeta = const VerificationMeta('showInChannel'); @override - late final GeneratedColumn showInChannel = GeneratedColumn( - 'show_in_channel', aliasedName, true, - type: const BoolType(), - requiredDuringInsert: false, - defaultConstraints: 'CHECK (show_in_channel IN (0, 1))'); - final VerificationMeta _shadowedMeta = const VerificationMeta('shadowed'); - @override - late final GeneratedColumn shadowed = GeneratedColumn( - 'shadowed', aliasedName, false, - type: const BoolType(), - requiredDuringInsert: false, - defaultConstraints: 'CHECK (shadowed IN (0, 1))', - defaultValue: const Constant(false)); - final VerificationMeta _commandMeta = const VerificationMeta('command'); - @override - late final GeneratedColumn command = GeneratedColumn( + late final GeneratedColumn showInChannel = + GeneratedColumn('show_in_channel', aliasedName, true, + type: DriftSqlType.bool, + requiredDuringInsert: false, + defaultConstraints: GeneratedColumn.constraintsDependsOnDialect({ + SqlDialect.sqlite: 'CHECK ("show_in_channel" IN (0, 1))', + SqlDialect.mysql: '', + SqlDialect.postgres: '', + })); + static const VerificationMeta _shadowedMeta = + const VerificationMeta('shadowed'); + @override + late final GeneratedColumn shadowed = + GeneratedColumn('shadowed', aliasedName, false, + type: DriftSqlType.bool, + requiredDuringInsert: false, + defaultConstraints: GeneratedColumn.constraintsDependsOnDialect({ + SqlDialect.sqlite: 'CHECK ("shadowed" IN (0, 1))', + SqlDialect.mysql: '', + SqlDialect.postgres: '', + }), + defaultValue: const Constant(false)); + static const VerificationMeta _commandMeta = + const VerificationMeta('command'); + @override + late final GeneratedColumn command = GeneratedColumn( 'command', aliasedName, true, - type: const StringType(), requiredDuringInsert: false); - final VerificationMeta _createdAtMeta = const VerificationMeta('createdAt'); + type: DriftSqlType.string, requiredDuringInsert: false); + static const VerificationMeta _createdAtMeta = + const VerificationMeta('createdAt'); @override - late final GeneratedColumn createdAt = GeneratedColumn( + late final GeneratedColumn createdAt = GeneratedColumn( 'created_at', aliasedName, false, - type: const IntType(), + type: DriftSqlType.dateTime, requiredDuringInsert: false, defaultValue: currentDateAndTime); - final VerificationMeta _updatedAtMeta = const VerificationMeta('updatedAt'); + static const VerificationMeta _updatedAtMeta = + const VerificationMeta('updatedAt'); @override - late final GeneratedColumn updatedAt = GeneratedColumn( + late final GeneratedColumn updatedAt = GeneratedColumn( 'updated_at', aliasedName, false, - type: const IntType(), + type: DriftSqlType.dateTime, requiredDuringInsert: false, defaultValue: currentDateAndTime); - final VerificationMeta _deletedAtMeta = const VerificationMeta('deletedAt'); + static const VerificationMeta _deletedAtMeta = + const VerificationMeta('deletedAt'); @override - late final GeneratedColumn deletedAt = GeneratedColumn( + late final GeneratedColumn deletedAt = GeneratedColumn( 'deleted_at', aliasedName, true, - type: const IntType(), requiredDuringInsert: false); - final VerificationMeta _userIdMeta = const VerificationMeta('userId'); + type: DriftSqlType.dateTime, requiredDuringInsert: false); + static const VerificationMeta _userIdMeta = const VerificationMeta('userId'); @override - late final GeneratedColumn userId = GeneratedColumn( + late final GeneratedColumn userId = GeneratedColumn( 'user_id', aliasedName, true, - type: const StringType(), requiredDuringInsert: false); - final VerificationMeta _pinnedMeta = const VerificationMeta('pinned'); - @override - late final GeneratedColumn pinned = GeneratedColumn( - 'pinned', aliasedName, false, - type: const BoolType(), - requiredDuringInsert: false, - defaultConstraints: 'CHECK (pinned IN (0, 1))', - defaultValue: const Constant(false)); - final VerificationMeta _pinnedAtMeta = const VerificationMeta('pinnedAt'); - @override - late final GeneratedColumn pinnedAt = GeneratedColumn( + type: DriftSqlType.string, requiredDuringInsert: false); + static const VerificationMeta _pinnedMeta = const VerificationMeta('pinned'); + @override + late final GeneratedColumn pinned = + GeneratedColumn('pinned', aliasedName, false, + type: DriftSqlType.bool, + requiredDuringInsert: false, + defaultConstraints: GeneratedColumn.constraintsDependsOnDialect({ + SqlDialect.sqlite: 'CHECK ("pinned" IN (0, 1))', + SqlDialect.mysql: '', + SqlDialect.postgres: '', + }), + defaultValue: const Constant(false)); + static const VerificationMeta _pinnedAtMeta = + const VerificationMeta('pinnedAt'); + @override + late final GeneratedColumn pinnedAt = GeneratedColumn( 'pinned_at', aliasedName, true, - type: const IntType(), requiredDuringInsert: false); - final VerificationMeta _pinExpiresMeta = const VerificationMeta('pinExpires'); + type: DriftSqlType.dateTime, requiredDuringInsert: false); + static const VerificationMeta _pinExpiresMeta = + const VerificationMeta('pinExpires'); @override - late final GeneratedColumn pinExpires = GeneratedColumn( + late final GeneratedColumn pinExpires = GeneratedColumn( 'pin_expires', aliasedName, true, - type: const IntType(), requiredDuringInsert: false); - final VerificationMeta _pinnedByUserIdMeta = + type: DriftSqlType.dateTime, requiredDuringInsert: false); + static const VerificationMeta _pinnedByUserIdMeta = const VerificationMeta('pinnedByUserId'); @override - late final GeneratedColumn pinnedByUserId = GeneratedColumn( + late final GeneratedColumn pinnedByUserId = GeneratedColumn( 'pinned_by_user_id', aliasedName, true, - type: const StringType(), requiredDuringInsert: false); - final VerificationMeta _channelCidMeta = const VerificationMeta('channelCid'); + type: DriftSqlType.string, requiredDuringInsert: false); + static const VerificationMeta _channelCidMeta = + const VerificationMeta('channelCid'); @override - late final GeneratedColumn channelCid = GeneratedColumn( + late final GeneratedColumn channelCid = GeneratedColumn( 'channel_cid', aliasedName, false, - type: const StringType(), + type: DriftSqlType.string, requiredDuringInsert: true, - $customConstraints: 'REFERENCES channels(cid) ON DELETE CASCADE'); - final VerificationMeta _i18nMeta = const VerificationMeta('i18n'); - @override - late final GeneratedColumnWithTypeConverter, String?> - i18n = GeneratedColumn('i18n', aliasedName, true, - type: const StringType(), requiredDuringInsert: false) - .withConverter>($MessagesTable.$converter5); - final VerificationMeta _extraDataMeta = const VerificationMeta('extraData'); - @override - late final GeneratedColumnWithTypeConverter, String?> - extraData = GeneratedColumn('extra_data', aliasedName, true, - type: const StringType(), requiredDuringInsert: false) - .withConverter>($MessagesTable.$converter6); + defaultConstraints: GeneratedColumn.constraintIsAlways( + 'REFERENCES channels (cid) ON DELETE CASCADE')); + static const VerificationMeta _i18nMeta = const VerificationMeta('i18n'); + @override + late final GeneratedColumnWithTypeConverter?, String> + i18n = GeneratedColumn('i18n', aliasedName, true, + type: DriftSqlType.string, requiredDuringInsert: false) + .withConverter?>( + $PinnedMessagesTable.$converteri18n); + static const VerificationMeta _extraDataMeta = + const VerificationMeta('extraData'); + @override + late final GeneratedColumnWithTypeConverter?, String> + extraData = GeneratedColumn('extra_data', aliasedName, true, + type: DriftSqlType.string, requiredDuringInsert: false) + .withConverter?>( + $PinnedMessagesTable.$converterextraDatan); @override List get $columns => [ id, @@ -1589,11 +2015,12 @@ class $MessagesTable extends Messages extraData ]; @override - String get aliasedName => _alias ?? 'messages'; + String get aliasedName => _alias ?? 'pinned_messages'; @override - String get actualTableName => 'messages'; + String get actualTableName => 'pinned_messages'; @override - VerificationContext validateIntegrity(Insertable instance, + VerificationContext validateIntegrity( + Insertable instance, {bool isInserting = false}) { final context = VerificationContext(); final data = instance.toColumns(true); @@ -1699,30 +2126,94 @@ class $MessagesTable extends Messages @override Set get $primaryKey => {id}; @override - MessageEntity map(Map data, {String? tablePrefix}) { - return MessageEntity.fromData(data, - prefix: tablePrefix != null ? '$tablePrefix.' : null); + PinnedMessageEntity map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return PinnedMessageEntity( + id: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}id'])!, + messageText: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}message_text']), + attachments: $PinnedMessagesTable.$converterattachments.fromSql( + attachedDatabase.typeMapping.read( + DriftSqlType.string, data['${effectivePrefix}attachments'])!), + status: $PinnedMessagesTable.$converterstatus.fromSql(attachedDatabase + .typeMapping + .read(DriftSqlType.int, data['${effectivePrefix}status'])!), + type: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}type'])!, + mentionedUsers: $PinnedMessagesTable.$convertermentionedUsers.fromSql( + attachedDatabase.typeMapping.read( + DriftSqlType.string, data['${effectivePrefix}mentioned_users'])!), + reactionCounts: $PinnedMessagesTable.$converterreactionCountsn.fromSql( + attachedDatabase.typeMapping.read( + DriftSqlType.string, data['${effectivePrefix}reaction_counts'])), + reactionScores: $PinnedMessagesTable.$converterreactionScoresn.fromSql( + attachedDatabase.typeMapping.read( + DriftSqlType.string, data['${effectivePrefix}reaction_scores'])), + parentId: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}parent_id']), + quotedMessageId: attachedDatabase.typeMapping.read( + DriftSqlType.string, data['${effectivePrefix}quoted_message_id']), + replyCount: attachedDatabase.typeMapping + .read(DriftSqlType.int, data['${effectivePrefix}reply_count']), + showInChannel: attachedDatabase.typeMapping + .read(DriftSqlType.bool, data['${effectivePrefix}show_in_channel']), + shadowed: attachedDatabase.typeMapping + .read(DriftSqlType.bool, data['${effectivePrefix}shadowed'])!, + command: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}command']), + createdAt: attachedDatabase.typeMapping + .read(DriftSqlType.dateTime, data['${effectivePrefix}created_at'])!, + updatedAt: attachedDatabase.typeMapping + .read(DriftSqlType.dateTime, data['${effectivePrefix}updated_at'])!, + deletedAt: attachedDatabase.typeMapping + .read(DriftSqlType.dateTime, data['${effectivePrefix}deleted_at']), + userId: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}user_id']), + pinned: attachedDatabase.typeMapping + .read(DriftSqlType.bool, data['${effectivePrefix}pinned'])!, + pinnedAt: attachedDatabase.typeMapping + .read(DriftSqlType.dateTime, data['${effectivePrefix}pinned_at']), + pinExpires: attachedDatabase.typeMapping + .read(DriftSqlType.dateTime, data['${effectivePrefix}pin_expires']), + pinnedByUserId: attachedDatabase.typeMapping.read( + DriftSqlType.string, data['${effectivePrefix}pinned_by_user_id']), + channelCid: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}channel_cid'])!, + i18n: $PinnedMessagesTable.$converteri18n.fromSql(attachedDatabase + .typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}i18n'])), + extraData: $PinnedMessagesTable.$converterextraDatan.fromSql( + attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}extra_data'])), + ); } @override - $MessagesTable createAlias(String alias) { - return $MessagesTable(attachedDatabase, alias); + $PinnedMessagesTable createAlias(String alias) { + return $PinnedMessagesTable(attachedDatabase, alias); } - static TypeConverter, String> $converter0 = + static TypeConverter, String> $converterattachments = ListConverter(); - static TypeConverter $converter1 = + static TypeConverter $converterstatus = MessageSendingStatusConverter(); - static TypeConverter, String> $converter2 = + static TypeConverter, String> $convertermentionedUsers = ListConverter(); - static TypeConverter, String> $converter3 = + static TypeConverter, String> $converterreactionCounts = MapConverter(); - static TypeConverter, String> $converter4 = + static TypeConverter?, String?> $converterreactionCountsn = + NullAwareTypeConverter.wrap($converterreactionCounts); + static TypeConverter, String> $converterreactionScores = MapConverter(); - static TypeConverter, String> $converter5 = - MapConverter(); - static TypeConverter, String> $converter6 = + static TypeConverter?, String?> $converterreactionScoresn = + NullAwareTypeConverter.wrap($converterreactionScores); + static TypeConverter?, String?> $converteri18n = + NullableMapConverter(); + static TypeConverter, String> $converterextraData = MapConverter(); + static TypeConverter?, String?> $converterextraDatan = + NullAwareTypeConverter.wrap($converterextraData); } class PinnedMessageEntity extends DataClass @@ -1802,7 +2293,7 @@ class PinnedMessageEntity extends DataClass /// Message custom extraData final Map? extraData; - PinnedMessageEntity( + const PinnedMessageEntity( {required this.id, this.messageText, required this.attachments, @@ -1828,138 +2319,79 @@ class PinnedMessageEntity extends DataClass required this.channelCid, this.i18n, this.extraData}); - factory PinnedMessageEntity.fromData(Map data, - {String? prefix}) { - final effectivePrefix = prefix ?? ''; - return PinnedMessageEntity( - id: const StringType() - .mapFromDatabaseResponse(data['${effectivePrefix}id'])!, - messageText: const StringType() - .mapFromDatabaseResponse(data['${effectivePrefix}message_text']), - attachments: $PinnedMessagesTable.$converter0.mapToDart(const StringType() - .mapFromDatabaseResponse(data['${effectivePrefix}attachments']))!, - status: $PinnedMessagesTable.$converter1.mapToDart(const IntType() - .mapFromDatabaseResponse(data['${effectivePrefix}status']))!, - type: const StringType() - .mapFromDatabaseResponse(data['${effectivePrefix}type'])!, - mentionedUsers: $PinnedMessagesTable.$converter2.mapToDart( - const StringType().mapFromDatabaseResponse( - data['${effectivePrefix}mentioned_users']))!, - reactionCounts: $PinnedMessagesTable.$converter3.mapToDart( - const StringType().mapFromDatabaseResponse( - data['${effectivePrefix}reaction_counts'])), - reactionScores: $PinnedMessagesTable.$converter4.mapToDart( - const StringType().mapFromDatabaseResponse( - data['${effectivePrefix}reaction_scores'])), - parentId: const StringType() - .mapFromDatabaseResponse(data['${effectivePrefix}parent_id']), - quotedMessageId: const StringType() - .mapFromDatabaseResponse(data['${effectivePrefix}quoted_message_id']), - replyCount: const IntType() - .mapFromDatabaseResponse(data['${effectivePrefix}reply_count']), - showInChannel: const BoolType() - .mapFromDatabaseResponse(data['${effectivePrefix}show_in_channel']), - shadowed: const BoolType() - .mapFromDatabaseResponse(data['${effectivePrefix}shadowed'])!, - command: const StringType() - .mapFromDatabaseResponse(data['${effectivePrefix}command']), - createdAt: const DateTimeType() - .mapFromDatabaseResponse(data['${effectivePrefix}created_at'])!, - updatedAt: const DateTimeType() - .mapFromDatabaseResponse(data['${effectivePrefix}updated_at'])!, - deletedAt: const DateTimeType() - .mapFromDatabaseResponse(data['${effectivePrefix}deleted_at']), - userId: const StringType() - .mapFromDatabaseResponse(data['${effectivePrefix}user_id']), - pinned: const BoolType() - .mapFromDatabaseResponse(data['${effectivePrefix}pinned'])!, - pinnedAt: const DateTimeType() - .mapFromDatabaseResponse(data['${effectivePrefix}pinned_at']), - pinExpires: const DateTimeType() - .mapFromDatabaseResponse(data['${effectivePrefix}pin_expires']), - pinnedByUserId: const StringType() - .mapFromDatabaseResponse(data['${effectivePrefix}pinned_by_user_id']), - channelCid: const StringType() - .mapFromDatabaseResponse(data['${effectivePrefix}channel_cid'])!, - i18n: $PinnedMessagesTable.$converter5.mapToDart(const StringType() - .mapFromDatabaseResponse(data['${effectivePrefix}i18n'])), - extraData: $PinnedMessagesTable.$converter6.mapToDart(const StringType() - .mapFromDatabaseResponse(data['${effectivePrefix}extra_data'])), - ); - } @override Map toColumns(bool nullToAbsent) { final map = {}; map['id'] = Variable(id); if (!nullToAbsent || messageText != null) { - map['message_text'] = Variable(messageText); + map['message_text'] = Variable(messageText); } { - final converter = $PinnedMessagesTable.$converter0; - map['attachments'] = Variable(converter.mapToSql(attachments)!); + final converter = $PinnedMessagesTable.$converterattachments; + map['attachments'] = Variable(converter.toSql(attachments)); } { - final converter = $PinnedMessagesTable.$converter1; - map['status'] = Variable(converter.mapToSql(status)!); + final converter = $PinnedMessagesTable.$converterstatus; + map['status'] = Variable(converter.toSql(status)); } map['type'] = Variable(type); { - final converter = $PinnedMessagesTable.$converter2; + final converter = $PinnedMessagesTable.$convertermentionedUsers; map['mentioned_users'] = - Variable(converter.mapToSql(mentionedUsers)!); + Variable(converter.toSql(mentionedUsers)); } if (!nullToAbsent || reactionCounts != null) { - final converter = $PinnedMessagesTable.$converter3; + final converter = $PinnedMessagesTable.$converterreactionCountsn; map['reaction_counts'] = - Variable(converter.mapToSql(reactionCounts)); + Variable(converter.toSql(reactionCounts)); } if (!nullToAbsent || reactionScores != null) { - final converter = $PinnedMessagesTable.$converter4; + final converter = $PinnedMessagesTable.$converterreactionScoresn; map['reaction_scores'] = - Variable(converter.mapToSql(reactionScores)); + Variable(converter.toSql(reactionScores)); } if (!nullToAbsent || parentId != null) { - map['parent_id'] = Variable(parentId); + map['parent_id'] = Variable(parentId); } if (!nullToAbsent || quotedMessageId != null) { - map['quoted_message_id'] = Variable(quotedMessageId); + map['quoted_message_id'] = Variable(quotedMessageId); } if (!nullToAbsent || replyCount != null) { - map['reply_count'] = Variable(replyCount); + map['reply_count'] = Variable(replyCount); } if (!nullToAbsent || showInChannel != null) { - map['show_in_channel'] = Variable(showInChannel); + map['show_in_channel'] = Variable(showInChannel); } map['shadowed'] = Variable(shadowed); if (!nullToAbsent || command != null) { - map['command'] = Variable(command); + map['command'] = Variable(command); } map['created_at'] = Variable(createdAt); map['updated_at'] = Variable(updatedAt); if (!nullToAbsent || deletedAt != null) { - map['deleted_at'] = Variable(deletedAt); + map['deleted_at'] = Variable(deletedAt); } if (!nullToAbsent || userId != null) { - map['user_id'] = Variable(userId); + map['user_id'] = Variable(userId); } map['pinned'] = Variable(pinned); if (!nullToAbsent || pinnedAt != null) { - map['pinned_at'] = Variable(pinnedAt); + map['pinned_at'] = Variable(pinnedAt); } if (!nullToAbsent || pinExpires != null) { - map['pin_expires'] = Variable(pinExpires); + map['pin_expires'] = Variable(pinExpires); } if (!nullToAbsent || pinnedByUserId != null) { - map['pinned_by_user_id'] = Variable(pinnedByUserId); + map['pinned_by_user_id'] = Variable(pinnedByUserId); } map['channel_cid'] = Variable(channelCid); if (!nullToAbsent || i18n != null) { - final converter = $PinnedMessagesTable.$converter5; - map['i18n'] = Variable(converter.mapToSql(i18n)); + final converter = $PinnedMessagesTable.$converteri18n; + map['i18n'] = Variable(converter.toSql(i18n)); } if (!nullToAbsent || extraData != null) { - final converter = $PinnedMessagesTable.$converter6; - map['extra_data'] = Variable(converter.mapToSql(extraData)); + final converter = $PinnedMessagesTable.$converterextraDatan; + map['extra_data'] = Variable(converter.toSql(extraData)); } return map; } @@ -2205,6 +2637,7 @@ class PinnedMessagesCompanion extends UpdateCompanion { final Value channelCid; final Value?> i18n; final Value?> extraData; + final Value rowid; const PinnedMessagesCompanion({ this.id = const Value.absent(), this.messageText = const Value.absent(), @@ -2231,6 +2664,7 @@ class PinnedMessagesCompanion extends UpdateCompanion { this.channelCid = const Value.absent(), this.i18n = const Value.absent(), this.extraData = const Value.absent(), + this.rowid = const Value.absent(), }); PinnedMessagesCompanion.insert({ required String id, @@ -2258,36 +2692,38 @@ class PinnedMessagesCompanion extends UpdateCompanion { required String channelCid, this.i18n = const Value.absent(), this.extraData = const Value.absent(), + this.rowid = const Value.absent(), }) : id = Value(id), attachments = Value(attachments), mentionedUsers = Value(mentionedUsers), channelCid = Value(channelCid); static Insertable custom({ Expression? id, - Expression? messageText, - Expression>? attachments, - Expression? status, + Expression? messageText, + Expression? attachments, + Expression? status, Expression? type, - Expression>? mentionedUsers, - Expression?>? reactionCounts, - Expression?>? reactionScores, - Expression? parentId, - Expression? quotedMessageId, - Expression? replyCount, - Expression? showInChannel, + Expression? mentionedUsers, + Expression? reactionCounts, + Expression? reactionScores, + Expression? parentId, + Expression? quotedMessageId, + Expression? replyCount, + Expression? showInChannel, Expression? shadowed, - Expression? command, + Expression? command, Expression? createdAt, Expression? updatedAt, - Expression? deletedAt, - Expression? userId, + Expression? deletedAt, + Expression? userId, Expression? pinned, - Expression? pinnedAt, - Expression? pinExpires, - Expression? pinnedByUserId, + Expression? pinnedAt, + Expression? pinExpires, + Expression? pinnedByUserId, Expression? channelCid, - Expression?>? i18n, - Expression?>? extraData, + Expression? i18n, + Expression? extraData, + Expression? rowid, }) { return RawValuesInsertable({ if (id != null) 'id': id, @@ -2315,6 +2751,7 @@ class PinnedMessagesCompanion extends UpdateCompanion { if (channelCid != null) 'channel_cid': channelCid, if (i18n != null) 'i18n': i18n, if (extraData != null) 'extra_data': extraData, + if (rowid != null) 'rowid': rowid, }); } @@ -2343,7 +2780,8 @@ class PinnedMessagesCompanion extends UpdateCompanion { Value? pinnedByUserId, Value? channelCid, Value?>? i18n, - Value?>? extraData}) { + Value?>? extraData, + Value? rowid}) { return PinnedMessagesCompanion( id: id ?? this.id, messageText: messageText ?? this.messageText, @@ -2370,6 +2808,7 @@ class PinnedMessagesCompanion extends UpdateCompanion { channelCid: channelCid ?? this.channelCid, i18n: i18n ?? this.i18n, extraData: extraData ?? this.extraData, + rowid: rowid ?? this.rowid, ); } @@ -2380,52 +2819,51 @@ class PinnedMessagesCompanion extends UpdateCompanion { map['id'] = Variable(id.value); } if (messageText.present) { - map['message_text'] = Variable(messageText.value); + map['message_text'] = Variable(messageText.value); } if (attachments.present) { - final converter = $PinnedMessagesTable.$converter0; - map['attachments'] = - Variable(converter.mapToSql(attachments.value)!); + final converter = $PinnedMessagesTable.$converterattachments; + map['attachments'] = Variable(converter.toSql(attachments.value)); } if (status.present) { - final converter = $PinnedMessagesTable.$converter1; - map['status'] = Variable(converter.mapToSql(status.value)!); + final converter = $PinnedMessagesTable.$converterstatus; + map['status'] = Variable(converter.toSql(status.value)); } if (type.present) { map['type'] = Variable(type.value); } if (mentionedUsers.present) { - final converter = $PinnedMessagesTable.$converter2; + final converter = $PinnedMessagesTable.$convertermentionedUsers; map['mentioned_users'] = - Variable(converter.mapToSql(mentionedUsers.value)!); + Variable(converter.toSql(mentionedUsers.value)); } if (reactionCounts.present) { - final converter = $PinnedMessagesTable.$converter3; + final converter = $PinnedMessagesTable.$converterreactionCountsn; map['reaction_counts'] = - Variable(converter.mapToSql(reactionCounts.value)); + Variable(converter.toSql(reactionCounts.value)); } if (reactionScores.present) { - final converter = $PinnedMessagesTable.$converter4; + final converter = $PinnedMessagesTable.$converterreactionScoresn; map['reaction_scores'] = - Variable(converter.mapToSql(reactionScores.value)); + Variable(converter.toSql(reactionScores.value)); } if (parentId.present) { - map['parent_id'] = Variable(parentId.value); + map['parent_id'] = Variable(parentId.value); } if (quotedMessageId.present) { - map['quoted_message_id'] = Variable(quotedMessageId.value); + map['quoted_message_id'] = Variable(quotedMessageId.value); } if (replyCount.present) { - map['reply_count'] = Variable(replyCount.value); + map['reply_count'] = Variable(replyCount.value); } if (showInChannel.present) { - map['show_in_channel'] = Variable(showInChannel.value); + map['show_in_channel'] = Variable(showInChannel.value); } if (shadowed.present) { map['shadowed'] = Variable(shadowed.value); } if (command.present) { - map['command'] = Variable(command.value); + map['command'] = Variable(command.value); } if (createdAt.present) { map['created_at'] = Variable(createdAt.value); @@ -2434,34 +2872,36 @@ class PinnedMessagesCompanion extends UpdateCompanion { map['updated_at'] = Variable(updatedAt.value); } if (deletedAt.present) { - map['deleted_at'] = Variable(deletedAt.value); + map['deleted_at'] = Variable(deletedAt.value); } if (userId.present) { - map['user_id'] = Variable(userId.value); + map['user_id'] = Variable(userId.value); } if (pinned.present) { map['pinned'] = Variable(pinned.value); } if (pinnedAt.present) { - map['pinned_at'] = Variable(pinnedAt.value); + map['pinned_at'] = Variable(pinnedAt.value); } if (pinExpires.present) { - map['pin_expires'] = Variable(pinExpires.value); + map['pin_expires'] = Variable(pinExpires.value); } if (pinnedByUserId.present) { - map['pinned_by_user_id'] = Variable(pinnedByUserId.value); + map['pinned_by_user_id'] = Variable(pinnedByUserId.value); } if (channelCid.present) { map['channel_cid'] = Variable(channelCid.value); } if (i18n.present) { - final converter = $PinnedMessagesTable.$converter5; - map['i18n'] = Variable(converter.mapToSql(i18n.value)); + final converter = $PinnedMessagesTable.$converteri18n; + map['i18n'] = Variable(converter.toSql(i18n.value)); } if (extraData.present) { - final converter = $PinnedMessagesTable.$converter6; - map['extra_data'] = - Variable(converter.mapToSql(extraData.value)); + final converter = $PinnedMessagesTable.$converterextraDatan; + map['extra_data'] = Variable(converter.toSql(extraData.value)); + } + if (rowid.present) { + map['rowid'] = Variable(rowid.value); } return map; } @@ -2493,345 +2933,135 @@ class PinnedMessagesCompanion extends UpdateCompanion { ..write('pinnedByUserId: $pinnedByUserId, ') ..write('channelCid: $channelCid, ') ..write('i18n: $i18n, ') - ..write('extraData: $extraData') + ..write('extraData: $extraData, ') + ..write('rowid: $rowid') ..write(')')) .toString(); } } -class $PinnedMessagesTable extends PinnedMessages - with TableInfo<$PinnedMessagesTable, PinnedMessageEntity> { +class $PinnedMessageReactionsTable extends PinnedMessageReactions + with TableInfo<$PinnedMessageReactionsTable, PinnedMessageReactionEntity> { @override final GeneratedDatabase attachedDatabase; final String? _alias; - $PinnedMessagesTable(this.attachedDatabase, [this._alias]); - final VerificationMeta _idMeta = const VerificationMeta('id'); - @override - late final GeneratedColumn id = GeneratedColumn( - 'id', aliasedName, false, - type: const StringType(), requiredDuringInsert: true); - final VerificationMeta _messageTextMeta = - const VerificationMeta('messageText'); - @override - late final GeneratedColumn messageText = GeneratedColumn( - 'message_text', aliasedName, true, - type: const StringType(), requiredDuringInsert: false); - final VerificationMeta _attachmentsMeta = - const VerificationMeta('attachments'); - @override - late final GeneratedColumnWithTypeConverter, String?> - attachments = GeneratedColumn('attachments', aliasedName, false, - type: const StringType(), requiredDuringInsert: true) - .withConverter>($PinnedMessagesTable.$converter0); - final VerificationMeta _statusMeta = const VerificationMeta('status'); - @override - late final GeneratedColumnWithTypeConverter - status = GeneratedColumn('status', aliasedName, false, - type: const IntType(), - requiredDuringInsert: false, - defaultValue: const Constant(1)) - .withConverter( - $PinnedMessagesTable.$converter1); - final VerificationMeta _typeMeta = const VerificationMeta('type'); - @override - late final GeneratedColumn type = GeneratedColumn( - 'type', aliasedName, false, - type: const StringType(), - requiredDuringInsert: false, - defaultValue: const Constant('regular')); - final VerificationMeta _mentionedUsersMeta = - const VerificationMeta('mentionedUsers'); - @override - late final GeneratedColumnWithTypeConverter, String?> - mentionedUsers = GeneratedColumn( - 'mentioned_users', aliasedName, false, - type: const StringType(), requiredDuringInsert: true) - .withConverter>($PinnedMessagesTable.$converter2); - final VerificationMeta _reactionCountsMeta = - const VerificationMeta('reactionCounts'); - @override - late final GeneratedColumnWithTypeConverter, String?> - reactionCounts = GeneratedColumn( - 'reaction_counts', aliasedName, true, - type: const StringType(), requiredDuringInsert: false) - .withConverter>($PinnedMessagesTable.$converter3); - final VerificationMeta _reactionScoresMeta = - const VerificationMeta('reactionScores'); - @override - late final GeneratedColumnWithTypeConverter, String?> - reactionScores = GeneratedColumn( - 'reaction_scores', aliasedName, true, - type: const StringType(), requiredDuringInsert: false) - .withConverter>($PinnedMessagesTable.$converter4); - final VerificationMeta _parentIdMeta = const VerificationMeta('parentId'); - @override - late final GeneratedColumn parentId = GeneratedColumn( - 'parent_id', aliasedName, true, - type: const StringType(), requiredDuringInsert: false); - final VerificationMeta _quotedMessageIdMeta = - const VerificationMeta('quotedMessageId'); - @override - late final GeneratedColumn quotedMessageId = - GeneratedColumn('quoted_message_id', aliasedName, true, - type: const StringType(), requiredDuringInsert: false); - final VerificationMeta _replyCountMeta = const VerificationMeta('replyCount'); - @override - late final GeneratedColumn replyCount = GeneratedColumn( - 'reply_count', aliasedName, true, - type: const IntType(), requiredDuringInsert: false); - final VerificationMeta _showInChannelMeta = - const VerificationMeta('showInChannel'); - @override - late final GeneratedColumn showInChannel = GeneratedColumn( - 'show_in_channel', aliasedName, true, - type: const BoolType(), - requiredDuringInsert: false, - defaultConstraints: 'CHECK (show_in_channel IN (0, 1))'); - final VerificationMeta _shadowedMeta = const VerificationMeta('shadowed'); - @override - late final GeneratedColumn shadowed = GeneratedColumn( - 'shadowed', aliasedName, false, - type: const BoolType(), - requiredDuringInsert: false, - defaultConstraints: 'CHECK (shadowed IN (0, 1))', - defaultValue: const Constant(false)); - final VerificationMeta _commandMeta = const VerificationMeta('command'); - @override - late final GeneratedColumn command = GeneratedColumn( - 'command', aliasedName, true, - type: const StringType(), requiredDuringInsert: false); - final VerificationMeta _createdAtMeta = const VerificationMeta('createdAt'); - @override - late final GeneratedColumn createdAt = GeneratedColumn( - 'created_at', aliasedName, false, - type: const IntType(), - requiredDuringInsert: false, - defaultValue: currentDateAndTime); - final VerificationMeta _updatedAtMeta = const VerificationMeta('updatedAt'); - @override - late final GeneratedColumn updatedAt = GeneratedColumn( - 'updated_at', aliasedName, false, - type: const IntType(), - requiredDuringInsert: false, - defaultValue: currentDateAndTime); - final VerificationMeta _deletedAtMeta = const VerificationMeta('deletedAt'); - @override - late final GeneratedColumn deletedAt = GeneratedColumn( - 'deleted_at', aliasedName, true, - type: const IntType(), requiredDuringInsert: false); - final VerificationMeta _userIdMeta = const VerificationMeta('userId'); - @override - late final GeneratedColumn userId = GeneratedColumn( - 'user_id', aliasedName, true, - type: const StringType(), requiredDuringInsert: false); - final VerificationMeta _pinnedMeta = const VerificationMeta('pinned'); - @override - late final GeneratedColumn pinned = GeneratedColumn( - 'pinned', aliasedName, false, - type: const BoolType(), - requiredDuringInsert: false, - defaultConstraints: 'CHECK (pinned IN (0, 1))', - defaultValue: const Constant(false)); - final VerificationMeta _pinnedAtMeta = const VerificationMeta('pinnedAt'); - @override - late final GeneratedColumn pinnedAt = GeneratedColumn( - 'pinned_at', aliasedName, true, - type: const IntType(), requiredDuringInsert: false); - final VerificationMeta _pinExpiresMeta = const VerificationMeta('pinExpires'); - @override - late final GeneratedColumn pinExpires = GeneratedColumn( - 'pin_expires', aliasedName, true, - type: const IntType(), requiredDuringInsert: false); - final VerificationMeta _pinnedByUserIdMeta = - const VerificationMeta('pinnedByUserId'); + $PinnedMessageReactionsTable(this.attachedDatabase, [this._alias]); + static const VerificationMeta _userIdMeta = const VerificationMeta('userId'); @override - late final GeneratedColumn pinnedByUserId = GeneratedColumn( - 'pinned_by_user_id', aliasedName, true, - type: const StringType(), requiredDuringInsert: false); - final VerificationMeta _channelCidMeta = const VerificationMeta('channelCid'); + late final GeneratedColumn userId = GeneratedColumn( + 'user_id', aliasedName, false, + type: DriftSqlType.string, requiredDuringInsert: true); + static const VerificationMeta _messageIdMeta = + const VerificationMeta('messageId'); @override - late final GeneratedColumn channelCid = GeneratedColumn( - 'channel_cid', aliasedName, false, - type: const StringType(), + late final GeneratedColumn messageId = GeneratedColumn( + 'message_id', aliasedName, false, + type: DriftSqlType.string, requiredDuringInsert: true, - $customConstraints: 'REFERENCES channels(cid) ON DELETE CASCADE'); - final VerificationMeta _i18nMeta = const VerificationMeta('i18n'); - @override - late final GeneratedColumnWithTypeConverter, String?> - i18n = GeneratedColumn('i18n', aliasedName, true, - type: const StringType(), requiredDuringInsert: false) - .withConverter>($PinnedMessagesTable.$converter5); - final VerificationMeta _extraDataMeta = const VerificationMeta('extraData'); - @override - late final GeneratedColumnWithTypeConverter, String?> - extraData = GeneratedColumn('extra_data', aliasedName, true, - type: const StringType(), requiredDuringInsert: false) - .withConverter>( - $PinnedMessagesTable.$converter6); + $customConstraints: 'REFERENCES pinned_messages(id) ON DELETE CASCADE'); + static const VerificationMeta _typeMeta = const VerificationMeta('type'); @override - List get $columns => [ - id, - messageText, - attachments, - status, - type, - mentionedUsers, - reactionCounts, - reactionScores, - parentId, - quotedMessageId, - replyCount, - showInChannel, - shadowed, - command, - createdAt, - updatedAt, - deletedAt, - userId, - pinned, - pinnedAt, - pinExpires, - pinnedByUserId, - channelCid, - i18n, - extraData - ]; + late final GeneratedColumn type = GeneratedColumn( + 'type', aliasedName, false, + type: DriftSqlType.string, requiredDuringInsert: true); + static const VerificationMeta _createdAtMeta = + const VerificationMeta('createdAt'); @override - String get aliasedName => _alias ?? 'pinned_messages'; + late final GeneratedColumn createdAt = GeneratedColumn( + 'created_at', aliasedName, false, + type: DriftSqlType.dateTime, + requiredDuringInsert: false, + defaultValue: currentDateAndTime); + static const VerificationMeta _scoreMeta = const VerificationMeta('score'); @override - String get actualTableName => 'pinned_messages'; + late final GeneratedColumn score = GeneratedColumn( + 'score', aliasedName, false, + type: DriftSqlType.int, + requiredDuringInsert: false, + defaultValue: const Constant(0)); + static const VerificationMeta _extraDataMeta = + const VerificationMeta('extraData'); + @override + late final GeneratedColumnWithTypeConverter?, String> + extraData = GeneratedColumn('extra_data', aliasedName, true, + type: DriftSqlType.string, requiredDuringInsert: false) + .withConverter?>( + $PinnedMessageReactionsTable.$converterextraDatan); + @override + List get $columns => + [userId, messageId, type, createdAt, score, extraData]; + @override + String get aliasedName => _alias ?? 'pinned_message_reactions'; + @override + String get actualTableName => 'pinned_message_reactions'; @override VerificationContext validateIntegrity( - Insertable instance, + Insertable instance, {bool isInserting = false}) { final context = VerificationContext(); final data = instance.toColumns(true); - if (data.containsKey('id')) { - context.handle(_idMeta, id.isAcceptableOrUnknown(data['id']!, _idMeta)); + if (data.containsKey('user_id')) { + context.handle(_userIdMeta, + userId.isAcceptableOrUnknown(data['user_id']!, _userIdMeta)); } else if (isInserting) { - context.missing(_idMeta); + context.missing(_userIdMeta); } - if (data.containsKey('message_text')) { - context.handle( - _messageTextMeta, - messageText.isAcceptableOrUnknown( - data['message_text']!, _messageTextMeta)); + if (data.containsKey('message_id')) { + context.handle(_messageIdMeta, + messageId.isAcceptableOrUnknown(data['message_id']!, _messageIdMeta)); + } else if (isInserting) { + context.missing(_messageIdMeta); } - context.handle(_attachmentsMeta, const VerificationResult.success()); - context.handle(_statusMeta, const VerificationResult.success()); if (data.containsKey('type')) { context.handle( _typeMeta, type.isAcceptableOrUnknown(data['type']!, _typeMeta)); - } - context.handle(_mentionedUsersMeta, const VerificationResult.success()); - context.handle(_reactionCountsMeta, const VerificationResult.success()); - context.handle(_reactionScoresMeta, const VerificationResult.success()); - if (data.containsKey('parent_id')) { - context.handle(_parentIdMeta, - parentId.isAcceptableOrUnknown(data['parent_id']!, _parentIdMeta)); - } - if (data.containsKey('quoted_message_id')) { - context.handle( - _quotedMessageIdMeta, - quotedMessageId.isAcceptableOrUnknown( - data['quoted_message_id']!, _quotedMessageIdMeta)); - } - if (data.containsKey('reply_count')) { - context.handle( - _replyCountMeta, - replyCount.isAcceptableOrUnknown( - data['reply_count']!, _replyCountMeta)); - } - if (data.containsKey('show_in_channel')) { - context.handle( - _showInChannelMeta, - showInChannel.isAcceptableOrUnknown( - data['show_in_channel']!, _showInChannelMeta)); - } - if (data.containsKey('shadowed')) { - context.handle(_shadowedMeta, - shadowed.isAcceptableOrUnknown(data['shadowed']!, _shadowedMeta)); - } - if (data.containsKey('command')) { - context.handle(_commandMeta, - command.isAcceptableOrUnknown(data['command']!, _commandMeta)); + } else if (isInserting) { + context.missing(_typeMeta); } if (data.containsKey('created_at')) { context.handle(_createdAtMeta, createdAt.isAcceptableOrUnknown(data['created_at']!, _createdAtMeta)); } - if (data.containsKey('updated_at')) { - context.handle(_updatedAtMeta, - updatedAt.isAcceptableOrUnknown(data['updated_at']!, _updatedAtMeta)); - } - if (data.containsKey('deleted_at')) { - context.handle(_deletedAtMeta, - deletedAt.isAcceptableOrUnknown(data['deleted_at']!, _deletedAtMeta)); - } - if (data.containsKey('user_id')) { - context.handle(_userIdMeta, - userId.isAcceptableOrUnknown(data['user_id']!, _userIdMeta)); - } - if (data.containsKey('pinned')) { - context.handle(_pinnedMeta, - pinned.isAcceptableOrUnknown(data['pinned']!, _pinnedMeta)); - } - if (data.containsKey('pinned_at')) { - context.handle(_pinnedAtMeta, - pinnedAt.isAcceptableOrUnknown(data['pinned_at']!, _pinnedAtMeta)); - } - if (data.containsKey('pin_expires')) { - context.handle( - _pinExpiresMeta, - pinExpires.isAcceptableOrUnknown( - data['pin_expires']!, _pinExpiresMeta)); - } - if (data.containsKey('pinned_by_user_id')) { - context.handle( - _pinnedByUserIdMeta, - pinnedByUserId.isAcceptableOrUnknown( - data['pinned_by_user_id']!, _pinnedByUserIdMeta)); - } - if (data.containsKey('channel_cid')) { + if (data.containsKey('score')) { context.handle( - _channelCidMeta, - channelCid.isAcceptableOrUnknown( - data['channel_cid']!, _channelCidMeta)); - } else if (isInserting) { - context.missing(_channelCidMeta); + _scoreMeta, score.isAcceptableOrUnknown(data['score']!, _scoreMeta)); } - context.handle(_i18nMeta, const VerificationResult.success()); context.handle(_extraDataMeta, const VerificationResult.success()); return context; } @override - Set get $primaryKey => {id}; + Set get $primaryKey => {messageId, type, userId}; @override - PinnedMessageEntity map(Map data, {String? tablePrefix}) { - return PinnedMessageEntity.fromData(data, - prefix: tablePrefix != null ? '$tablePrefix.' : null); + PinnedMessageReactionEntity map(Map data, + {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return PinnedMessageReactionEntity( + userId: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}user_id'])!, + messageId: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}message_id'])!, + type: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}type'])!, + createdAt: attachedDatabase.typeMapping + .read(DriftSqlType.dateTime, data['${effectivePrefix}created_at'])!, + score: attachedDatabase.typeMapping + .read(DriftSqlType.int, data['${effectivePrefix}score'])!, + extraData: $PinnedMessageReactionsTable.$converterextraDatan.fromSql( + attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}extra_data'])), + ); } @override - $PinnedMessagesTable createAlias(String alias) { - return $PinnedMessagesTable(attachedDatabase, alias); + $PinnedMessageReactionsTable createAlias(String alias) { + return $PinnedMessageReactionsTable(attachedDatabase, alias); } - static TypeConverter, String> $converter0 = - ListConverter(); - static TypeConverter $converter1 = - MessageSendingStatusConverter(); - static TypeConverter, String> $converter2 = - ListConverter(); - static TypeConverter, String> $converter3 = - MapConverter(); - static TypeConverter, String> $converter4 = - MapConverter(); - static TypeConverter, String> $converter5 = - MapConverter(); - static TypeConverter, String> $converter6 = + static TypeConverter, String> $converterextraData = MapConverter(); + static TypeConverter?, String?> $converterextraDatan = + NullAwareTypeConverter.wrap($converterextraData); } class PinnedMessageReactionEntity extends DataClass @@ -2853,32 +3083,13 @@ class PinnedMessageReactionEntity extends DataClass /// Reaction custom extraData final Map? extraData; - PinnedMessageReactionEntity( + const PinnedMessageReactionEntity( {required this.userId, required this.messageId, required this.type, required this.createdAt, required this.score, this.extraData}); - factory PinnedMessageReactionEntity.fromData(Map data, - {String? prefix}) { - final effectivePrefix = prefix ?? ''; - return PinnedMessageReactionEntity( - userId: const StringType() - .mapFromDatabaseResponse(data['${effectivePrefix}user_id'])!, - messageId: const StringType() - .mapFromDatabaseResponse(data['${effectivePrefix}message_id'])!, - type: const StringType() - .mapFromDatabaseResponse(data['${effectivePrefix}type'])!, - createdAt: const DateTimeType() - .mapFromDatabaseResponse(data['${effectivePrefix}created_at'])!, - score: const IntType() - .mapFromDatabaseResponse(data['${effectivePrefix}score'])!, - extraData: $PinnedMessageReactionsTable.$converter0.mapToDart( - const StringType() - .mapFromDatabaseResponse(data['${effectivePrefix}extra_data'])), - ); - } @override Map toColumns(bool nullToAbsent) { final map = {}; @@ -2888,8 +3099,8 @@ class PinnedMessageReactionEntity extends DataClass map['created_at'] = Variable(createdAt); map['score'] = Variable(score); if (!nullToAbsent || extraData != null) { - final converter = $PinnedMessageReactionsTable.$converter0; - map['extra_data'] = Variable(converter.mapToSql(extraData)); + final converter = $PinnedMessageReactionsTable.$converterextraDatan; + map['extra_data'] = Variable(converter.toSql(extraData)); } return map; } @@ -2970,6 +3181,7 @@ class PinnedMessageReactionsCompanion final Value createdAt; final Value score; final Value?> extraData; + final Value rowid; const PinnedMessageReactionsCompanion({ this.userId = const Value.absent(), this.messageId = const Value.absent(), @@ -2977,6 +3189,7 @@ class PinnedMessageReactionsCompanion this.createdAt = const Value.absent(), this.score = const Value.absent(), this.extraData = const Value.absent(), + this.rowid = const Value.absent(), }); PinnedMessageReactionsCompanion.insert({ required String userId, @@ -2985,6 +3198,7 @@ class PinnedMessageReactionsCompanion this.createdAt = const Value.absent(), this.score = const Value.absent(), this.extraData = const Value.absent(), + this.rowid = const Value.absent(), }) : userId = Value(userId), messageId = Value(messageId), type = Value(type); @@ -2994,7 +3208,8 @@ class PinnedMessageReactionsCompanion Expression? type, Expression? createdAt, Expression? score, - Expression?>? extraData, + Expression? extraData, + Expression? rowid, }) { return RawValuesInsertable({ if (userId != null) 'user_id': userId, @@ -3003,6 +3218,7 @@ class PinnedMessageReactionsCompanion if (createdAt != null) 'created_at': createdAt, if (score != null) 'score': score, if (extraData != null) 'extra_data': extraData, + if (rowid != null) 'rowid': rowid, }); } @@ -3012,7 +3228,8 @@ class PinnedMessageReactionsCompanion Value? type, Value? createdAt, Value? score, - Value?>? extraData}) { + Value?>? extraData, + Value? rowid}) { return PinnedMessageReactionsCompanion( userId: userId ?? this.userId, messageId: messageId ?? this.messageId, @@ -3020,6 +3237,7 @@ class PinnedMessageReactionsCompanion createdAt: createdAt ?? this.createdAt, score: score ?? this.score, extraData: extraData ?? this.extraData, + rowid: rowid ?? this.rowid, ); } @@ -3042,9 +3260,11 @@ class PinnedMessageReactionsCompanion map['score'] = Variable(score.value); } if (extraData.present) { - final converter = $PinnedMessageReactionsTable.$converter0; - map['extra_data'] = - Variable(converter.mapToSql(extraData.value)); + final converter = $PinnedMessageReactionsTable.$converterextraDatan; + map['extra_data'] = Variable(converter.toSql(extraData.value)); + } + if (rowid.present) { + map['rowid'] = Variable(rowid.value); } return map; } @@ -3057,66 +3277,69 @@ class PinnedMessageReactionsCompanion ..write('type: $type, ') ..write('createdAt: $createdAt, ') ..write('score: $score, ') - ..write('extraData: $extraData') + ..write('extraData: $extraData, ') + ..write('rowid: $rowid') ..write(')')) .toString(); } } -class $PinnedMessageReactionsTable extends PinnedMessageReactions - with TableInfo<$PinnedMessageReactionsTable, PinnedMessageReactionEntity> { +class $ReactionsTable extends Reactions + with TableInfo<$ReactionsTable, ReactionEntity> { @override final GeneratedDatabase attachedDatabase; final String? _alias; - $PinnedMessageReactionsTable(this.attachedDatabase, [this._alias]); - final VerificationMeta _userIdMeta = const VerificationMeta('userId'); + $ReactionsTable(this.attachedDatabase, [this._alias]); + static const VerificationMeta _userIdMeta = const VerificationMeta('userId'); @override - late final GeneratedColumn userId = GeneratedColumn( + late final GeneratedColumn userId = GeneratedColumn( 'user_id', aliasedName, false, - type: const StringType(), requiredDuringInsert: true); - final VerificationMeta _messageIdMeta = const VerificationMeta('messageId'); + type: DriftSqlType.string, requiredDuringInsert: true); + static const VerificationMeta _messageIdMeta = + const VerificationMeta('messageId'); @override - late final GeneratedColumn messageId = GeneratedColumn( + late final GeneratedColumn messageId = GeneratedColumn( 'message_id', aliasedName, false, - type: const StringType(), + type: DriftSqlType.string, requiredDuringInsert: true, - $customConstraints: 'REFERENCES pinned_messages(id) ON DELETE CASCADE'); - final VerificationMeta _typeMeta = const VerificationMeta('type'); + $customConstraints: 'REFERENCES messages(id) ON DELETE CASCADE'); + static const VerificationMeta _typeMeta = const VerificationMeta('type'); @override - late final GeneratedColumn type = GeneratedColumn( + late final GeneratedColumn type = GeneratedColumn( 'type', aliasedName, false, - type: const StringType(), requiredDuringInsert: true); - final VerificationMeta _createdAtMeta = const VerificationMeta('createdAt'); + type: DriftSqlType.string, requiredDuringInsert: true); + static const VerificationMeta _createdAtMeta = + const VerificationMeta('createdAt'); @override - late final GeneratedColumn createdAt = GeneratedColumn( + late final GeneratedColumn createdAt = GeneratedColumn( 'created_at', aliasedName, false, - type: const IntType(), + type: DriftSqlType.dateTime, requiredDuringInsert: false, defaultValue: currentDateAndTime); - final VerificationMeta _scoreMeta = const VerificationMeta('score'); + static const VerificationMeta _scoreMeta = const VerificationMeta('score'); @override - late final GeneratedColumn score = GeneratedColumn( + late final GeneratedColumn score = GeneratedColumn( 'score', aliasedName, false, - type: const IntType(), + type: DriftSqlType.int, requiredDuringInsert: false, defaultValue: const Constant(0)); - final VerificationMeta _extraDataMeta = const VerificationMeta('extraData'); + static const VerificationMeta _extraDataMeta = + const VerificationMeta('extraData'); @override - late final GeneratedColumnWithTypeConverter, String?> - extraData = GeneratedColumn('extra_data', aliasedName, true, - type: const StringType(), requiredDuringInsert: false) - .withConverter>( - $PinnedMessageReactionsTable.$converter0); + late final GeneratedColumnWithTypeConverter?, String> + extraData = GeneratedColumn('extra_data', aliasedName, true, + type: DriftSqlType.string, requiredDuringInsert: false) + .withConverter?>( + $ReactionsTable.$converterextraDatan); @override List get $columns => [userId, messageId, type, createdAt, score, extraData]; @override - String get aliasedName => _alias ?? 'pinned_message_reactions'; + String get aliasedName => _alias ?? 'reactions'; @override - String get actualTableName => 'pinned_message_reactions'; + String get actualTableName => 'reactions'; @override - VerificationContext validateIntegrity( - Insertable instance, + VerificationContext validateIntegrity(Insertable instance, {bool isInserting = false}) { final context = VerificationContext(); final data = instance.toColumns(true); @@ -3153,19 +3376,34 @@ class $PinnedMessageReactionsTable extends PinnedMessageReactions @override Set get $primaryKey => {messageId, type, userId}; @override - PinnedMessageReactionEntity map(Map data, - {String? tablePrefix}) { - return PinnedMessageReactionEntity.fromData(data, - prefix: tablePrefix != null ? '$tablePrefix.' : null); + ReactionEntity map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return ReactionEntity( + userId: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}user_id'])!, + messageId: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}message_id'])!, + type: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}type'])!, + createdAt: attachedDatabase.typeMapping + .read(DriftSqlType.dateTime, data['${effectivePrefix}created_at'])!, + score: attachedDatabase.typeMapping + .read(DriftSqlType.int, data['${effectivePrefix}score'])!, + extraData: $ReactionsTable.$converterextraDatan.fromSql(attachedDatabase + .typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}extra_data'])), + ); } @override - $PinnedMessageReactionsTable createAlias(String alias) { - return $PinnedMessageReactionsTable(attachedDatabase, alias); + $ReactionsTable createAlias(String alias) { + return $ReactionsTable(attachedDatabase, alias); } - static TypeConverter, String> $converter0 = + static TypeConverter, String> $converterextraData = MapConverter(); + static TypeConverter?, String?> $converterextraDatan = + NullAwareTypeConverter.wrap($converterextraData); } class ReactionEntity extends DataClass implements Insertable { @@ -3186,30 +3424,13 @@ class ReactionEntity extends DataClass implements Insertable { /// Reaction custom extraData final Map? extraData; - ReactionEntity( + const ReactionEntity( {required this.userId, required this.messageId, required this.type, required this.createdAt, required this.score, this.extraData}); - factory ReactionEntity.fromData(Map data, {String? prefix}) { - final effectivePrefix = prefix ?? ''; - return ReactionEntity( - userId: const StringType() - .mapFromDatabaseResponse(data['${effectivePrefix}user_id'])!, - messageId: const StringType() - .mapFromDatabaseResponse(data['${effectivePrefix}message_id'])!, - type: const StringType() - .mapFromDatabaseResponse(data['${effectivePrefix}type'])!, - createdAt: const DateTimeType() - .mapFromDatabaseResponse(data['${effectivePrefix}created_at'])!, - score: const IntType() - .mapFromDatabaseResponse(data['${effectivePrefix}score'])!, - extraData: $ReactionsTable.$converter0.mapToDart(const StringType() - .mapFromDatabaseResponse(data['${effectivePrefix}extra_data'])), - ); - } @override Map toColumns(bool nullToAbsent) { final map = {}; @@ -3219,8 +3440,8 @@ class ReactionEntity extends DataClass implements Insertable { map['created_at'] = Variable(createdAt); map['score'] = Variable(score); if (!nullToAbsent || extraData != null) { - final converter = $ReactionsTable.$converter0; - map['extra_data'] = Variable(converter.mapToSql(extraData)); + final converter = $ReactionsTable.$converterextraDatan; + map['extra_data'] = Variable(converter.toSql(extraData)); } return map; } @@ -3300,6 +3521,7 @@ class ReactionsCompanion extends UpdateCompanion { final Value createdAt; final Value score; final Value?> extraData; + final Value rowid; const ReactionsCompanion({ this.userId = const Value.absent(), this.messageId = const Value.absent(), @@ -3307,6 +3529,7 @@ class ReactionsCompanion extends UpdateCompanion { this.createdAt = const Value.absent(), this.score = const Value.absent(), this.extraData = const Value.absent(), + this.rowid = const Value.absent(), }); ReactionsCompanion.insert({ required String userId, @@ -3315,6 +3538,7 @@ class ReactionsCompanion extends UpdateCompanion { this.createdAt = const Value.absent(), this.score = const Value.absent(), this.extraData = const Value.absent(), + this.rowid = const Value.absent(), }) : userId = Value(userId), messageId = Value(messageId), type = Value(type); @@ -3324,7 +3548,8 @@ class ReactionsCompanion extends UpdateCompanion { Expression? type, Expression? createdAt, Expression? score, - Expression?>? extraData, + Expression? extraData, + Expression? rowid, }) { return RawValuesInsertable({ if (userId != null) 'user_id': userId, @@ -3333,6 +3558,7 @@ class ReactionsCompanion extends UpdateCompanion { if (createdAt != null) 'created_at': createdAt, if (score != null) 'score': score, if (extraData != null) 'extra_data': extraData, + if (rowid != null) 'rowid': rowid, }); } @@ -3342,7 +3568,8 @@ class ReactionsCompanion extends UpdateCompanion { Value? type, Value? createdAt, Value? score, - Value?>? extraData}) { + Value?>? extraData, + Value? rowid}) { return ReactionsCompanion( userId: userId ?? this.userId, messageId: messageId ?? this.messageId, @@ -3350,6 +3577,7 @@ class ReactionsCompanion extends UpdateCompanion { createdAt: createdAt ?? this.createdAt, score: score ?? this.score, extraData: extraData ?? this.extraData, + rowid: rowid ?? this.rowid, ); } @@ -3372,9 +3600,11 @@ class ReactionsCompanion extends UpdateCompanion { map['score'] = Variable(score.value); } if (extraData.present) { - final converter = $ReactionsTable.$converter0; - map['extra_data'] = - Variable(converter.mapToSql(extraData.value)); + final converter = $ReactionsTable.$converterextraDatan; + map['extra_data'] = Variable(converter.toSql(extraData.value)); + } + if (rowid.present) { + map['rowid'] = Variable(rowid.value); } return map; } @@ -3387,111 +3617,181 @@ class ReactionsCompanion extends UpdateCompanion { ..write('type: $type, ') ..write('createdAt: $createdAt, ') ..write('score: $score, ') - ..write('extraData: $extraData') + ..write('extraData: $extraData, ') + ..write('rowid: $rowid') ..write(')')) .toString(); } } -class $ReactionsTable extends Reactions - with TableInfo<$ReactionsTable, ReactionEntity> { +class $UsersTable extends Users with TableInfo<$UsersTable, UserEntity> { @override final GeneratedDatabase attachedDatabase; final String? _alias; - $ReactionsTable(this.attachedDatabase, [this._alias]); - final VerificationMeta _userIdMeta = const VerificationMeta('userId'); + $UsersTable(this.attachedDatabase, [this._alias]); + static const VerificationMeta _idMeta = const VerificationMeta('id'); @override - late final GeneratedColumn userId = GeneratedColumn( - 'user_id', aliasedName, false, - type: const StringType(), requiredDuringInsert: true); - final VerificationMeta _messageIdMeta = const VerificationMeta('messageId'); + late final GeneratedColumn id = GeneratedColumn( + 'id', aliasedName, false, + type: DriftSqlType.string, requiredDuringInsert: true); + static const VerificationMeta _roleMeta = const VerificationMeta('role'); @override - late final GeneratedColumn messageId = GeneratedColumn( - 'message_id', aliasedName, false, - type: const StringType(), - requiredDuringInsert: true, - $customConstraints: 'REFERENCES messages(id) ON DELETE CASCADE'); - final VerificationMeta _typeMeta = const VerificationMeta('type'); + late final GeneratedColumn role = GeneratedColumn( + 'role', aliasedName, true, + type: DriftSqlType.string, requiredDuringInsert: false); + static const VerificationMeta _languageMeta = + const VerificationMeta('language'); @override - late final GeneratedColumn type = GeneratedColumn( - 'type', aliasedName, false, - type: const StringType(), requiredDuringInsert: true); - final VerificationMeta _createdAtMeta = const VerificationMeta('createdAt'); + late final GeneratedColumn language = GeneratedColumn( + 'language', aliasedName, true, + type: DriftSqlType.string, requiredDuringInsert: false); + static const VerificationMeta _createdAtMeta = + const VerificationMeta('createdAt'); @override - late final GeneratedColumn createdAt = GeneratedColumn( + late final GeneratedColumn createdAt = GeneratedColumn( 'created_at', aliasedName, false, - type: const IntType(), + type: DriftSqlType.dateTime, requiredDuringInsert: false, defaultValue: currentDateAndTime); - final VerificationMeta _scoreMeta = const VerificationMeta('score'); + static const VerificationMeta _updatedAtMeta = + const VerificationMeta('updatedAt'); @override - late final GeneratedColumn score = GeneratedColumn( - 'score', aliasedName, false, - type: const IntType(), + late final GeneratedColumn updatedAt = GeneratedColumn( + 'updated_at', aliasedName, false, + type: DriftSqlType.dateTime, requiredDuringInsert: false, - defaultValue: const Constant(0)); - final VerificationMeta _extraDataMeta = const VerificationMeta('extraData'); + defaultValue: currentDateAndTime); + static const VerificationMeta _lastActiveMeta = + const VerificationMeta('lastActive'); @override - late final GeneratedColumnWithTypeConverter, String?> - extraData = GeneratedColumn('extra_data', aliasedName, true, - type: const StringType(), requiredDuringInsert: false) - .withConverter>($ReactionsTable.$converter0); + late final GeneratedColumn lastActive = GeneratedColumn( + 'last_active', aliasedName, true, + type: DriftSqlType.dateTime, requiredDuringInsert: false); + static const VerificationMeta _onlineMeta = const VerificationMeta('online'); + @override + late final GeneratedColumn online = + GeneratedColumn('online', aliasedName, false, + type: DriftSqlType.bool, + requiredDuringInsert: false, + defaultConstraints: GeneratedColumn.constraintsDependsOnDialect({ + SqlDialect.sqlite: 'CHECK ("online" IN (0, 1))', + SqlDialect.mysql: '', + SqlDialect.postgres: '', + }), + defaultValue: const Constant(false)); + static const VerificationMeta _bannedMeta = const VerificationMeta('banned'); + @override + late final GeneratedColumn banned = + GeneratedColumn('banned', aliasedName, false, + type: DriftSqlType.bool, + requiredDuringInsert: false, + defaultConstraints: GeneratedColumn.constraintsDependsOnDialect({ + SqlDialect.sqlite: 'CHECK ("banned" IN (0, 1))', + SqlDialect.mysql: '', + SqlDialect.postgres: '', + }), + defaultValue: const Constant(false)); + static const VerificationMeta _extraDataMeta = + const VerificationMeta('extraData'); + @override + late final GeneratedColumnWithTypeConverter, String> + extraData = GeneratedColumn('extra_data', aliasedName, false, + type: DriftSqlType.string, requiredDuringInsert: true) + .withConverter>($UsersTable.$converterextraData); @override - List get $columns => - [userId, messageId, type, createdAt, score, extraData]; + List get $columns => [ + id, + role, + language, + createdAt, + updatedAt, + lastActive, + online, + banned, + extraData + ]; @override - String get aliasedName => _alias ?? 'reactions'; + String get aliasedName => _alias ?? 'users'; @override - String get actualTableName => 'reactions'; + String get actualTableName => 'users'; @override - VerificationContext validateIntegrity(Insertable instance, + VerificationContext validateIntegrity(Insertable instance, {bool isInserting = false}) { final context = VerificationContext(); final data = instance.toColumns(true); - if (data.containsKey('user_id')) { - context.handle(_userIdMeta, - userId.isAcceptableOrUnknown(data['user_id']!, _userIdMeta)); - } else if (isInserting) { - context.missing(_userIdMeta); - } - if (data.containsKey('message_id')) { - context.handle(_messageIdMeta, - messageId.isAcceptableOrUnknown(data['message_id']!, _messageIdMeta)); + if (data.containsKey('id')) { + context.handle(_idMeta, id.isAcceptableOrUnknown(data['id']!, _idMeta)); } else if (isInserting) { - context.missing(_messageIdMeta); + context.missing(_idMeta); } - if (data.containsKey('type')) { + if (data.containsKey('role')) { context.handle( - _typeMeta, type.isAcceptableOrUnknown(data['type']!, _typeMeta)); - } else if (isInserting) { - context.missing(_typeMeta); + _roleMeta, role.isAcceptableOrUnknown(data['role']!, _roleMeta)); + } + if (data.containsKey('language')) { + context.handle(_languageMeta, + language.isAcceptableOrUnknown(data['language']!, _languageMeta)); } if (data.containsKey('created_at')) { context.handle(_createdAtMeta, createdAt.isAcceptableOrUnknown(data['created_at']!, _createdAtMeta)); } - if (data.containsKey('score')) { + if (data.containsKey('updated_at')) { + context.handle(_updatedAtMeta, + updatedAt.isAcceptableOrUnknown(data['updated_at']!, _updatedAtMeta)); + } + if (data.containsKey('last_active')) { context.handle( - _scoreMeta, score.isAcceptableOrUnknown(data['score']!, _scoreMeta)); + _lastActiveMeta, + lastActive.isAcceptableOrUnknown( + data['last_active']!, _lastActiveMeta)); + } + if (data.containsKey('online')) { + context.handle(_onlineMeta, + online.isAcceptableOrUnknown(data['online']!, _onlineMeta)); + } + if (data.containsKey('banned')) { + context.handle(_bannedMeta, + banned.isAcceptableOrUnknown(data['banned']!, _bannedMeta)); } context.handle(_extraDataMeta, const VerificationResult.success()); return context; } @override - Set get $primaryKey => {messageId, type, userId}; + Set get $primaryKey => {id}; @override - ReactionEntity map(Map data, {String? tablePrefix}) { - return ReactionEntity.fromData(data, - prefix: tablePrefix != null ? '$tablePrefix.' : null); + UserEntity map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return UserEntity( + id: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}id'])!, + role: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}role']), + language: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}language']), + createdAt: attachedDatabase.typeMapping + .read(DriftSqlType.dateTime, data['${effectivePrefix}created_at'])!, + updatedAt: attachedDatabase.typeMapping + .read(DriftSqlType.dateTime, data['${effectivePrefix}updated_at'])!, + lastActive: attachedDatabase.typeMapping + .read(DriftSqlType.dateTime, data['${effectivePrefix}last_active']), + online: attachedDatabase.typeMapping + .read(DriftSqlType.bool, data['${effectivePrefix}online'])!, + banned: attachedDatabase.typeMapping + .read(DriftSqlType.bool, data['${effectivePrefix}banned'])!, + extraData: $UsersTable.$converterextraData.fromSql(attachedDatabase + .typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}extra_data'])!), + ); } @override - $ReactionsTable createAlias(String alias) { - return $ReactionsTable(attachedDatabase, alias); + $UsersTable createAlias(String alias) { + return $UsersTable(attachedDatabase, alias); } - static TypeConverter, String> $converter0 = + static TypeConverter, String> $converterextraData = MapConverter(); } @@ -3522,7 +3822,7 @@ class UserEntity extends DataClass implements Insertable { /// Map of custom user extraData final Map extraData; - UserEntity( + const UserEntity( {required this.id, this.role, this.language, @@ -3531,50 +3831,27 @@ class UserEntity extends DataClass implements Insertable { this.lastActive, required this.online, required this.banned, - required this.extraData}); - factory UserEntity.fromData(Map data, {String? prefix}) { - final effectivePrefix = prefix ?? ''; - return UserEntity( - id: const StringType() - .mapFromDatabaseResponse(data['${effectivePrefix}id'])!, - role: const StringType() - .mapFromDatabaseResponse(data['${effectivePrefix}role']), - language: const StringType() - .mapFromDatabaseResponse(data['${effectivePrefix}language']), - createdAt: const DateTimeType() - .mapFromDatabaseResponse(data['${effectivePrefix}created_at'])!, - updatedAt: const DateTimeType() - .mapFromDatabaseResponse(data['${effectivePrefix}updated_at'])!, - lastActive: const DateTimeType() - .mapFromDatabaseResponse(data['${effectivePrefix}last_active']), - online: const BoolType() - .mapFromDatabaseResponse(data['${effectivePrefix}online'])!, - banned: const BoolType() - .mapFromDatabaseResponse(data['${effectivePrefix}banned'])!, - extraData: $UsersTable.$converter0.mapToDart(const StringType() - .mapFromDatabaseResponse(data['${effectivePrefix}extra_data']))!, - ); - } + required this.extraData}); @override Map toColumns(bool nullToAbsent) { final map = {}; map['id'] = Variable(id); if (!nullToAbsent || role != null) { - map['role'] = Variable(role); + map['role'] = Variable(role); } if (!nullToAbsent || language != null) { - map['language'] = Variable(language); + map['language'] = Variable(language); } map['created_at'] = Variable(createdAt); map['updated_at'] = Variable(updatedAt); if (!nullToAbsent || lastActive != null) { - map['last_active'] = Variable(lastActive); + map['last_active'] = Variable(lastActive); } map['online'] = Variable(online); map['banned'] = Variable(banned); { - final converter = $UsersTable.$converter0; - map['extra_data'] = Variable(converter.mapToSql(extraData)!); + final converter = $UsersTable.$converterextraData; + map['extra_data'] = Variable(converter.toSql(extraData)); } return map; } @@ -3675,6 +3952,7 @@ class UsersCompanion extends UpdateCompanion { final Value online; final Value banned; final Value> extraData; + final Value rowid; const UsersCompanion({ this.id = const Value.absent(), this.role = const Value.absent(), @@ -3685,6 +3963,7 @@ class UsersCompanion extends UpdateCompanion { this.online = const Value.absent(), this.banned = const Value.absent(), this.extraData = const Value.absent(), + this.rowid = const Value.absent(), }); UsersCompanion.insert({ required String id, @@ -3696,18 +3975,20 @@ class UsersCompanion extends UpdateCompanion { this.online = const Value.absent(), this.banned = const Value.absent(), required Map extraData, + this.rowid = const Value.absent(), }) : id = Value(id), extraData = Value(extraData); static Insertable custom({ Expression? id, - Expression? role, - Expression? language, + Expression? role, + Expression? language, Expression? createdAt, Expression? updatedAt, - Expression? lastActive, + Expression? lastActive, Expression? online, Expression? banned, - Expression>? extraData, + Expression? extraData, + Expression? rowid, }) { return RawValuesInsertable({ if (id != null) 'id': id, @@ -3719,6 +4000,7 @@ class UsersCompanion extends UpdateCompanion { if (online != null) 'online': online, if (banned != null) 'banned': banned, if (extraData != null) 'extra_data': extraData, + if (rowid != null) 'rowid': rowid, }); } @@ -3731,7 +4013,8 @@ class UsersCompanion extends UpdateCompanion { Value? lastActive, Value? online, Value? banned, - Value>? extraData}) { + Value>? extraData, + Value? rowid}) { return UsersCompanion( id: id ?? this.id, role: role ?? this.role, @@ -3742,6 +4025,7 @@ class UsersCompanion extends UpdateCompanion { online: online ?? this.online, banned: banned ?? this.banned, extraData: extraData ?? this.extraData, + rowid: rowid ?? this.rowid, ); } @@ -3752,10 +4036,10 @@ class UsersCompanion extends UpdateCompanion { map['id'] = Variable(id.value); } if (role.present) { - map['role'] = Variable(role.value); + map['role'] = Variable(role.value); } if (language.present) { - map['language'] = Variable(language.value); + map['language'] = Variable(language.value); } if (createdAt.present) { map['created_at'] = Variable(createdAt.value); @@ -3764,7 +4048,7 @@ class UsersCompanion extends UpdateCompanion { map['updated_at'] = Variable(updatedAt.value); } if (lastActive.present) { - map['last_active'] = Variable(lastActive.value); + map['last_active'] = Variable(lastActive.value); } if (online.present) { map['online'] = Variable(online.value); @@ -3773,9 +4057,11 @@ class UsersCompanion extends UpdateCompanion { map['banned'] = Variable(banned.value); } if (extraData.present) { - final converter = $UsersTable.$converter0; - map['extra_data'] = - Variable(converter.mapToSql(extraData.value)!); + final converter = $UsersTable.$converterextraData; + map['extra_data'] = Variable(converter.toSql(extraData.value)); + } + if (rowid.present) { + map['rowid'] = Variable(rowid.value); } return map; } @@ -3791,148 +4077,238 @@ class UsersCompanion extends UpdateCompanion { ..write('lastActive: $lastActive, ') ..write('online: $online, ') ..write('banned: $banned, ') - ..write('extraData: $extraData') + ..write('extraData: $extraData, ') + ..write('rowid: $rowid') ..write(')')) .toString(); } } -class $UsersTable extends Users with TableInfo<$UsersTable, UserEntity> { +class $MembersTable extends Members + with TableInfo<$MembersTable, MemberEntity> { @override final GeneratedDatabase attachedDatabase; final String? _alias; - $UsersTable(this.attachedDatabase, [this._alias]); - final VerificationMeta _idMeta = const VerificationMeta('id'); + $MembersTable(this.attachedDatabase, [this._alias]); + static const VerificationMeta _userIdMeta = const VerificationMeta('userId'); @override - late final GeneratedColumn id = GeneratedColumn( - 'id', aliasedName, false, - type: const StringType(), requiredDuringInsert: true); - final VerificationMeta _roleMeta = const VerificationMeta('role'); + late final GeneratedColumn userId = GeneratedColumn( + 'user_id', aliasedName, false, + type: DriftSqlType.string, requiredDuringInsert: true); + static const VerificationMeta _channelCidMeta = + const VerificationMeta('channelCid'); @override - late final GeneratedColumn role = GeneratedColumn( - 'role', aliasedName, true, - type: const StringType(), requiredDuringInsert: false); - final VerificationMeta _languageMeta = const VerificationMeta('language'); + late final GeneratedColumn channelCid = GeneratedColumn( + 'channel_cid', aliasedName, false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'REFERENCES channels(cid) ON DELETE CASCADE'); + static const VerificationMeta _channelRoleMeta = + const VerificationMeta('channelRole'); @override - late final GeneratedColumn language = GeneratedColumn( - 'language', aliasedName, true, - type: const StringType(), requiredDuringInsert: false); - final VerificationMeta _createdAtMeta = const VerificationMeta('createdAt'); + late final GeneratedColumn channelRole = GeneratedColumn( + 'channel_role', aliasedName, true, + type: DriftSqlType.string, requiredDuringInsert: false); + static const VerificationMeta _inviteAcceptedAtMeta = + const VerificationMeta('inviteAcceptedAt'); + @override + late final GeneratedColumn inviteAcceptedAt = + GeneratedColumn('invite_accepted_at', aliasedName, true, + type: DriftSqlType.dateTime, requiredDuringInsert: false); + static const VerificationMeta _inviteRejectedAtMeta = + const VerificationMeta('inviteRejectedAt'); + @override + late final GeneratedColumn inviteRejectedAt = + GeneratedColumn('invite_rejected_at', aliasedName, true, + type: DriftSqlType.dateTime, requiredDuringInsert: false); + static const VerificationMeta _invitedMeta = + const VerificationMeta('invited'); + @override + late final GeneratedColumn invited = + GeneratedColumn('invited', aliasedName, false, + type: DriftSqlType.bool, + requiredDuringInsert: false, + defaultConstraints: GeneratedColumn.constraintsDependsOnDialect({ + SqlDialect.sqlite: 'CHECK ("invited" IN (0, 1))', + SqlDialect.mysql: '', + SqlDialect.postgres: '', + }), + defaultValue: const Constant(false)); + static const VerificationMeta _bannedMeta = const VerificationMeta('banned'); + @override + late final GeneratedColumn banned = + GeneratedColumn('banned', aliasedName, false, + type: DriftSqlType.bool, + requiredDuringInsert: false, + defaultConstraints: GeneratedColumn.constraintsDependsOnDialect({ + SqlDialect.sqlite: 'CHECK ("banned" IN (0, 1))', + SqlDialect.mysql: '', + SqlDialect.postgres: '', + }), + defaultValue: const Constant(false)); + static const VerificationMeta _shadowBannedMeta = + const VerificationMeta('shadowBanned'); + @override + late final GeneratedColumn shadowBanned = + GeneratedColumn('shadow_banned', aliasedName, false, + type: DriftSqlType.bool, + requiredDuringInsert: false, + defaultConstraints: GeneratedColumn.constraintsDependsOnDialect({ + SqlDialect.sqlite: 'CHECK ("shadow_banned" IN (0, 1))', + SqlDialect.mysql: '', + SqlDialect.postgres: '', + }), + defaultValue: const Constant(false)); + static const VerificationMeta _isModeratorMeta = + const VerificationMeta('isModerator'); @override - late final GeneratedColumn createdAt = GeneratedColumn( + late final GeneratedColumn isModerator = + GeneratedColumn('is_moderator', aliasedName, false, + type: DriftSqlType.bool, + requiredDuringInsert: false, + defaultConstraints: GeneratedColumn.constraintsDependsOnDialect({ + SqlDialect.sqlite: 'CHECK ("is_moderator" IN (0, 1))', + SqlDialect.mysql: '', + SqlDialect.postgres: '', + }), + defaultValue: const Constant(false)); + static const VerificationMeta _createdAtMeta = + const VerificationMeta('createdAt'); + @override + late final GeneratedColumn createdAt = GeneratedColumn( 'created_at', aliasedName, false, - type: const IntType(), + type: DriftSqlType.dateTime, requiredDuringInsert: false, defaultValue: currentDateAndTime); - final VerificationMeta _updatedAtMeta = const VerificationMeta('updatedAt'); + static const VerificationMeta _updatedAtMeta = + const VerificationMeta('updatedAt'); @override - late final GeneratedColumn updatedAt = GeneratedColumn( + late final GeneratedColumn updatedAt = GeneratedColumn( 'updated_at', aliasedName, false, - type: const IntType(), + type: DriftSqlType.dateTime, requiredDuringInsert: false, defaultValue: currentDateAndTime); - final VerificationMeta _lastActiveMeta = const VerificationMeta('lastActive'); - @override - late final GeneratedColumn lastActive = GeneratedColumn( - 'last_active', aliasedName, true, - type: const IntType(), requiredDuringInsert: false); - final VerificationMeta _onlineMeta = const VerificationMeta('online'); - @override - late final GeneratedColumn online = GeneratedColumn( - 'online', aliasedName, false, - type: const BoolType(), - requiredDuringInsert: false, - defaultConstraints: 'CHECK (online IN (0, 1))', - defaultValue: const Constant(false)); - final VerificationMeta _bannedMeta = const VerificationMeta('banned'); - @override - late final GeneratedColumn banned = GeneratedColumn( - 'banned', aliasedName, false, - type: const BoolType(), - requiredDuringInsert: false, - defaultConstraints: 'CHECK (banned IN (0, 1))', - defaultValue: const Constant(false)); - final VerificationMeta _extraDataMeta = const VerificationMeta('extraData'); - @override - late final GeneratedColumnWithTypeConverter, String?> - extraData = GeneratedColumn('extra_data', aliasedName, false, - type: const StringType(), requiredDuringInsert: true) - .withConverter>($UsersTable.$converter0); @override List get $columns => [ - id, - role, - language, - createdAt, - updatedAt, - lastActive, - online, + userId, + channelCid, + channelRole, + inviteAcceptedAt, + inviteRejectedAt, + invited, banned, - extraData + shadowBanned, + isModerator, + createdAt, + updatedAt ]; @override - String get aliasedName => _alias ?? 'users'; + String get aliasedName => _alias ?? 'members'; @override - String get actualTableName => 'users'; + String get actualTableName => 'members'; @override - VerificationContext validateIntegrity(Insertable instance, + VerificationContext validateIntegrity(Insertable instance, {bool isInserting = false}) { final context = VerificationContext(); final data = instance.toColumns(true); - if (data.containsKey('id')) { - context.handle(_idMeta, id.isAcceptableOrUnknown(data['id']!, _idMeta)); + if (data.containsKey('user_id')) { + context.handle(_userIdMeta, + userId.isAcceptableOrUnknown(data['user_id']!, _userIdMeta)); } else if (isInserting) { - context.missing(_idMeta); + context.missing(_userIdMeta); } - if (data.containsKey('role')) { + if (data.containsKey('channel_cid')) { context.handle( - _roleMeta, role.isAcceptableOrUnknown(data['role']!, _roleMeta)); - } - if (data.containsKey('language')) { - context.handle(_languageMeta, - language.isAcceptableOrUnknown(data['language']!, _languageMeta)); + _channelCidMeta, + channelCid.isAcceptableOrUnknown( + data['channel_cid']!, _channelCidMeta)); + } else if (isInserting) { + context.missing(_channelCidMeta); } - if (data.containsKey('created_at')) { - context.handle(_createdAtMeta, - createdAt.isAcceptableOrUnknown(data['created_at']!, _createdAtMeta)); + if (data.containsKey('channel_role')) { + context.handle( + _channelRoleMeta, + channelRole.isAcceptableOrUnknown( + data['channel_role']!, _channelRoleMeta)); } - if (data.containsKey('updated_at')) { - context.handle(_updatedAtMeta, - updatedAt.isAcceptableOrUnknown(data['updated_at']!, _updatedAtMeta)); + if (data.containsKey('invite_accepted_at')) { + context.handle( + _inviteAcceptedAtMeta, + inviteAcceptedAt.isAcceptableOrUnknown( + data['invite_accepted_at']!, _inviteAcceptedAtMeta)); } - if (data.containsKey('last_active')) { + if (data.containsKey('invite_rejected_at')) { context.handle( - _lastActiveMeta, - lastActive.isAcceptableOrUnknown( - data['last_active']!, _lastActiveMeta)); + _inviteRejectedAtMeta, + inviteRejectedAt.isAcceptableOrUnknown( + data['invite_rejected_at']!, _inviteRejectedAtMeta)); } - if (data.containsKey('online')) { - context.handle(_onlineMeta, - online.isAcceptableOrUnknown(data['online']!, _onlineMeta)); + if (data.containsKey('invited')) { + context.handle(_invitedMeta, + invited.isAcceptableOrUnknown(data['invited']!, _invitedMeta)); } if (data.containsKey('banned')) { context.handle(_bannedMeta, banned.isAcceptableOrUnknown(data['banned']!, _bannedMeta)); } - context.handle(_extraDataMeta, const VerificationResult.success()); + if (data.containsKey('shadow_banned')) { + context.handle( + _shadowBannedMeta, + shadowBanned.isAcceptableOrUnknown( + data['shadow_banned']!, _shadowBannedMeta)); + } + if (data.containsKey('is_moderator')) { + context.handle( + _isModeratorMeta, + isModerator.isAcceptableOrUnknown( + data['is_moderator']!, _isModeratorMeta)); + } + if (data.containsKey('created_at')) { + context.handle(_createdAtMeta, + createdAt.isAcceptableOrUnknown(data['created_at']!, _createdAtMeta)); + } + if (data.containsKey('updated_at')) { + context.handle(_updatedAtMeta, + updatedAt.isAcceptableOrUnknown(data['updated_at']!, _updatedAtMeta)); + } return context; } @override - Set get $primaryKey => {id}; + Set get $primaryKey => {userId, channelCid}; @override - UserEntity map(Map data, {String? tablePrefix}) { - return UserEntity.fromData(data, - prefix: tablePrefix != null ? '$tablePrefix.' : null); + MemberEntity map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return MemberEntity( + userId: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}user_id'])!, + channelCid: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}channel_cid'])!, + channelRole: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}channel_role']), + inviteAcceptedAt: attachedDatabase.typeMapping.read( + DriftSqlType.dateTime, data['${effectivePrefix}invite_accepted_at']), + inviteRejectedAt: attachedDatabase.typeMapping.read( + DriftSqlType.dateTime, data['${effectivePrefix}invite_rejected_at']), + invited: attachedDatabase.typeMapping + .read(DriftSqlType.bool, data['${effectivePrefix}invited'])!, + banned: attachedDatabase.typeMapping + .read(DriftSqlType.bool, data['${effectivePrefix}banned'])!, + shadowBanned: attachedDatabase.typeMapping + .read(DriftSqlType.bool, data['${effectivePrefix}shadow_banned'])!, + isModerator: attachedDatabase.typeMapping + .read(DriftSqlType.bool, data['${effectivePrefix}is_moderator'])!, + createdAt: attachedDatabase.typeMapping + .read(DriftSqlType.dateTime, data['${effectivePrefix}created_at'])!, + updatedAt: attachedDatabase.typeMapping + .read(DriftSqlType.dateTime, data['${effectivePrefix}updated_at'])!, + ); } @override - $UsersTable createAlias(String alias) { - return $UsersTable(attachedDatabase, alias); + $MembersTable createAlias(String alias) { + return $MembersTable(attachedDatabase, alias); } - - static TypeConverter, String> $converter0 = - MapConverter(); } class MemberEntity extends DataClass implements Insertable { @@ -3968,7 +4344,7 @@ class MemberEntity extends DataClass implements Insertable { /// The last date of update final DateTime updatedAt; - MemberEntity( + const MemberEntity( {required this.userId, required this.channelCid, this.channelRole, @@ -3980,46 +4356,19 @@ class MemberEntity extends DataClass implements Insertable { required this.isModerator, required this.createdAt, required this.updatedAt}); - factory MemberEntity.fromData(Map data, {String? prefix}) { - final effectivePrefix = prefix ?? ''; - return MemberEntity( - userId: const StringType() - .mapFromDatabaseResponse(data['${effectivePrefix}user_id'])!, - channelCid: const StringType() - .mapFromDatabaseResponse(data['${effectivePrefix}channel_cid'])!, - channelRole: const StringType() - .mapFromDatabaseResponse(data['${effectivePrefix}channel_role']), - inviteAcceptedAt: const DateTimeType().mapFromDatabaseResponse( - data['${effectivePrefix}invite_accepted_at']), - inviteRejectedAt: const DateTimeType().mapFromDatabaseResponse( - data['${effectivePrefix}invite_rejected_at']), - invited: const BoolType() - .mapFromDatabaseResponse(data['${effectivePrefix}invited'])!, - banned: const BoolType() - .mapFromDatabaseResponse(data['${effectivePrefix}banned'])!, - shadowBanned: const BoolType() - .mapFromDatabaseResponse(data['${effectivePrefix}shadow_banned'])!, - isModerator: const BoolType() - .mapFromDatabaseResponse(data['${effectivePrefix}is_moderator'])!, - createdAt: const DateTimeType() - .mapFromDatabaseResponse(data['${effectivePrefix}created_at'])!, - updatedAt: const DateTimeType() - .mapFromDatabaseResponse(data['${effectivePrefix}updated_at'])!, - ); - } @override Map toColumns(bool nullToAbsent) { final map = {}; map['user_id'] = Variable(userId); map['channel_cid'] = Variable(channelCid); if (!nullToAbsent || channelRole != null) { - map['channel_role'] = Variable(channelRole); + map['channel_role'] = Variable(channelRole); } if (!nullToAbsent || inviteAcceptedAt != null) { - map['invite_accepted_at'] = Variable(inviteAcceptedAt); + map['invite_accepted_at'] = Variable(inviteAcceptedAt); } if (!nullToAbsent || inviteRejectedAt != null) { - map['invite_rejected_at'] = Variable(inviteRejectedAt); + map['invite_rejected_at'] = Variable(inviteRejectedAt); } map['invited'] = Variable(invited); map['banned'] = Variable(banned); @@ -4156,6 +4505,7 @@ class MembersCompanion extends UpdateCompanion { final Value isModerator; final Value createdAt; final Value updatedAt; + final Value rowid; const MembersCompanion({ this.userId = const Value.absent(), this.channelCid = const Value.absent(), @@ -4168,6 +4518,7 @@ class MembersCompanion extends UpdateCompanion { this.isModerator = const Value.absent(), this.createdAt = const Value.absent(), this.updatedAt = const Value.absent(), + this.rowid = const Value.absent(), }); MembersCompanion.insert({ required String userId, @@ -4181,20 +4532,22 @@ class MembersCompanion extends UpdateCompanion { this.isModerator = const Value.absent(), this.createdAt = const Value.absent(), this.updatedAt = const Value.absent(), + this.rowid = const Value.absent(), }) : userId = Value(userId), channelCid = Value(channelCid); static Insertable custom({ Expression? userId, Expression? channelCid, - Expression? channelRole, - Expression? inviteAcceptedAt, - Expression? inviteRejectedAt, + Expression? channelRole, + Expression? inviteAcceptedAt, + Expression? inviteRejectedAt, Expression? invited, Expression? banned, Expression? shadowBanned, Expression? isModerator, Expression? createdAt, Expression? updatedAt, + Expression? rowid, }) { return RawValuesInsertable({ if (userId != null) 'user_id': userId, @@ -4208,6 +4561,7 @@ class MembersCompanion extends UpdateCompanion { if (isModerator != null) 'is_moderator': isModerator, if (createdAt != null) 'created_at': createdAt, if (updatedAt != null) 'updated_at': updatedAt, + if (rowid != null) 'rowid': rowid, }); } @@ -4222,7 +4576,8 @@ class MembersCompanion extends UpdateCompanion { Value? shadowBanned, Value? isModerator, Value? createdAt, - Value? updatedAt}) { + Value? updatedAt, + Value? rowid}) { return MembersCompanion( userId: userId ?? this.userId, channelCid: channelCid ?? this.channelCid, @@ -4235,6 +4590,7 @@ class MembersCompanion extends UpdateCompanion { isModerator: isModerator ?? this.isModerator, createdAt: createdAt ?? this.createdAt, updatedAt: updatedAt ?? this.updatedAt, + rowid: rowid ?? this.rowid, ); } @@ -4248,13 +4604,13 @@ class MembersCompanion extends UpdateCompanion { map['channel_cid'] = Variable(channelCid.value); } if (channelRole.present) { - map['channel_role'] = Variable(channelRole.value); + map['channel_role'] = Variable(channelRole.value); } if (inviteAcceptedAt.present) { - map['invite_accepted_at'] = Variable(inviteAcceptedAt.value); + map['invite_accepted_at'] = Variable(inviteAcceptedAt.value); } if (inviteRejectedAt.present) { - map['invite_rejected_at'] = Variable(inviteRejectedAt.value); + map['invite_rejected_at'] = Variable(inviteRejectedAt.value); } if (invited.present) { map['invited'] = Variable(invited.value); @@ -4274,6 +4630,9 @@ class MembersCompanion extends UpdateCompanion { if (updatedAt.present) { map['updated_at'] = Variable(updatedAt.value); } + if (rowid.present) { + map['rowid'] = Variable(rowid.value); + } return map; } @@ -4290,119 +4649,63 @@ class MembersCompanion extends UpdateCompanion { ..write('shadowBanned: $shadowBanned, ') ..write('isModerator: $isModerator, ') ..write('createdAt: $createdAt, ') - ..write('updatedAt: $updatedAt') + ..write('updatedAt: $updatedAt, ') + ..write('rowid: $rowid') ..write(')')) .toString(); } } -class $MembersTable extends Members - with TableInfo<$MembersTable, MemberEntity> { +class $ReadsTable extends Reads with TableInfo<$ReadsTable, ReadEntity> { @override final GeneratedDatabase attachedDatabase; final String? _alias; - $MembersTable(this.attachedDatabase, [this._alias]); - final VerificationMeta _userIdMeta = const VerificationMeta('userId'); + $ReadsTable(this.attachedDatabase, [this._alias]); + static const VerificationMeta _lastReadMeta = + const VerificationMeta('lastRead'); + @override + late final GeneratedColumn lastRead = GeneratedColumn( + 'last_read', aliasedName, false, + type: DriftSqlType.dateTime, requiredDuringInsert: true); + static const VerificationMeta _userIdMeta = const VerificationMeta('userId'); @override - late final GeneratedColumn userId = GeneratedColumn( + late final GeneratedColumn userId = GeneratedColumn( 'user_id', aliasedName, false, - type: const StringType(), requiredDuringInsert: true); - final VerificationMeta _channelCidMeta = const VerificationMeta('channelCid'); + type: DriftSqlType.string, requiredDuringInsert: true); + static const VerificationMeta _channelCidMeta = + const VerificationMeta('channelCid'); @override - late final GeneratedColumn channelCid = GeneratedColumn( + late final GeneratedColumn channelCid = GeneratedColumn( 'channel_cid', aliasedName, false, - type: const StringType(), + type: DriftSqlType.string, requiredDuringInsert: true, $customConstraints: 'REFERENCES channels(cid) ON DELETE CASCADE'); - final VerificationMeta _channelRoleMeta = - const VerificationMeta('channelRole'); - @override - late final GeneratedColumn channelRole = GeneratedColumn( - 'channel_role', aliasedName, true, - type: const StringType(), requiredDuringInsert: false); - final VerificationMeta _inviteAcceptedAtMeta = - const VerificationMeta('inviteAcceptedAt'); - @override - late final GeneratedColumn inviteAcceptedAt = - GeneratedColumn('invite_accepted_at', aliasedName, true, - type: const IntType(), requiredDuringInsert: false); - final VerificationMeta _inviteRejectedAtMeta = - const VerificationMeta('inviteRejectedAt'); - @override - late final GeneratedColumn inviteRejectedAt = - GeneratedColumn('invite_rejected_at', aliasedName, true, - type: const IntType(), requiredDuringInsert: false); - final VerificationMeta _invitedMeta = const VerificationMeta('invited'); - @override - late final GeneratedColumn invited = GeneratedColumn( - 'invited', aliasedName, false, - type: const BoolType(), - requiredDuringInsert: false, - defaultConstraints: 'CHECK (invited IN (0, 1))', - defaultValue: const Constant(false)); - final VerificationMeta _bannedMeta = const VerificationMeta('banned'); - @override - late final GeneratedColumn banned = GeneratedColumn( - 'banned', aliasedName, false, - type: const BoolType(), - requiredDuringInsert: false, - defaultConstraints: 'CHECK (banned IN (0, 1))', - defaultValue: const Constant(false)); - final VerificationMeta _shadowBannedMeta = - const VerificationMeta('shadowBanned'); - @override - late final GeneratedColumn shadowBanned = GeneratedColumn( - 'shadow_banned', aliasedName, false, - type: const BoolType(), - requiredDuringInsert: false, - defaultConstraints: 'CHECK (shadow_banned IN (0, 1))', - defaultValue: const Constant(false)); - final VerificationMeta _isModeratorMeta = - const VerificationMeta('isModerator'); - @override - late final GeneratedColumn isModerator = GeneratedColumn( - 'is_moderator', aliasedName, false, - type: const BoolType(), - requiredDuringInsert: false, - defaultConstraints: 'CHECK (is_moderator IN (0, 1))', - defaultValue: const Constant(false)); - final VerificationMeta _createdAtMeta = const VerificationMeta('createdAt'); - @override - late final GeneratedColumn createdAt = GeneratedColumn( - 'created_at', aliasedName, false, - type: const IntType(), - requiredDuringInsert: false, - defaultValue: currentDateAndTime); - final VerificationMeta _updatedAtMeta = const VerificationMeta('updatedAt'); + static const VerificationMeta _unreadMessagesMeta = + const VerificationMeta('unreadMessages'); @override - late final GeneratedColumn updatedAt = GeneratedColumn( - 'updated_at', aliasedName, false, - type: const IntType(), + late final GeneratedColumn unreadMessages = GeneratedColumn( + 'unread_messages', aliasedName, false, + type: DriftSqlType.int, requiredDuringInsert: false, - defaultValue: currentDateAndTime); + defaultValue: const Constant(0)); @override - List get $columns => [ - userId, - channelCid, - channelRole, - inviteAcceptedAt, - inviteRejectedAt, - invited, - banned, - shadowBanned, - isModerator, - createdAt, - updatedAt - ]; + List get $columns => + [lastRead, userId, channelCid, unreadMessages]; @override - String get aliasedName => _alias ?? 'members'; + String get aliasedName => _alias ?? 'reads'; @override - String get actualTableName => 'members'; + String get actualTableName => 'reads'; @override - VerificationContext validateIntegrity(Insertable instance, + VerificationContext validateIntegrity(Insertable instance, {bool isInserting = false}) { final context = VerificationContext(); final data = instance.toColumns(true); + if (data.containsKey('last_read')) { + context.handle(_lastReadMeta, + lastRead.isAcceptableOrUnknown(data['last_read']!, _lastReadMeta)); + } else if (isInserting) { + context.missing(_lastReadMeta); + } if (data.containsKey('user_id')) { context.handle(_userIdMeta, userId.isAcceptableOrUnknown(data['user_id']!, _userIdMeta)); @@ -4417,51 +4720,11 @@ class $MembersTable extends Members } else if (isInserting) { context.missing(_channelCidMeta); } - if (data.containsKey('channel_role')) { - context.handle( - _channelRoleMeta, - channelRole.isAcceptableOrUnknown( - data['channel_role']!, _channelRoleMeta)); - } - if (data.containsKey('invite_accepted_at')) { - context.handle( - _inviteAcceptedAtMeta, - inviteAcceptedAt.isAcceptableOrUnknown( - data['invite_accepted_at']!, _inviteAcceptedAtMeta)); - } - if (data.containsKey('invite_rejected_at')) { - context.handle( - _inviteRejectedAtMeta, - inviteRejectedAt.isAcceptableOrUnknown( - data['invite_rejected_at']!, _inviteRejectedAtMeta)); - } - if (data.containsKey('invited')) { - context.handle(_invitedMeta, - invited.isAcceptableOrUnknown(data['invited']!, _invitedMeta)); - } - if (data.containsKey('banned')) { - context.handle(_bannedMeta, - banned.isAcceptableOrUnknown(data['banned']!, _bannedMeta)); - } - if (data.containsKey('shadow_banned')) { - context.handle( - _shadowBannedMeta, - shadowBanned.isAcceptableOrUnknown( - data['shadow_banned']!, _shadowBannedMeta)); - } - if (data.containsKey('is_moderator')) { + if (data.containsKey('unread_messages')) { context.handle( - _isModeratorMeta, - isModerator.isAcceptableOrUnknown( - data['is_moderator']!, _isModeratorMeta)); - } - if (data.containsKey('created_at')) { - context.handle(_createdAtMeta, - createdAt.isAcceptableOrUnknown(data['created_at']!, _createdAtMeta)); - } - if (data.containsKey('updated_at')) { - context.handle(_updatedAtMeta, - updatedAt.isAcceptableOrUnknown(data['updated_at']!, _updatedAtMeta)); + _unreadMessagesMeta, + unreadMessages.isAcceptableOrUnknown( + data['unread_messages']!, _unreadMessagesMeta)); } return context; } @@ -4469,14 +4732,23 @@ class $MembersTable extends Members @override Set get $primaryKey => {userId, channelCid}; @override - MemberEntity map(Map data, {String? tablePrefix}) { - return MemberEntity.fromData(data, - prefix: tablePrefix != null ? '$tablePrefix.' : null); + ReadEntity map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return ReadEntity( + lastRead: attachedDatabase.typeMapping + .read(DriftSqlType.dateTime, data['${effectivePrefix}last_read'])!, + userId: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}user_id'])!, + channelCid: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}channel_cid'])!, + unreadMessages: attachedDatabase.typeMapping + .read(DriftSqlType.int, data['${effectivePrefix}unread_messages'])!, + ); } @override - $MembersTable createAlias(String alias) { - return $MembersTable(attachedDatabase, alias); + $ReadsTable createAlias(String alias) { + return $ReadsTable(attachedDatabase, alias); } } @@ -4492,24 +4764,11 @@ class ReadEntity extends DataClass implements Insertable { /// Number of unread messages final int unreadMessages; - ReadEntity( + const ReadEntity( {required this.lastRead, required this.userId, required this.channelCid, required this.unreadMessages}); - factory ReadEntity.fromData(Map data, {String? prefix}) { - final effectivePrefix = prefix ?? ''; - return ReadEntity( - lastRead: const DateTimeType() - .mapFromDatabaseResponse(data['${effectivePrefix}last_read'])!, - userId: const StringType() - .mapFromDatabaseResponse(data['${effectivePrefix}user_id'])!, - channelCid: const StringType() - .mapFromDatabaseResponse(data['${effectivePrefix}channel_cid'])!, - unreadMessages: const IntType() - .mapFromDatabaseResponse(data['${effectivePrefix}unread_messages'])!, - ); - } @override Map toColumns(bool nullToAbsent) { final map = {}; @@ -4580,17 +4839,20 @@ class ReadsCompanion extends UpdateCompanion { final Value userId; final Value channelCid; final Value unreadMessages; + final Value rowid; const ReadsCompanion({ this.lastRead = const Value.absent(), this.userId = const Value.absent(), this.channelCid = const Value.absent(), this.unreadMessages = const Value.absent(), + this.rowid = const Value.absent(), }); ReadsCompanion.insert({ required DateTime lastRead, required String userId, required String channelCid, this.unreadMessages = const Value.absent(), + this.rowid = const Value.absent(), }) : lastRead = Value(lastRead), userId = Value(userId), channelCid = Value(channelCid); @@ -4599,12 +4861,14 @@ class ReadsCompanion extends UpdateCompanion { Expression? userId, Expression? channelCid, Expression? unreadMessages, + Expression? rowid, }) { return RawValuesInsertable({ if (lastRead != null) 'last_read': lastRead, if (userId != null) 'user_id': userId, if (channelCid != null) 'channel_cid': channelCid, if (unreadMessages != null) 'unread_messages': unreadMessages, + if (rowid != null) 'rowid': rowid, }); } @@ -4612,12 +4876,14 @@ class ReadsCompanion extends UpdateCompanion { {Value? lastRead, Value? userId, Value? channelCid, - Value? unreadMessages}) { + Value? unreadMessages, + Value? rowid}) { return ReadsCompanion( lastRead: lastRead ?? this.lastRead, userId: userId ?? this.userId, channelCid: channelCid ?? this.channelCid, unreadMessages: unreadMessages ?? this.unreadMessages, + rowid: rowid ?? this.rowid, ); } @@ -4636,6 +4902,9 @@ class ReadsCompanion extends UpdateCompanion { if (unreadMessages.present) { map['unread_messages'] = Variable(unreadMessages.value); } + if (rowid.present) { + map['rowid'] = Variable(rowid.value); + } return map; } @@ -4645,65 +4914,47 @@ class ReadsCompanion extends UpdateCompanion { ..write('lastRead: $lastRead, ') ..write('userId: $userId, ') ..write('channelCid: $channelCid, ') - ..write('unreadMessages: $unreadMessages') + ..write('unreadMessages: $unreadMessages, ') + ..write('rowid: $rowid') ..write(')')) .toString(); } } -class $ReadsTable extends Reads with TableInfo<$ReadsTable, ReadEntity> { +class $ChannelQueriesTable extends ChannelQueries + with TableInfo<$ChannelQueriesTable, ChannelQueryEntity> { @override final GeneratedDatabase attachedDatabase; final String? _alias; - $ReadsTable(this.attachedDatabase, [this._alias]); - final VerificationMeta _lastReadMeta = const VerificationMeta('lastRead'); - @override - late final GeneratedColumn lastRead = GeneratedColumn( - 'last_read', aliasedName, false, - type: const IntType(), requiredDuringInsert: true); - final VerificationMeta _userIdMeta = const VerificationMeta('userId'); + $ChannelQueriesTable(this.attachedDatabase, [this._alias]); + static const VerificationMeta _queryHashMeta = + const VerificationMeta('queryHash'); @override - late final GeneratedColumn userId = GeneratedColumn( - 'user_id', aliasedName, false, - type: const StringType(), requiredDuringInsert: true); - final VerificationMeta _channelCidMeta = const VerificationMeta('channelCid'); + late final GeneratedColumn queryHash = GeneratedColumn( + 'query_hash', aliasedName, false, + type: DriftSqlType.string, requiredDuringInsert: true); + static const VerificationMeta _channelCidMeta = + const VerificationMeta('channelCid'); @override - late final GeneratedColumn channelCid = GeneratedColumn( + late final GeneratedColumn channelCid = GeneratedColumn( 'channel_cid', aliasedName, false, - type: const StringType(), - requiredDuringInsert: true, - $customConstraints: 'REFERENCES channels(cid) ON DELETE CASCADE'); - final VerificationMeta _unreadMessagesMeta = - const VerificationMeta('unreadMessages'); - @override - late final GeneratedColumn unreadMessages = GeneratedColumn( - 'unread_messages', aliasedName, false, - type: const IntType(), - requiredDuringInsert: false, - defaultValue: const Constant(0)); + type: DriftSqlType.string, requiredDuringInsert: true); @override - List get $columns => - [lastRead, userId, channelCid, unreadMessages]; + List get $columns => [queryHash, channelCid]; @override - String get aliasedName => _alias ?? 'reads'; + String get aliasedName => _alias ?? 'channel_queries'; @override - String get actualTableName => 'reads'; + String get actualTableName => 'channel_queries'; @override - VerificationContext validateIntegrity(Insertable instance, + VerificationContext validateIntegrity(Insertable instance, {bool isInserting = false}) { final context = VerificationContext(); final data = instance.toColumns(true); - if (data.containsKey('last_read')) { - context.handle(_lastReadMeta, - lastRead.isAcceptableOrUnknown(data['last_read']!, _lastReadMeta)); - } else if (isInserting) { - context.missing(_lastReadMeta); - } - if (data.containsKey('user_id')) { - context.handle(_userIdMeta, - userId.isAcceptableOrUnknown(data['user_id']!, _userIdMeta)); + if (data.containsKey('query_hash')) { + context.handle(_queryHashMeta, + queryHash.isAcceptableOrUnknown(data['query_hash']!, _queryHashMeta)); } else if (isInserting) { - context.missing(_userIdMeta); + context.missing(_queryHashMeta); } if (data.containsKey('channel_cid')) { context.handle( @@ -4713,26 +4964,25 @@ class $ReadsTable extends Reads with TableInfo<$ReadsTable, ReadEntity> { } else if (isInserting) { context.missing(_channelCidMeta); } - if (data.containsKey('unread_messages')) { - context.handle( - _unreadMessagesMeta, - unreadMessages.isAcceptableOrUnknown( - data['unread_messages']!, _unreadMessagesMeta)); - } return context; } @override - Set get $primaryKey => {userId, channelCid}; + Set get $primaryKey => {queryHash, channelCid}; @override - ReadEntity map(Map data, {String? tablePrefix}) { - return ReadEntity.fromData(data, - prefix: tablePrefix != null ? '$tablePrefix.' : null); + ChannelQueryEntity map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return ChannelQueryEntity( + queryHash: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}query_hash'])!, + channelCid: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}channel_cid'])!, + ); } @override - $ReadsTable createAlias(String alias) { - return $ReadsTable(attachedDatabase, alias); + $ChannelQueriesTable createAlias(String alias) { + return $ChannelQueriesTable(attachedDatabase, alias); } } @@ -4743,17 +4993,7 @@ class ChannelQueryEntity extends DataClass /// The channel cid of this query final String channelCid; - ChannelQueryEntity({required this.queryHash, required this.channelCid}); - factory ChannelQueryEntity.fromData(Map data, - {String? prefix}) { - final effectivePrefix = prefix ?? ''; - return ChannelQueryEntity( - queryHash: const StringType() - .mapFromDatabaseResponse(data['${effectivePrefix}query_hash'])!, - channelCid: const StringType() - .mapFromDatabaseResponse(data['${effectivePrefix}channel_cid'])!, - ); - } + const ChannelQueryEntity({required this.queryHash, required this.channelCid}); @override Map toColumns(bool nullToAbsent) { final map = {}; @@ -4806,30 +5046,38 @@ class ChannelQueryEntity extends DataClass class ChannelQueriesCompanion extends UpdateCompanion { final Value queryHash; final Value channelCid; + final Value rowid; const ChannelQueriesCompanion({ this.queryHash = const Value.absent(), this.channelCid = const Value.absent(), + this.rowid = const Value.absent(), }); ChannelQueriesCompanion.insert({ required String queryHash, required String channelCid, + this.rowid = const Value.absent(), }) : queryHash = Value(queryHash), channelCid = Value(channelCid); static Insertable custom({ Expression? queryHash, Expression? channelCid, + Expression? rowid, }) { return RawValuesInsertable({ if (queryHash != null) 'query_hash': queryHash, if (channelCid != null) 'channel_cid': channelCid, + if (rowid != null) 'rowid': rowid, }); } ChannelQueriesCompanion copyWith( - {Value? queryHash, Value? channelCid}) { + {Value? queryHash, + Value? channelCid, + Value? rowid}) { return ChannelQueriesCompanion( queryHash: queryHash ?? this.queryHash, channelCid: channelCid ?? this.channelCid, + rowid: rowid ?? this.rowid, ); } @@ -4842,6 +5090,9 @@ class ChannelQueriesCompanion extends UpdateCompanion { if (channelCid.present) { map['channel_cid'] = Variable(channelCid.value); } + if (rowid.present) { + map['rowid'] = Variable(rowid.value); + } return map; } @@ -4849,68 +5100,151 @@ class ChannelQueriesCompanion extends UpdateCompanion { String toString() { return (StringBuffer('ChannelQueriesCompanion(') ..write('queryHash: $queryHash, ') - ..write('channelCid: $channelCid') + ..write('channelCid: $channelCid, ') + ..write('rowid: $rowid') ..write(')')) .toString(); } } -class $ChannelQueriesTable extends ChannelQueries - with TableInfo<$ChannelQueriesTable, ChannelQueryEntity> { +class $ConnectionEventsTable extends ConnectionEvents + with TableInfo<$ConnectionEventsTable, ConnectionEventEntity> { @override final GeneratedDatabase attachedDatabase; final String? _alias; - $ChannelQueriesTable(this.attachedDatabase, [this._alias]); - final VerificationMeta _queryHashMeta = const VerificationMeta('queryHash'); + $ConnectionEventsTable(this.attachedDatabase, [this._alias]); + static const VerificationMeta _idMeta = const VerificationMeta('id'); @override - late final GeneratedColumn queryHash = GeneratedColumn( - 'query_hash', aliasedName, false, - type: const StringType(), requiredDuringInsert: true); - final VerificationMeta _channelCidMeta = const VerificationMeta('channelCid'); + late final GeneratedColumn id = GeneratedColumn( + 'id', aliasedName, false, + type: DriftSqlType.int, requiredDuringInsert: false); + static const VerificationMeta _typeMeta = const VerificationMeta('type'); @override - late final GeneratedColumn channelCid = GeneratedColumn( - 'channel_cid', aliasedName, false, - type: const StringType(), requiredDuringInsert: true); + late final GeneratedColumn type = GeneratedColumn( + 'type', aliasedName, false, + type: DriftSqlType.string, requiredDuringInsert: true); + static const VerificationMeta _ownUserMeta = + const VerificationMeta('ownUser'); + @override + late final GeneratedColumnWithTypeConverter?, String> + ownUser = GeneratedColumn('own_user', aliasedName, true, + type: DriftSqlType.string, requiredDuringInsert: false) + .withConverter?>( + $ConnectionEventsTable.$converterownUsern); + static const VerificationMeta _totalUnreadCountMeta = + const VerificationMeta('totalUnreadCount'); @override - List get $columns => [queryHash, channelCid]; + late final GeneratedColumn totalUnreadCount = GeneratedColumn( + 'total_unread_count', aliasedName, true, + type: DriftSqlType.int, requiredDuringInsert: false); + static const VerificationMeta _unreadChannelsMeta = + const VerificationMeta('unreadChannels'); @override - String get aliasedName => _alias ?? 'channel_queries'; + late final GeneratedColumn unreadChannels = GeneratedColumn( + 'unread_channels', aliasedName, true, + type: DriftSqlType.int, requiredDuringInsert: false); + static const VerificationMeta _lastEventAtMeta = + const VerificationMeta('lastEventAt'); @override - String get actualTableName => 'channel_queries'; + late final GeneratedColumn lastEventAt = GeneratedColumn( + 'last_event_at', aliasedName, true, + type: DriftSqlType.dateTime, requiredDuringInsert: false); + static const VerificationMeta _lastSyncAtMeta = + const VerificationMeta('lastSyncAt'); @override - VerificationContext validateIntegrity(Insertable instance, + late final GeneratedColumn lastSyncAt = GeneratedColumn( + 'last_sync_at', aliasedName, true, + type: DriftSqlType.dateTime, requiredDuringInsert: false); + @override + List get $columns => [ + id, + type, + ownUser, + totalUnreadCount, + unreadChannels, + lastEventAt, + lastSyncAt + ]; + @override + String get aliasedName => _alias ?? 'connection_events'; + @override + String get actualTableName => 'connection_events'; + @override + VerificationContext validateIntegrity( + Insertable instance, {bool isInserting = false}) { final context = VerificationContext(); final data = instance.toColumns(true); - if (data.containsKey('query_hash')) { - context.handle(_queryHashMeta, - queryHash.isAcceptableOrUnknown(data['query_hash']!, _queryHashMeta)); - } else if (isInserting) { - context.missing(_queryHashMeta); + if (data.containsKey('id')) { + context.handle(_idMeta, id.isAcceptableOrUnknown(data['id']!, _idMeta)); } - if (data.containsKey('channel_cid')) { + if (data.containsKey('type')) { context.handle( - _channelCidMeta, - channelCid.isAcceptableOrUnknown( - data['channel_cid']!, _channelCidMeta)); + _typeMeta, type.isAcceptableOrUnknown(data['type']!, _typeMeta)); } else if (isInserting) { - context.missing(_channelCidMeta); + context.missing(_typeMeta); + } + context.handle(_ownUserMeta, const VerificationResult.success()); + if (data.containsKey('total_unread_count')) { + context.handle( + _totalUnreadCountMeta, + totalUnreadCount.isAcceptableOrUnknown( + data['total_unread_count']!, _totalUnreadCountMeta)); + } + if (data.containsKey('unread_channels')) { + context.handle( + _unreadChannelsMeta, + unreadChannels.isAcceptableOrUnknown( + data['unread_channels']!, _unreadChannelsMeta)); + } + if (data.containsKey('last_event_at')) { + context.handle( + _lastEventAtMeta, + lastEventAt.isAcceptableOrUnknown( + data['last_event_at']!, _lastEventAtMeta)); + } + if (data.containsKey('last_sync_at')) { + context.handle( + _lastSyncAtMeta, + lastSyncAt.isAcceptableOrUnknown( + data['last_sync_at']!, _lastSyncAtMeta)); } return context; } @override - Set get $primaryKey => {queryHash, channelCid}; + Set get $primaryKey => {id}; @override - ChannelQueryEntity map(Map data, {String? tablePrefix}) { - return ChannelQueryEntity.fromData(data, - prefix: tablePrefix != null ? '$tablePrefix.' : null); + ConnectionEventEntity map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return ConnectionEventEntity( + id: attachedDatabase.typeMapping + .read(DriftSqlType.int, data['${effectivePrefix}id'])!, + type: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}type'])!, + ownUser: $ConnectionEventsTable.$converterownUsern.fromSql( + attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}own_user'])), + totalUnreadCount: attachedDatabase.typeMapping + .read(DriftSqlType.int, data['${effectivePrefix}total_unread_count']), + unreadChannels: attachedDatabase.typeMapping + .read(DriftSqlType.int, data['${effectivePrefix}unread_channels']), + lastEventAt: attachedDatabase.typeMapping + .read(DriftSqlType.dateTime, data['${effectivePrefix}last_event_at']), + lastSyncAt: attachedDatabase.typeMapping + .read(DriftSqlType.dateTime, data['${effectivePrefix}last_sync_at']), + ); } @override - $ChannelQueriesTable createAlias(String alias) { - return $ChannelQueriesTable(attachedDatabase, alias); + $ConnectionEventsTable createAlias(String alias) { + return $ConnectionEventsTable(attachedDatabase, alias); } + + static TypeConverter, String> $converterownUser = + MapConverter(); + static TypeConverter?, String?> $converterownUsern = + NullAwareTypeConverter.wrap($converterownUser); } class ConnectionEventEntity extends DataClass @@ -4935,7 +5269,7 @@ class ConnectionEventEntity extends DataClass /// DateTime of the last sync final DateTime? lastSyncAt; - ConnectionEventEntity( + const ConnectionEventEntity( {required this.id, required this.type, this.ownUser, @@ -4943,46 +5277,26 @@ class ConnectionEventEntity extends DataClass this.unreadChannels, this.lastEventAt, this.lastSyncAt}); - factory ConnectionEventEntity.fromData(Map data, - {String? prefix}) { - final effectivePrefix = prefix ?? ''; - return ConnectionEventEntity( - id: const IntType() - .mapFromDatabaseResponse(data['${effectivePrefix}id'])!, - type: const StringType() - .mapFromDatabaseResponse(data['${effectivePrefix}type'])!, - ownUser: $ConnectionEventsTable.$converter0.mapToDart(const StringType() - .mapFromDatabaseResponse(data['${effectivePrefix}own_user'])), - totalUnreadCount: const IntType().mapFromDatabaseResponse( - data['${effectivePrefix}total_unread_count']), - unreadChannels: const IntType() - .mapFromDatabaseResponse(data['${effectivePrefix}unread_channels']), - lastEventAt: const DateTimeType() - .mapFromDatabaseResponse(data['${effectivePrefix}last_event_at']), - lastSyncAt: const DateTimeType() - .mapFromDatabaseResponse(data['${effectivePrefix}last_sync_at']), - ); - } @override Map toColumns(bool nullToAbsent) { final map = {}; map['id'] = Variable(id); map['type'] = Variable(type); if (!nullToAbsent || ownUser != null) { - final converter = $ConnectionEventsTable.$converter0; - map['own_user'] = Variable(converter.mapToSql(ownUser)); + final converter = $ConnectionEventsTable.$converterownUsern; + map['own_user'] = Variable(converter.toSql(ownUser)); } if (!nullToAbsent || totalUnreadCount != null) { - map['total_unread_count'] = Variable(totalUnreadCount); + map['total_unread_count'] = Variable(totalUnreadCount); } if (!nullToAbsent || unreadChannels != null) { - map['unread_channels'] = Variable(unreadChannels); + map['unread_channels'] = Variable(unreadChannels); } if (!nullToAbsent || lastEventAt != null) { - map['last_event_at'] = Variable(lastEventAt); + map['last_event_at'] = Variable(lastEventAt); } if (!nullToAbsent || lastSyncAt != null) { - map['last_sync_at'] = Variable(lastSyncAt); + map['last_sync_at'] = Variable(lastSyncAt); } return map; } @@ -5093,11 +5407,11 @@ class ConnectionEventsCompanion extends UpdateCompanion { static Insertable custom({ Expression? id, Expression? type, - Expression?>? ownUser, - Expression? totalUnreadCount, - Expression? unreadChannels, - Expression? lastEventAt, - Expression? lastSyncAt, + Expression? ownUser, + Expression? totalUnreadCount, + Expression? unreadChannels, + Expression? lastEventAt, + Expression? lastSyncAt, }) { return RawValuesInsertable({ if (id != null) 'id': id, @@ -5139,20 +5453,20 @@ class ConnectionEventsCompanion extends UpdateCompanion { map['type'] = Variable(type.value); } if (ownUser.present) { - final converter = $ConnectionEventsTable.$converter0; - map['own_user'] = Variable(converter.mapToSql(ownUser.value)); + final converter = $ConnectionEventsTable.$converterownUsern; + map['own_user'] = Variable(converter.toSql(ownUser.value)); } if (totalUnreadCount.present) { - map['total_unread_count'] = Variable(totalUnreadCount.value); + map['total_unread_count'] = Variable(totalUnreadCount.value); } if (unreadChannels.present) { - map['unread_channels'] = Variable(unreadChannels.value); + map['unread_channels'] = Variable(unreadChannels.value); } if (lastEventAt.present) { - map['last_event_at'] = Variable(lastEventAt.value); + map['last_event_at'] = Variable(lastEventAt.value); } if (lastSyncAt.present) { - map['last_sync_at'] = Variable(lastSyncAt.value); + map['last_sync_at'] = Variable(lastSyncAt.value); } return map; } @@ -5172,130 +5486,8 @@ class ConnectionEventsCompanion extends UpdateCompanion { } } -class $ConnectionEventsTable extends ConnectionEvents - with TableInfo<$ConnectionEventsTable, ConnectionEventEntity> { - @override - final GeneratedDatabase attachedDatabase; - final String? _alias; - $ConnectionEventsTable(this.attachedDatabase, [this._alias]); - final VerificationMeta _idMeta = const VerificationMeta('id'); - @override - late final GeneratedColumn id = GeneratedColumn( - 'id', aliasedName, false, - type: const IntType(), requiredDuringInsert: false); - final VerificationMeta _typeMeta = const VerificationMeta('type'); - @override - late final GeneratedColumn type = GeneratedColumn( - 'type', aliasedName, false, - type: const StringType(), requiredDuringInsert: true); - final VerificationMeta _ownUserMeta = const VerificationMeta('ownUser'); - @override - late final GeneratedColumnWithTypeConverter, String?> - ownUser = GeneratedColumn('own_user', aliasedName, true, - type: const StringType(), requiredDuringInsert: false) - .withConverter>( - $ConnectionEventsTable.$converter0); - final VerificationMeta _totalUnreadCountMeta = - const VerificationMeta('totalUnreadCount'); - @override - late final GeneratedColumn totalUnreadCount = GeneratedColumn( - 'total_unread_count', aliasedName, true, - type: const IntType(), requiredDuringInsert: false); - final VerificationMeta _unreadChannelsMeta = - const VerificationMeta('unreadChannels'); - @override - late final GeneratedColumn unreadChannels = GeneratedColumn( - 'unread_channels', aliasedName, true, - type: const IntType(), requiredDuringInsert: false); - final VerificationMeta _lastEventAtMeta = - const VerificationMeta('lastEventAt'); - @override - late final GeneratedColumn lastEventAt = - GeneratedColumn('last_event_at', aliasedName, true, - type: const IntType(), requiredDuringInsert: false); - final VerificationMeta _lastSyncAtMeta = const VerificationMeta('lastSyncAt'); - @override - late final GeneratedColumn lastSyncAt = GeneratedColumn( - 'last_sync_at', aliasedName, true, - type: const IntType(), requiredDuringInsert: false); - @override - List get $columns => [ - id, - type, - ownUser, - totalUnreadCount, - unreadChannels, - lastEventAt, - lastSyncAt - ]; - @override - String get aliasedName => _alias ?? 'connection_events'; - @override - String get actualTableName => 'connection_events'; - @override - VerificationContext validateIntegrity( - Insertable instance, - {bool isInserting = false}) { - final context = VerificationContext(); - final data = instance.toColumns(true); - if (data.containsKey('id')) { - context.handle(_idMeta, id.isAcceptableOrUnknown(data['id']!, _idMeta)); - } - if (data.containsKey('type')) { - context.handle( - _typeMeta, type.isAcceptableOrUnknown(data['type']!, _typeMeta)); - } else if (isInserting) { - context.missing(_typeMeta); - } - context.handle(_ownUserMeta, const VerificationResult.success()); - if (data.containsKey('total_unread_count')) { - context.handle( - _totalUnreadCountMeta, - totalUnreadCount.isAcceptableOrUnknown( - data['total_unread_count']!, _totalUnreadCountMeta)); - } - if (data.containsKey('unread_channels')) { - context.handle( - _unreadChannelsMeta, - unreadChannels.isAcceptableOrUnknown( - data['unread_channels']!, _unreadChannelsMeta)); - } - if (data.containsKey('last_event_at')) { - context.handle( - _lastEventAtMeta, - lastEventAt.isAcceptableOrUnknown( - data['last_event_at']!, _lastEventAtMeta)); - } - if (data.containsKey('last_sync_at')) { - context.handle( - _lastSyncAtMeta, - lastSyncAt.isAcceptableOrUnknown( - data['last_sync_at']!, _lastSyncAtMeta)); - } - return context; - } - - @override - Set get $primaryKey => {id}; - @override - ConnectionEventEntity map(Map data, {String? tablePrefix}) { - return ConnectionEventEntity.fromData(data, - prefix: tablePrefix != null ? '$tablePrefix.' : null); - } - - @override - $ConnectionEventsTable createAlias(String alias) { - return $ConnectionEventsTable(attachedDatabase, alias); - } - - static TypeConverter, String> $converter0 = - MapConverter(); -} - abstract class _$DriftChatDatabase extends GeneratedDatabase { - _$DriftChatDatabase(QueryExecutor e) - : super(SqlTypeSystem.defaultInstance, e); - _$DriftChatDatabase.connect(DatabaseConnection c) : super.connect(c); + _$DriftChatDatabase(QueryExecutor e) : super(e); late final $ChannelsTable channels = $ChannelsTable(this); late final $MessagesTable messages = $MessagesTable(this); late final $PinnedMessagesTable pinnedMessages = $PinnedMessagesTable(this); @@ -5323,7 +5515,8 @@ abstract class _$DriftChatDatabase extends GeneratedDatabase { late final ConnectionEventDao connectionEventDao = ConnectionEventDao(this as DriftChatDatabase); @override - Iterable get allTables => allSchemaEntities.whereType(); + Iterable> get allTables => + allSchemaEntities.whereType>(); @override List get allSchemaEntities => [ channels, @@ -5337,4 +5530,23 @@ abstract class _$DriftChatDatabase extends GeneratedDatabase { channelQueries, connectionEvents ]; + @override + StreamQueryUpdateRules get streamUpdateRules => const StreamQueryUpdateRules( + [ + WritePropagation( + on: TableUpdateQuery.onTableName('channels', + limitUpdateKind: UpdateKind.delete), + result: [ + TableUpdate('messages', kind: UpdateKind.delete), + ], + ), + WritePropagation( + on: TableUpdateQuery.onTableName('channels', + limitUpdateKind: UpdateKind.delete), + result: [ + TableUpdate('pinned_messages', kind: UpdateKind.delete), + ], + ), + ], + ); } diff --git a/packages/stream_chat_persistence/lib/src/db/shared/native_db.dart b/packages/stream_chat_persistence/lib/src/db/shared/native_db.dart index ca9a98bfe..ca31c3bb2 100644 --- a/packages/stream_chat_persistence/lib/src/db/shared/native_db.dart +++ b/packages/stream_chat_persistence/lib/src/db/shared/native_db.dart @@ -23,7 +23,7 @@ class SharedDB { }) async { final dbName = 'db_$userId'; if (connectionMode == ConnectionMode.background) { - return DriftChatDatabase.connect( + return DriftChatDatabase( userId, DatabaseConnection.delayed(Future(() async { final isolate = await _createMoorIsolate( @@ -34,6 +34,7 @@ class SharedDB { })), ); } + return DriftChatDatabase( userId, LazyDatabase( @@ -68,7 +69,7 @@ class SharedDB { logStatements: request.logStatements, )); final moorIsolate = DriftIsolate.inCurrent( - () => DatabaseConnection.fromExecutor(executor), + () => DatabaseConnection(executor), ); request.sendMoorIsolate.send(moorIsolate); } diff --git a/packages/stream_chat_persistence/lib/src/entity/messages.dart b/packages/stream_chat_persistence/lib/src/entity/messages.dart index f40bd2924..2bbb29e51 100644 --- a/packages/stream_chat_persistence/lib/src/entity/messages.dart +++ b/packages/stream_chat_persistence/lib/src/entity/messages.dart @@ -4,6 +4,8 @@ import 'package:stream_chat_persistence/src/converter/list_converter.dart'; import 'package:stream_chat_persistence/src/converter/map_converter.dart'; import 'package:stream_chat_persistence/src/converter/message_sending_status_converter.dart'; +import 'channels.dart'; + /// Represents a [Messages] table in [MoorChatDatabase]. @DataClassName('MessageEntity') class Messages extends Table { @@ -78,10 +80,11 @@ class Messages extends Table { /// The channel cid of which this message is part of TextColumn get channelCid => - text().customConstraint('REFERENCES channels(cid) ON DELETE CASCADE')(); + text().references(Channels, #cid, onDelete: KeyAction.cascade)(); /// A Map of [messageText] translations. - TextColumn get i18n => text().nullable().map(MapConverter())(); + TextColumn get i18n => + text().nullable().map(NullableMapConverter())(); /// Message custom extraData TextColumn get extraData => text().nullable().map(MapConverter())(); diff --git a/packages/stream_chat_persistence/lib/src/entity/pinned_messages.dart b/packages/stream_chat_persistence/lib/src/entity/pinned_messages.dart index 61672fc86..386c07259 100644 --- a/packages/stream_chat_persistence/lib/src/entity/pinned_messages.dart +++ b/packages/stream_chat_persistence/lib/src/entity/pinned_messages.dart @@ -1,6 +1,5 @@ // coverage:ignore-file import 'package:drift/drift.dart'; - import 'package:stream_chat_persistence/src/entity/messages.dart'; /// Represents a [PinnedMessages] table in [MoorChatDatabase]. diff --git a/packages/stream_chat_persistence/pubspec.yaml b/packages/stream_chat_persistence/pubspec.yaml index 5628688b9..852fe3ae7 100644 --- a/packages/stream_chat_persistence/pubspec.yaml +++ b/packages/stream_chat_persistence/pubspec.yaml @@ -10,7 +10,7 @@ environment: flutter: ">=1.17.0" dependencies: - drift: ^1.7.1 + drift: ^2.7.0 flutter: sdk: flutter logging: ^1.0.1 @@ -23,8 +23,8 @@ dependencies: dev_dependencies: build_runner: ^2.3.3 - dart_code_metrics: ^4.18.0 - drift_dev: ^1.7.1 + dart_code_metrics: ^5.7.2 + drift_dev: ^2.7.0 flutter_test: sdk: flutter mocktail: ^0.3.0 diff --git a/packages/stream_chat_persistence/test/src/converter/list_coverter_test.dart b/packages/stream_chat_persistence/test/src/converter/list_coverter_test.dart index 9cee72b07..ebd1d5204 100644 --- a/packages/stream_chat_persistence/test/src/converter/list_coverter_test.dart +++ b/packages/stream_chat_persistence/test/src/converter/list_coverter_test.dart @@ -4,50 +4,89 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:stream_chat_persistence/src/converter/list_converter.dart'; void main() { - group('mapToDart', () { + group('ListConverter', () { final listConverter = ListConverter(); - test('should return null if nothing is provided', () { - final res = listConverter.mapToDart(null); - expect(res, isNull); - }); + group('fromSql', () { + test('should throw type error if the provided json is not a list', () { + final json = {'test_key': 'testData'}; + expect( + () => listConverter.fromSql(jsonEncode(json)), + throwsA(isA()), + ); + }); - test('should throw type error if the provided json is not a list', () { - final json = {'test_key': 'testData'}; - expect( - () => listConverter.mapToDart(jsonEncode(json)), - throwsA(isA()), - ); - }); + test( + 'should throw type error if the provided json is not a list of String', + () { + final json = [22, 33, 44]; + expect( + () => listConverter.fromSql(jsonEncode(json)), + throwsA(isA()), + ); + }); - test('should throw type error if the provided json is not a list of String', - () { - final json = [22, 33, 44]; - expect( - () => listConverter.mapToDart(jsonEncode(json)), - throwsA(isA()), - ); + test('should return list of String if json data list is provided', () { + final data = ['data1', 'data2', 'data3']; + final res = listConverter.fromSql(jsonEncode(data)); + expect(res.length, data.length); + }); }); - test('should return list of String if json data list is provided', () { - final data = ['data1', 'data2', 'data3']; - final res = listConverter.mapToDart(jsonEncode(data)); - expect(res!.length, data.length); + group('toSql', () { + test('should return json string if data list is provided', () { + final data = ['data1', 'data2', 'data3']; + final res = listConverter.toSql(data); + expect(res, jsonEncode(data)); + }); }); }); - group('mapToSql', () { - final listConverter = ListConverter(); + group('NullableListConverter', () { + final listConverter = NullableListConverter(); + + group('fromSql', () { + test('should return null if nothing is provided', () { + final res = listConverter.fromSql(null); + expect(res, isNull); + }); - test('should return null if nothing is provided', () { - final res = listConverter.mapToSql(null); - expect(res, isNull); + test('should throw type error if the provided json is not a list', () { + final json = {'test_key': 'testData'}; + expect( + () => listConverter.fromSql(jsonEncode(json)), + throwsA(isA()), + ); + }); + + test( + 'should throw type error if the provided json is not a list of String', + () { + final json = [22, 33, 44]; + expect( + () => listConverter.fromSql(jsonEncode(json)), + throwsA(isA()), + ); + }); + + test('should return list of String if json data list is provided', () { + final data = ['data1', 'data2', 'data3']; + final res = listConverter.fromSql(jsonEncode(data)); + expect(res!.length, data.length); + }); }); - test('should return json string if data list is provided', () { - final data = ['data1', 'data2', 'data3']; - final res = listConverter.mapToSql(data); - expect(res, jsonEncode(data)); + group('toSql', () { + test('should return null if nothing is provided', () { + final res = listConverter.toSql(null); + expect(res, isNull); + }); + + test('should return json string if data list is provided', () { + final data = ['data1', 'data2', 'data3']; + final res = listConverter.toSql(data); + expect(res, jsonEncode(data)); + }); }); }); } diff --git a/packages/stream_chat_persistence/test/src/converter/map_converter_test.dart b/packages/stream_chat_persistence/test/src/converter/map_converter_test.dart index c77548926..78faa9369 100644 --- a/packages/stream_chat_persistence/test/src/converter/map_converter_test.dart +++ b/packages/stream_chat_persistence/test/src/converter/map_converter_test.dart @@ -4,61 +4,109 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:stream_chat_persistence/src/converter/map_converter.dart'; void main() { - group('mapToDart', () { + group('MapConverter', () { final mapConverter = MapConverter(); - test('should return null if nothing is provided', () { - final res = mapConverter.mapToDart(null); - expect(res, isNull); - }); + group('fromSql', () { + test('should throw type error if the provided json is not a map', () { + const json = ['testData1', 'testData2', 'testData3']; + expect( + () => mapConverter.fromSql(jsonEncode(json)), + throwsA(isA()), + ); + }); - test('should throw type error if the provided json is not a map', () { - const json = ['testData1', 'testData2', 'testData3']; - expect( - () => mapConverter.mapToDart(jsonEncode(json)), - throwsA(isA()), + test( + 'should throw type error if the provided json is not a ' + 'map of String, String', + () { + const json = {'test_key': 22, 'test_key2': 33, 'test_key3': 44}; + expect( + () => mapConverter.fromSql(jsonEncode(json)), + throwsA(isA()), + ); + }, ); + + test('should return map of String, String if json data is provided', () { + const data = { + 'test_key': 'testValue', + 'test_key2': 'testValue2', + 'test_key3': 'testValue3', + }; + final res = mapConverter.fromSql(jsonEncode(data)); + expect(res, data); + }); + }); + + group('toSql', () { + test('should return json string if data map is provided', () { + const data = { + 'test_key': 'testValue', + 'test_key2': 'testValue2', + 'test_key3': 'testValue3', + }; + final res = mapConverter.toSql(data); + expect(res, jsonEncode(data)); + }); }); + }); - test( - 'should throw type error if the provided json is not a ' - 'map of String, String', - () { - const json = {'test_key': 22, 'test_key2': 33, 'test_key3': 44}; + group('NullableMapConverter', () { + final mapConverter = NullableMapConverter(); + + group('fromSql', () { + test('should return null if nothing is provided', () { + final res = mapConverter.fromSql(null); + expect(res, isNull); + }); + + test('should throw type error if the provided json is not a map', () { + const json = ['testData1', 'testData2', 'testData3']; expect( - () => mapConverter.mapToDart(jsonEncode(json)), + () => mapConverter.fromSql(jsonEncode(json)), throwsA(isA()), ); - }, - ); - - test('should return map of String, String if json data is provided', () { - const data = { - 'test_key': 'testValue', - 'test_key2': 'testValue2', - 'test_key3': 'testValue3', - }; - final res = mapConverter.mapToDart(jsonEncode(data)); - expect(res, data); - }); - }); + }); - group('mapToSql', () { - final mapConverter = MapConverter(); + test( + 'should throw type error if the provided json is not a ' + 'map of String, String', + () { + const json = {'test_key': 22, 'test_key2': 33, 'test_key3': 44}; + expect( + () => mapConverter.fromSql(jsonEncode(json)), + throwsA(isA()), + ); + }, + ); - test('should return null if nothing is provided', () { - final res = mapConverter.mapToSql(null); - expect(res, isNull); + test('should return map of String, String if json data is provided', () { + const data = { + 'test_key': 'testValue', + 'test_key2': 'testValue2', + 'test_key3': 'testValue3', + }; + final res = mapConverter.fromSql(jsonEncode(data)); + expect(res, data); + }); }); - test('should return json string if data map is provided', () { - const data = { - 'test_key': 'testValue', - 'test_key2': 'testValue2', - 'test_key3': 'testValue3', - }; - final res = mapConverter.mapToSql(data); - expect(res, jsonEncode(data)); + group('toSql', () { + test('should return null if nothing is provided', () { + final res = mapConverter.toSql(null); + expect(res, isNull); + }); + + test('should return json string if data map is provided', () { + const data = { + 'test_key': 'testValue', + 'test_key2': 'testValue2', + 'test_key3': 'testValue3', + }; + final res = mapConverter.toSql(data); + expect(res, jsonEncode(data)); + }); }); }); } diff --git a/packages/stream_chat_persistence/test/src/converter/message_sending_status_converter_test.dart b/packages/stream_chat_persistence/test/src/converter/message_sending_status_converter_test.dart index 840f04698..f60374c56 100644 --- a/packages/stream_chat_persistence/test/src/converter/message_sending_status_converter_test.dart +++ b/packages/stream_chat_persistence/test/src/converter/message_sending_status_converter_test.dart @@ -3,30 +3,20 @@ import 'package:stream_chat/stream_chat.dart'; import 'package:stream_chat_persistence/src/converter/message_sending_status_converter.dart'; void main() { - group('mapToDart', () { + group('fromSql', () { final statusConverter = MessageSendingStatusConverter(); - test('should return null if nothing is provided', () { - final res = statusConverter.mapToDart(null); - expect(res, isNull); - }); - test('should return expected status if status code is provided', () { - final res = statusConverter.mapToDart(3); + final res = statusConverter.fromSql(3); expect(res, MessageSendingStatus.updating); }); }); - group('mapToSql', () { + group('toSql', () { final statusConverter = MessageSendingStatusConverter(); - test('should return null if nothing is provided', () { - final res = statusConverter.mapToSql(null); - expect(res, isNull); - }); - test('should return expected code if the status is provided', () { - final res = statusConverter.mapToSql(MessageSendingStatus.updating); + final res = statusConverter.toSql(MessageSendingStatus.updating); expect(res, 3); }); }); diff --git a/packages/stream_chat_persistence/test/src/db/drift_chat_database_test.dart b/packages/stream_chat_persistence/test/src/db/drift_chat_database_test.dart index 441f186de..0528d5c5c 100644 --- a/packages/stream_chat_persistence/test/src/db/drift_chat_database_test.dart +++ b/packages/stream_chat_persistence/test/src/db/drift_chat_database_test.dart @@ -30,7 +30,7 @@ void main() { final isolate = await DriftIsolate.spawn(_backgroundConnection); final connection = DatabaseConnection.delayed(isolate.connect()); - final database = DriftChatDatabase.connect(userId, connection); + final database = DriftChatDatabase(userId, connection); expect(database, isNotNull); expect(database.userId, userId); From 3b0cc225eb761a283e13fe01cc26ba32d8ed1d2b Mon Sep 17 00:00:00 2001 From: Sahil Kumar Date: Thu, 20 Apr 2023 19:05:54 +0530 Subject: [PATCH 102/107] update DriftChatDatabase version. Signed-off-by: xsahil03x --- .../lib/src/dao/member_dao.g.dart | 1 + .../dao/pinned_message_reaction_dao.g.dart | 2 + .../lib/src/dao/reaction_dao.g.dart | 2 + .../lib/src/dao/read_dao.g.dart | 1 + .../lib/src/db/drift_chat_database.dart | 2 +- .../lib/src/db/drift_chat_database.g.dart | 40 +++++++++++++++++-- .../lib/src/entity/members.dart | 3 +- .../src/entity/pinned_message_reactions.dart | 6 +-- .../lib/src/entity/reactions.dart | 3 +- .../lib/src/entity/reads.dart | 3 +- 10 files changed, 52 insertions(+), 11 deletions(-) diff --git a/packages/stream_chat_persistence/lib/src/dao/member_dao.g.dart b/packages/stream_chat_persistence/lib/src/dao/member_dao.g.dart index 0e6ec2da8..bc95ddafd 100644 --- a/packages/stream_chat_persistence/lib/src/dao/member_dao.g.dart +++ b/packages/stream_chat_persistence/lib/src/dao/member_dao.g.dart @@ -4,6 +4,7 @@ part of 'member_dao.dart'; // ignore_for_file: type=lint mixin _$MemberDaoMixin on DatabaseAccessor { + $ChannelsTable get channels => attachedDatabase.channels; $MembersTable get members => attachedDatabase.members; $UsersTable get users => attachedDatabase.users; } diff --git a/packages/stream_chat_persistence/lib/src/dao/pinned_message_reaction_dao.g.dart b/packages/stream_chat_persistence/lib/src/dao/pinned_message_reaction_dao.g.dart index 075044a42..13bb195fe 100644 --- a/packages/stream_chat_persistence/lib/src/dao/pinned_message_reaction_dao.g.dart +++ b/packages/stream_chat_persistence/lib/src/dao/pinned_message_reaction_dao.g.dart @@ -4,6 +4,8 @@ part of 'pinned_message_reaction_dao.dart'; // ignore_for_file: type=lint mixin _$PinnedMessageReactionDaoMixin on DatabaseAccessor { + $ChannelsTable get channels => attachedDatabase.channels; + $PinnedMessagesTable get pinnedMessages => attachedDatabase.pinnedMessages; $PinnedMessageReactionsTable get pinnedMessageReactions => attachedDatabase.pinnedMessageReactions; $UsersTable get users => attachedDatabase.users; diff --git a/packages/stream_chat_persistence/lib/src/dao/reaction_dao.g.dart b/packages/stream_chat_persistence/lib/src/dao/reaction_dao.g.dart index 2fcaeaf71..cdaddc17a 100644 --- a/packages/stream_chat_persistence/lib/src/dao/reaction_dao.g.dart +++ b/packages/stream_chat_persistence/lib/src/dao/reaction_dao.g.dart @@ -4,6 +4,8 @@ part of 'reaction_dao.dart'; // ignore_for_file: type=lint mixin _$ReactionDaoMixin on DatabaseAccessor { + $ChannelsTable get channels => attachedDatabase.channels; + $MessagesTable get messages => attachedDatabase.messages; $ReactionsTable get reactions => attachedDatabase.reactions; $UsersTable get users => attachedDatabase.users; } diff --git a/packages/stream_chat_persistence/lib/src/dao/read_dao.g.dart b/packages/stream_chat_persistence/lib/src/dao/read_dao.g.dart index b176e4d0a..80b1c1cff 100644 --- a/packages/stream_chat_persistence/lib/src/dao/read_dao.g.dart +++ b/packages/stream_chat_persistence/lib/src/dao/read_dao.g.dart @@ -4,6 +4,7 @@ part of 'read_dao.dart'; // ignore_for_file: type=lint mixin _$ReadDaoMixin on DatabaseAccessor { + $ChannelsTable get channels => attachedDatabase.channels; $ReadsTable get reads => attachedDatabase.reads; $UsersTable get users => attachedDatabase.users; } diff --git a/packages/stream_chat_persistence/lib/src/db/drift_chat_database.dart b/packages/stream_chat_persistence/lib/src/db/drift_chat_database.dart index 8098e837f..e186fbb3c 100644 --- a/packages/stream_chat_persistence/lib/src/db/drift_chat_database.dart +++ b/packages/stream_chat_persistence/lib/src/db/drift_chat_database.dart @@ -49,7 +49,7 @@ class DriftChatDatabase extends _$DriftChatDatabase { // you should bump this number whenever you change or add a table definition. @override - int get schemaVersion => 9; + int get schemaVersion => 10; @override MigrationStrategy get migration => MigrationStrategy( diff --git a/packages/stream_chat_persistence/lib/src/db/drift_chat_database.g.dart b/packages/stream_chat_persistence/lib/src/db/drift_chat_database.g.dart index aa56b75ce..6f8b0e318 100644 --- a/packages/stream_chat_persistence/lib/src/db/drift_chat_database.g.dart +++ b/packages/stream_chat_persistence/lib/src/db/drift_chat_database.g.dart @@ -2958,7 +2958,8 @@ class $PinnedMessageReactionsTable extends PinnedMessageReactions 'message_id', aliasedName, false, type: DriftSqlType.string, requiredDuringInsert: true, - $customConstraints: 'REFERENCES pinned_messages(id) ON DELETE CASCADE'); + defaultConstraints: GeneratedColumn.constraintIsAlways( + 'REFERENCES pinned_messages (id) ON DELETE CASCADE')); static const VerificationMeta _typeMeta = const VerificationMeta('type'); @override late final GeneratedColumn type = GeneratedColumn( @@ -3302,7 +3303,8 @@ class $ReactionsTable extends Reactions 'message_id', aliasedName, false, type: DriftSqlType.string, requiredDuringInsert: true, - $customConstraints: 'REFERENCES messages(id) ON DELETE CASCADE'); + defaultConstraints: GeneratedColumn.constraintIsAlways( + 'REFERENCES messages (id) ON DELETE CASCADE')); static const VerificationMeta _typeMeta = const VerificationMeta('type'); @override late final GeneratedColumn type = GeneratedColumn( @@ -4102,7 +4104,8 @@ class $MembersTable extends Members 'channel_cid', aliasedName, false, type: DriftSqlType.string, requiredDuringInsert: true, - $customConstraints: 'REFERENCES channels(cid) ON DELETE CASCADE'); + defaultConstraints: GeneratedColumn.constraintIsAlways( + 'REFERENCES channels (cid) ON DELETE CASCADE')); static const VerificationMeta _channelRoleMeta = const VerificationMeta('channelRole'); @override @@ -4679,7 +4682,8 @@ class $ReadsTable extends Reads with TableInfo<$ReadsTable, ReadEntity> { 'channel_cid', aliasedName, false, type: DriftSqlType.string, requiredDuringInsert: true, - $customConstraints: 'REFERENCES channels(cid) ON DELETE CASCADE'); + defaultConstraints: GeneratedColumn.constraintIsAlways( + 'REFERENCES channels (cid) ON DELETE CASCADE')); static const VerificationMeta _unreadMessagesMeta = const VerificationMeta('unreadMessages'); @override @@ -5547,6 +5551,34 @@ abstract class _$DriftChatDatabase extends GeneratedDatabase { TableUpdate('pinned_messages', kind: UpdateKind.delete), ], ), + WritePropagation( + on: TableUpdateQuery.onTableName('pinned_messages', + limitUpdateKind: UpdateKind.delete), + result: [ + TableUpdate('pinned_message_reactions', kind: UpdateKind.delete), + ], + ), + WritePropagation( + on: TableUpdateQuery.onTableName('messages', + limitUpdateKind: UpdateKind.delete), + result: [ + TableUpdate('reactions', kind: UpdateKind.delete), + ], + ), + WritePropagation( + on: TableUpdateQuery.onTableName('channels', + limitUpdateKind: UpdateKind.delete), + result: [ + TableUpdate('members', kind: UpdateKind.delete), + ], + ), + WritePropagation( + on: TableUpdateQuery.onTableName('channels', + limitUpdateKind: UpdateKind.delete), + result: [ + TableUpdate('reads', kind: UpdateKind.delete), + ], + ), ], ); } diff --git a/packages/stream_chat_persistence/lib/src/entity/members.dart b/packages/stream_chat_persistence/lib/src/entity/members.dart index b4e8181b7..9401d8c58 100644 --- a/packages/stream_chat_persistence/lib/src/entity/members.dart +++ b/packages/stream_chat_persistence/lib/src/entity/members.dart @@ -1,5 +1,6 @@ // coverage:ignore-file import 'package:drift/drift.dart'; +import 'package:stream_chat_persistence/src/entity/channels.dart'; /// Represents a [Members] table in [MoorChatDatabase]. @DataClassName('MemberEntity') @@ -9,7 +10,7 @@ class Members extends Table { /// The channel cid of which this user is part of TextColumn get channelCid => - text().customConstraint('REFERENCES channels(cid) ON DELETE CASCADE')(); + text().references(Channels, #cid, onDelete: KeyAction.cascade)(); /// The role of the user in the channel TextColumn get channelRole => text().nullable()(); diff --git a/packages/stream_chat_persistence/lib/src/entity/pinned_message_reactions.dart b/packages/stream_chat_persistence/lib/src/entity/pinned_message_reactions.dart index 8228ee5f0..e4c9b06e5 100644 --- a/packages/stream_chat_persistence/lib/src/entity/pinned_message_reactions.dart +++ b/packages/stream_chat_persistence/lib/src/entity/pinned_message_reactions.dart @@ -1,6 +1,6 @@ // coverage:ignore-file import 'package:drift/drift.dart'; - +import 'package:stream_chat_persistence/src/entity/pinned_messages.dart'; import 'package:stream_chat_persistence/src/entity/reactions.dart'; /// Represents a [PinnedMessageReactions] table in [MoorChatDatabase]. @@ -8,6 +8,6 @@ import 'package:stream_chat_persistence/src/entity/reactions.dart'; class PinnedMessageReactions extends Reactions { /// The messageId to which the reaction belongs @override - TextColumn get messageId => text() - .customConstraint('REFERENCES pinned_messages(id) ON DELETE CASCADE')(); + TextColumn get messageId => + text().references(PinnedMessages, #id, onDelete: KeyAction.cascade)(); } diff --git a/packages/stream_chat_persistence/lib/src/entity/reactions.dart b/packages/stream_chat_persistence/lib/src/entity/reactions.dart index 712b7b180..5ea81b6d1 100644 --- a/packages/stream_chat_persistence/lib/src/entity/reactions.dart +++ b/packages/stream_chat_persistence/lib/src/entity/reactions.dart @@ -1,6 +1,7 @@ // coverage:ignore-file import 'package:drift/drift.dart'; import 'package:stream_chat_persistence/src/converter/map_converter.dart'; +import 'package:stream_chat_persistence/src/entity/messages.dart'; /// Represents a [Reactions] table in [MoorChatDatabase]. @DataClassName('ReactionEntity') @@ -10,7 +11,7 @@ class Reactions extends Table { /// The messageId to which the reaction belongs TextColumn get messageId => - text().customConstraint('REFERENCES messages(id) ON DELETE CASCADE')(); + text().references(Messages, #id, onDelete: KeyAction.cascade)(); /// The type of the reaction TextColumn get type => text()(); diff --git a/packages/stream_chat_persistence/lib/src/entity/reads.dart b/packages/stream_chat_persistence/lib/src/entity/reads.dart index 18d44934c..63faf754e 100644 --- a/packages/stream_chat_persistence/lib/src/entity/reads.dart +++ b/packages/stream_chat_persistence/lib/src/entity/reads.dart @@ -1,5 +1,6 @@ // coverage:ignore-file import 'package:drift/drift.dart'; +import 'package:stream_chat_persistence/src/entity/channels.dart'; /// Represents a [Reads] table in [MoorChatDatabase]. @DataClassName('ReadEntity') @@ -12,7 +13,7 @@ class Reads extends Table { /// The channel cid of which this read belongs TextColumn get channelCid => - text().customConstraint('REFERENCES channels(cid) ON DELETE CASCADE')(); + text().references(Channels, #cid, onDelete: KeyAction.cascade)(); /// Number of unread messages IntColumn get unreadMessages => integer().withDefault(const Constant(0))(); From 4d43b07df3d875fc6be99c34955856cca3e8007f Mon Sep 17 00:00:00 2001 From: Sahil Kumar Date: Thu, 20 Apr 2023 19:09:28 +0530 Subject: [PATCH 103/107] fix analysis Signed-off-by: xsahil03x --- .../lib/src/entity/messages.dart | 3 +- .../src/converter/list_coverter_test.dart | 34 ++++++++++--------- .../test/src/db/drift_chat_database_test.dart | 2 +- 3 files changed, 20 insertions(+), 19 deletions(-) diff --git a/packages/stream_chat_persistence/lib/src/entity/messages.dart b/packages/stream_chat_persistence/lib/src/entity/messages.dart index 2bbb29e51..fe20013ae 100644 --- a/packages/stream_chat_persistence/lib/src/entity/messages.dart +++ b/packages/stream_chat_persistence/lib/src/entity/messages.dart @@ -3,8 +3,7 @@ import 'package:drift/drift.dart'; import 'package:stream_chat_persistence/src/converter/list_converter.dart'; import 'package:stream_chat_persistence/src/converter/map_converter.dart'; import 'package:stream_chat_persistence/src/converter/message_sending_status_converter.dart'; - -import 'channels.dart'; +import 'package:stream_chat_persistence/src/entity/channels.dart'; /// Represents a [Messages] table in [MoorChatDatabase]. @DataClassName('MessageEntity') diff --git a/packages/stream_chat_persistence/test/src/converter/list_coverter_test.dart b/packages/stream_chat_persistence/test/src/converter/list_coverter_test.dart index ebd1d5204..05c791023 100644 --- a/packages/stream_chat_persistence/test/src/converter/list_coverter_test.dart +++ b/packages/stream_chat_persistence/test/src/converter/list_coverter_test.dart @@ -17,14 +17,15 @@ void main() { }); test( - 'should throw type error if the provided json is not a list of String', - () { - final json = [22, 33, 44]; - expect( - () => listConverter.fromSql(jsonEncode(json)), - throwsA(isA()), - ); - }); + 'should throw type error if the provided json is not a list of String', + () { + final json = [22, 33, 44]; + expect( + () => listConverter.fromSql(jsonEncode(json)), + throwsA(isA()), + ); + }, + ); test('should return list of String if json data list is provided', () { final data = ['data1', 'data2', 'data3']; @@ -60,14 +61,15 @@ void main() { }); test( - 'should throw type error if the provided json is not a list of String', - () { - final json = [22, 33, 44]; - expect( - () => listConverter.fromSql(jsonEncode(json)), - throwsA(isA()), - ); - }); + 'should throw type error if the provided json is not a list of String', + () { + final json = [22, 33, 44]; + expect( + () => listConverter.fromSql(jsonEncode(json)), + throwsA(isA()), + ); + }, + ); test('should return list of String if json data list is provided', () { final data = ['data1', 'data2', 'data3']; diff --git a/packages/stream_chat_persistence/test/src/db/drift_chat_database_test.dart b/packages/stream_chat_persistence/test/src/db/drift_chat_database_test.dart index 0528d5c5c..996c152fb 100644 --- a/packages/stream_chat_persistence/test/src/db/drift_chat_database_test.dart +++ b/packages/stream_chat_persistence/test/src/db/drift_chat_database_test.dart @@ -5,7 +5,7 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:stream_chat_persistence/src/db/drift_chat_database.dart'; DatabaseConnection _backgroundConnection() => - DatabaseConnection.fromExecutor(NativeDatabase.memory()); + DatabaseConnection(NativeDatabase.memory()); void main() { test( From bd87c1dcd552d02189af831d87c077131a27269d Mon Sep 17 00:00:00 2001 From: Sahil Kumar Date: Thu, 20 Apr 2023 19:12:01 +0530 Subject: [PATCH 104/107] update CHANGELOG.md Signed-off-by: xsahil03x --- packages/stream_chat_persistence/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/stream_chat_persistence/CHANGELOG.md b/packages/stream_chat_persistence/CHANGELOG.md index e0dabaa73..1255aa71f 100644 --- a/packages/stream_chat_persistence/CHANGELOG.md +++ b/packages/stream_chat_persistence/CHANGELOG.md @@ -1,5 +1,6 @@ ## Upcoming +- Updated `drift` to `^2.7.0`. - Updated dependencies to resolvable versions. ## 5.1.0 From 75933c4ec3b5e4b0d49fd9e0b995491efde0c255 Mon Sep 17 00:00:00 2001 From: Sahil Kumar Date: Thu, 20 Apr 2023 19:28:30 +0530 Subject: [PATCH 105/107] fix codecov Signed-off-by: xsahil03x --- .../converter/message_sending_status_converter_test.dart | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/stream_chat_persistence/test/src/converter/message_sending_status_converter_test.dart b/packages/stream_chat_persistence/test/src/converter/message_sending_status_converter_test.dart index f60374c56..9961f9171 100644 --- a/packages/stream_chat_persistence/test/src/converter/message_sending_status_converter_test.dart +++ b/packages/stream_chat_persistence/test/src/converter/message_sending_status_converter_test.dart @@ -7,8 +7,8 @@ void main() { final statusConverter = MessageSendingStatusConverter(); test('should return expected status if status code is provided', () { - final res = statusConverter.fromSql(3); - expect(res, MessageSendingStatus.updating); + final res = statusConverter.fromSql(6); + expect(res, MessageSendingStatus.failed_delete); }); }); @@ -16,8 +16,8 @@ void main() { final statusConverter = MessageSendingStatusConverter(); test('should return expected code if the status is provided', () { - final res = statusConverter.toSql(MessageSendingStatus.updating); - expect(res, 3); + final res = statusConverter.toSql(MessageSendingStatus.failed_delete); + expect(res, 6); }); }); } From 9446df7782d13c2d91888b434213b80606ac05ed Mon Sep 17 00:00:00 2001 From: Sahil Kumar Date: Thu, 20 Apr 2023 19:58:59 +0530 Subject: [PATCH 106/107] bump version Signed-off-by: xsahil03x --- packages/stream_chat/CHANGELOG.md | 2 +- packages/stream_chat/lib/version.dart | 2 +- packages/stream_chat/pubspec.yaml | 2 +- packages/stream_chat_flutter/CHANGELOG.md | 2 +- packages/stream_chat_flutter/pubspec.yaml | 4 ++-- packages/stream_chat_flutter_core/CHANGELOG.md | 2 +- packages/stream_chat_flutter_core/pubspec.yaml | 4 ++-- packages/stream_chat_localizations/CHANGELOG.md | 4 ++++ packages/stream_chat_localizations/pubspec.yaml | 4 ++-- packages/stream_chat_persistence/CHANGELOG.md | 2 +- packages/stream_chat_persistence/pubspec.yaml | 4 ++-- 11 files changed, 18 insertions(+), 14 deletions(-) diff --git a/packages/stream_chat/CHANGELOG.md b/packages/stream_chat/CHANGELOG.md index c3d089af4..9a4f508d7 100644 --- a/packages/stream_chat/CHANGELOG.md +++ b/packages/stream_chat/CHANGELOG.md @@ -1,4 +1,4 @@ -## Upcoming +## 6.0.0 🐞 Fixed diff --git a/packages/stream_chat/lib/version.dart b/packages/stream_chat/lib/version.dart index a61f1cc62..19a6844b0 100644 --- a/packages/stream_chat/lib/version.dart +++ b/packages/stream_chat/lib/version.dart @@ -3,4 +3,4 @@ import 'package:stream_chat/src/client/client.dart'; /// Current package version /// Used in [StreamChatClient] to build the `x-stream-client` header // ignore: constant_identifier_names -const PACKAGE_VERSION = '5.3.0'; +const PACKAGE_VERSION = '6.0.0'; diff --git a/packages/stream_chat/pubspec.yaml b/packages/stream_chat/pubspec.yaml index 11571a815..f0bbc763d 100644 --- a/packages/stream_chat/pubspec.yaml +++ b/packages/stream_chat/pubspec.yaml @@ -1,7 +1,7 @@ name: stream_chat homepage: https://getstream.io/ description: The official Dart client for Stream Chat, a service for building chat applications. -version: 5.3.0 +version: 6.0.0 repository: https://github.com/GetStream/stream-chat-flutter issue_tracker: https://github.com/GetStream/stream-chat-flutter/issues diff --git a/packages/stream_chat_flutter/CHANGELOG.md b/packages/stream_chat_flutter/CHANGELOG.md index a0cd21e0c..dea279237 100644 --- a/packages/stream_chat_flutter/CHANGELOG.md +++ b/packages/stream_chat_flutter/CHANGELOG.md @@ -1,4 +1,4 @@ -## Upcoming +## 6.0.0 🐞 Fixed diff --git a/packages/stream_chat_flutter/pubspec.yaml b/packages/stream_chat_flutter/pubspec.yaml index 7ecb494c2..13117f215 100644 --- a/packages/stream_chat_flutter/pubspec.yaml +++ b/packages/stream_chat_flutter/pubspec.yaml @@ -1,7 +1,7 @@ name: stream_chat_flutter homepage: https://github.com/GetStream/stream-chat-flutter description: Stream Chat official Flutter SDK. Build your own chat experience using Dart and Flutter. -version: 5.3.0 +version: 6.0.0 repository: https://github.com/GetStream/stream-chat-flutter issue_tracker: https://github.com/GetStream/stream-chat-flutter/issues @@ -37,7 +37,7 @@ dependencies: rxdart: ^0.27.0 share_plus: ^6.3.0 shimmer: ^2.0.0 - stream_chat_flutter_core: ^5.3.0 + stream_chat_flutter_core: ^6.0.0 synchronized: ^3.0.0 thumblr: ^0.0.4 url_launcher: ^6.1.0 diff --git a/packages/stream_chat_flutter_core/CHANGELOG.md b/packages/stream_chat_flutter_core/CHANGELOG.md index 6f26af264..29b6a27fd 100644 --- a/packages/stream_chat_flutter_core/CHANGELOG.md +++ b/packages/stream_chat_flutter_core/CHANGELOG.md @@ -1,4 +1,4 @@ -## Upcoming +## 6.0.0 - Updated dependencies to resolvable versions. diff --git a/packages/stream_chat_flutter_core/pubspec.yaml b/packages/stream_chat_flutter_core/pubspec.yaml index 6e0868ae0..35a6d0671 100644 --- a/packages/stream_chat_flutter_core/pubspec.yaml +++ b/packages/stream_chat_flutter_core/pubspec.yaml @@ -1,7 +1,7 @@ name: stream_chat_flutter_core homepage: https://github.com/GetStream/stream-chat-flutter description: Stream Chat official Flutter SDK Core. Build your own chat experience using Dart and Flutter. -version: 5.3.0 +version: 6.0.0 repository: https://github.com/GetStream/stream-chat-flutter issue_tracker: https://github.com/GetStream/stream-chat-flutter/issues @@ -17,7 +17,7 @@ dependencies: freezed_annotation: ^2.0.3 meta: ^1.8.0 rxdart: ^0.27.0 - stream_chat: ^5.3.0 + stream_chat: ^6.0.0 dev_dependencies: build_runner: ^2.3.3 diff --git a/packages/stream_chat_localizations/CHANGELOG.md b/packages/stream_chat_localizations/CHANGELOG.md index 20fd8458a..dc42f2448 100644 --- a/packages/stream_chat_localizations/CHANGELOG.md +++ b/packages/stream_chat_localizations/CHANGELOG.md @@ -1,3 +1,7 @@ +## 5.0.0 + +* Updated `stream_chat_flutter` dependency to [`6.0.0`](https://pub.dev/packages/stream_chat_flutter/changelog). + ## 4.1.0 ✅ Added diff --git a/packages/stream_chat_localizations/pubspec.yaml b/packages/stream_chat_localizations/pubspec.yaml index 2fb2bbc39..fc154cff9 100644 --- a/packages/stream_chat_localizations/pubspec.yaml +++ b/packages/stream_chat_localizations/pubspec.yaml @@ -1,6 +1,6 @@ name: stream_chat_localizations description: The Official localizations for Stream Chat Flutter, a service for building chat applications -version: 4.1.0 +version: 5.0.0 homepage: https://github.com/GetStream/stream-chat-flutter repository: https://github.com/GetStream/stream-chat-flutter issue_tracker: https://github.com/GetStream/stream-chat-flutter/issues @@ -14,7 +14,7 @@ dependencies: sdk: flutter flutter_localizations: sdk: flutter - stream_chat_flutter: ^5.3.0 + stream_chat_flutter: ^6.0.0 dev_dependencies: dart_code_metrics: ^5.7.2 diff --git a/packages/stream_chat_persistence/CHANGELOG.md b/packages/stream_chat_persistence/CHANGELOG.md index 1255aa71f..d980edcc8 100644 --- a/packages/stream_chat_persistence/CHANGELOG.md +++ b/packages/stream_chat_persistence/CHANGELOG.md @@ -1,4 +1,4 @@ -## Upcoming +## 6.0.0 - Updated `drift` to `^2.7.0`. - Updated dependencies to resolvable versions. diff --git a/packages/stream_chat_persistence/pubspec.yaml b/packages/stream_chat_persistence/pubspec.yaml index 852fe3ae7..232753961 100644 --- a/packages/stream_chat_persistence/pubspec.yaml +++ b/packages/stream_chat_persistence/pubspec.yaml @@ -1,7 +1,7 @@ name: stream_chat_persistence homepage: https://github.com/GetStream/stream-chat-flutter description: Official Stream Chat Persistence library. Build your own chat experience using Dart and Flutter. -version: 5.1.0 +version: 6.0.0 repository: https://github.com/GetStream/stream-chat-flutter issue_tracker: https://github.com/GetStream/stream-chat-flutter/issues @@ -19,7 +19,7 @@ dependencies: path: ^1.8.2 path_provider: ^2.0.1 sqlite3_flutter_libs: ^0.5.0 - stream_chat: ^5.1.0 + stream_chat: ^6.0.0 dev_dependencies: build_runner: ^2.3.3 From 5c7fc74c5b20804014de63d8cca7878702d1cf38 Mon Sep 17 00:00:00 2001 From: Sahil Kumar Date: Mon, 24 Apr 2023 17:55:59 +0530 Subject: [PATCH 107/107] add required deps. Signed-off-by: xsahil03x --- packages/stream_chat/example/pubspec.yaml | 3 +-- packages/stream_chat_flutter/pubspec.yaml | 3 ++- packages/stream_chat_localizations/pubspec.yaml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/stream_chat/example/pubspec.yaml b/packages/stream_chat/example/pubspec.yaml index 49e226c2b..b8a852eb8 100644 --- a/packages/stream_chat/example/pubspec.yaml +++ b/packages/stream_chat/example/pubspec.yaml @@ -12,8 +12,7 @@ dependencies: cupertino_icons: ^1.0.0 flutter: sdk: flutter - stream_chat: - path: ../ + stream_chat: ^6.0.0 dev_dependencies: flutter_test: diff --git a/packages/stream_chat_flutter/pubspec.yaml b/packages/stream_chat_flutter/pubspec.yaml index 13117f215..5425efb6f 100644 --- a/packages/stream_chat_flutter/pubspec.yaml +++ b/packages/stream_chat_flutter/pubspec.yaml @@ -7,7 +7,7 @@ issue_tracker: https://github.com/GetStream/stream-chat-flutter/issues environment: sdk: ">=2.17.0 <3.0.0" - flutter: ">=1.17.0" + flutter: ">=1.20.0" dependencies: cached_network_image: ^3.0.0 @@ -17,6 +17,7 @@ dependencies: dart_vlc: ^0.4.0 desktop_drop: ^0.4.0 diacritic: ^0.1.3 + dio: ^5.1.1 ezanimation: ^0.6.0 file_picker: ^5.2.4 file_selector: ^0.9.0 diff --git a/packages/stream_chat_localizations/pubspec.yaml b/packages/stream_chat_localizations/pubspec.yaml index fc154cff9..1590d7413 100644 --- a/packages/stream_chat_localizations/pubspec.yaml +++ b/packages/stream_chat_localizations/pubspec.yaml @@ -7,7 +7,7 @@ issue_tracker: https://github.com/GetStream/stream-chat-flutter/issues environment: sdk: '>=2.17.0 <3.0.0' - flutter: ">=1.17.0" + flutter: ">=1.20.0" dependencies: flutter: