From 9e6a3fd21cedf41a0cf28250053ef7cf4416b686 Mon Sep 17 00:00:00 2001 From: Kelrap Date: Wed, 17 Jul 2024 15:06:46 -0400 Subject: [PATCH 1/3] Saves avatar when creating new space --- lib/pages/new_space/new_space.dart | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/pages/new_space/new_space.dart b/lib/pages/new_space/new_space.dart index d76a016aa..10dbf41f7 100644 --- a/lib/pages/new_space/new_space.dart +++ b/lib/pages/new_space/new_space.dart @@ -198,6 +198,10 @@ class NewSpaceController extends State { space.updateRoomCapacity(capacity); } + if (avatar != null && space != null) { + space.setAvatar(MatrixFile(bytes: avatar, name: 'Avatar')); + } + final Room? room = Matrix.of(context).client.getRoomById(spaceId); if (room == null) { ErrorHandler.logError( From ab7a8e25825e1d9abcc16324f3ab48d2da690865 Mon Sep 17 00:00:00 2001 From: Kelrap Date: Thu, 18 Jul 2024 11:32:59 -0400 Subject: [PATCH 2/3] Changed implementation to use initialstate --- lib/pages/new_space/new_space.dart | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/pages/new_space/new_space.dart b/lib/pages/new_space/new_space.dart index 10dbf41f7..79d8b980d 100644 --- a/lib/pages/new_space/new_space.dart +++ b/lib/pages/new_space/new_space.dart @@ -84,6 +84,15 @@ class NewSpaceController extends State { ), ); + if (avatar != null) { + events.add( + StateEvent( + type: sdk.EventTypes.RoomAvatar, + content: {'url': avatarUrl.toString()}, + ), + ); + } + // commenting out pangea room rules in spaces for now // if (rulesEditorKey.currentState?.rules != null) { // events.add(rulesEditorKey.currentState!.rules.toStateEvent); @@ -198,10 +207,6 @@ class NewSpaceController extends State { space.updateRoomCapacity(capacity); } - if (avatar != null && space != null) { - space.setAvatar(MatrixFile(bytes: avatar, name: 'Avatar')); - } - final Room? room = Matrix.of(context).client.getRoomById(spaceId); if (room == null) { ErrorHandler.logError( From 65b4c1667d207346ea8ac90da983fd380ddc4432 Mon Sep 17 00:00:00 2001 From: ggurdin Date: Thu, 18 Jul 2024 13:40:07 -0400 Subject: [PATCH 3/3] replaced commented out fluffychat code to set avatar in initial state when creating a new space --- lib/pages/new_space/new_space.dart | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/lib/pages/new_space/new_space.dart b/lib/pages/new_space/new_space.dart index 79d8b980d..a9a051063 100644 --- a/lib/pages/new_space/new_space.dart +++ b/lib/pages/new_space/new_space.dart @@ -84,15 +84,6 @@ class NewSpaceController extends State { ), ); - if (avatar != null) { - events.add( - StateEvent( - type: sdk.EventTypes.RoomAvatar, - content: {'url': avatarUrl.toString()}, - ), - ); - } - // commenting out pangea room rules in spaces for now // if (rulesEditorKey.currentState?.rules != null) { // events.add(rulesEditorKey.currentState!.rules.toStateEvent); @@ -182,15 +173,17 @@ class NewSpaceController extends State { addToSpaceKey.currentState!.parent, ) : null, - // initialState: [ - // if (avatar != null) - // sdk.StateEvent( - // type: sdk.EventTypes.RoomAvatar, - // content: {'url': avatarUrl.toString()}, - // ), - // ], - initialState: initialState, // Pangea# + initialState: [ + if (avatar != null) + sdk.StateEvent( + type: sdk.EventTypes.RoomAvatar, + content: {'url': avatarUrl.toString()}, + ), + // #Pangea + ...initialState, + // Pangea# + ], ); // #Pangea final List> futures = [