diff --git a/lib/pages/add_story/add_story.dart b/lib/pages/add_story/add_story.dart index 558f32731..117b725d5 100644 --- a/lib/pages/add_story/add_story.dart +++ b/lib/pages/add_story/add_story.dart @@ -170,10 +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) { + 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, @@ -183,10 +194,10 @@ class AddStoryController extends State { originServerTs: DateTime.now(), ).downloadAndDecryptAttachment().then((file) { setState(() { - image = shareFile; + image = file.detectFileType as MatrixImageFile; }); }); - } else if (shareFile is MatrixVideoFile) { + } else if (msgType == MessageTypes.Video) { Event( content: shareContent, type: EventTypes.Message, @@ -196,7 +207,7 @@ class AddStoryController extends State { originServerTs: DateTime.now(), ).downloadAndDecryptAttachment().then((file) { setState(() { - video = shareFile; + video = file.detectFileType as MatrixVideoFile; }); }); }