add thread offline

This commit is contained in:
Salvatore Giordano
2020-03-12 16:08:42 +01:00
parent 6f696c41ed
commit ce3aae2e38
3 changed files with 9 additions and 8 deletions
+2 -1
View File
@@ -25,12 +25,13 @@ import 'package:stream_chat_flutter/stream_chat_flutter.dart';
/// ///
/// If you now run the simulator you will see a single channel UI. /// If you now run the simulator you will see a single channel UI.
void main() async { void main() async {
WidgetsFlutterBinding.ensureInitialized();
final client = Client( final client = Client(
'b67pax5b2wdq', 'b67pax5b2wdq',
logLevel: Level.INFO, logLevel: Level.INFO,
); );
await client.setUser( client.setUser(
User(id: 'falling-mountain-7'), User(id: 'falling-mountain-7'),
'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoiZmFsbGluZy1tb3VudGFpbi03In0.AKgRXHMQQMz6vJAKszXdY8zMFfsAgkoUeZHlI-Szz9E', 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoiZmFsbGluZy1tb3VudGFpbi03In0.AKgRXHMQQMz6vJAKszXdY8zMFfsAgkoUeZHlI-Szz9E',
); );
+7 -6
View File
@@ -320,11 +320,7 @@ class _MessageListViewState extends State<MessageListView> {
Stream<List<Message>> stream; Stream<List<Message>> stream;
if (widget.parentMessage == null) { if (widget.parentMessage == null) {
stream = streamChannel.channel.state.messagesStream.map((messages) => stream = streamChannel.channel.state.messagesStream;
messages
.where((m) =>
!(m.status == MessageSendingStatus.FAILED && m.isDeleted))
.toList());
} else { } else {
streamChannel.getReplies(widget.parentMessage.id); streamChannel.getReplies(widget.parentMessage.id);
stream = streamChannel.channel.state.threadsStream stream = streamChannel.channel.state.threadsStream
@@ -332,7 +328,12 @@ class _MessageListViewState extends State<MessageListView> {
.map((threads) => threads[widget.parentMessage.id]); .map((threads) => threads[widget.parentMessage.id]);
} }
_streamListener = stream.listen((newMessages) { _streamListener = stream
.map((messages) => messages
.where((m) =>
!(m.status == MessageSendingStatus.FAILED && m.isDeleted))
.toList())
.listen((newMessages) {
newMessages = newMessages.reversed.toList(); newMessages = newMessages.reversed.toList();
if (_messages.isEmpty || if (_messages.isEmpty ||
newMessages.isEmpty || newMessages.isEmpty ||
-1
View File
@@ -909,7 +909,6 @@ class _MessageWidgetState extends State<MessageWidget>
return GestureDetector( return GestureDetector(
child: Image(image: provider), child: Image(image: provider),
onTap: () { onTap: () {
print(attachment.toJson());
Navigator.push(context, MaterialPageRoute(builder: (_) { Navigator.push(context, MaterialPageRoute(builder: (_) {
return FullScreenImage( return FullScreenImage(
url: attachment.imageUrl ?? url: attachment.imageUrl ??