From f9617b1b576c5aab7dfbb53ae7c9a741a180171a Mon Sep 17 00:00:00 2001 From: Krille Fear Date: Sun, 6 Feb 2022 17:24:09 +0100 Subject: [PATCH] chore: FIx share stories --- lib/pages/add_story/add_story.dart | 37 +++++++++++++++++++----------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/lib/pages/add_story/add_story.dart b/lib/pages/add_story/add_story.dart index 558f3273..117b725d 100644 --- a/lib/pages/add_story/add_story.dart +++ b/lib/pages/add_story/add_story.dart @@ -170,23 +170,21 @@ class AddStoryController extends State { final shareContent = Matrix.of(context).shareContent; if (shareContent != null) { + controller.text = shareContent.tryGet('body') ?? ''; final shareFile = shareContent.tryGet('file')?.detectFileType; - controller.text = shareContent.tryGet('body') ?? ''; if (shareFile is MatrixImageFile) { - Event( - content: shareContent, - type: EventTypes.Message, - room: Room(id: '!tmproom', client: Matrix.of(context).client), - eventId: 'tmpevent', - senderId: '@tmpsender:example', - originServerTs: DateTime.now(), - ).downloadAndDecryptAttachment().then((file) { - setState(() { - image = shareFile; - }); + setState(() { + image = shareFile; }); } else if (shareFile is MatrixVideoFile) { + setState(() { + video = shareFile; + }); + } + + final msgType = shareContent.tryGet('msgtype'); + if (msgType == MessageTypes.Image) { Event( content: shareContent, type: EventTypes.Message, @@ -196,7 +194,20 @@ class AddStoryController extends State { originServerTs: DateTime.now(), ).downloadAndDecryptAttachment().then((file) { setState(() { - video = shareFile; + image = file.detectFileType as MatrixImageFile; + }); + }); + } else if (msgType == MessageTypes.Video) { + Event( + content: shareContent, + type: EventTypes.Message, + room: Room(id: '!tmproom', client: Matrix.of(context).client), + eventId: 'tmpevent', + senderId: '@tmpsender:example', + originServerTs: DateTime.now(), + ).downloadAndDecryptAttachment().then((file) { + setState(() { + video = file.detectFileType as MatrixVideoFile; }); }); }