mirror of
https://github.com/krille-chan/fluffychat
synced 2024-08-11 07:53:48 +00:00
refactor: Put forwarded text into inputfield instead of sending directly
This commit is contained in:
parent
9dea9fa50a
commit
fec39eb602
3 changed files with 17 additions and 4 deletions
|
@ -283,7 +283,10 @@ abstract class AppRoutes {
|
|||
path: ':roomid',
|
||||
pageBuilder: (context, state) => defaultPageBuilder(
|
||||
context,
|
||||
ChatPage(roomId: state.pathParameters['roomid']!),
|
||||
ChatPage(
|
||||
roomId: state.pathParameters['roomid']!,
|
||||
shareText: state.uri.queryParameters['body'],
|
||||
),
|
||||
),
|
||||
redirect: loggedOutRedirect,
|
||||
routes: [
|
||||
|
|
|
@ -41,10 +41,12 @@ import 'sticker_picker_dialog.dart';
|
|||
|
||||
class ChatPage extends StatelessWidget {
|
||||
final String roomId;
|
||||
final String? shareText;
|
||||
|
||||
const ChatPage({
|
||||
super.key,
|
||||
required this.roomId,
|
||||
this.shareText,
|
||||
});
|
||||
|
||||
@override
|
||||
|
@ -69,6 +71,7 @@ class ChatPage extends StatelessWidget {
|
|||
child: ChatPageWithRoom(
|
||||
key: Key('chat_page_$roomId'),
|
||||
room: room,
|
||||
shareText: shareText,
|
||||
),
|
||||
),
|
||||
if (FluffyThemes.isThreeColumnMode(context) &&
|
||||
|
@ -93,10 +96,12 @@ class ChatPage extends StatelessWidget {
|
|||
|
||||
class ChatPageWithRoom extends StatefulWidget {
|
||||
final Room room;
|
||||
final String? shareText;
|
||||
|
||||
const ChatPageWithRoom({
|
||||
super.key,
|
||||
required this.room,
|
||||
this.shareText,
|
||||
});
|
||||
|
||||
@override
|
||||
|
@ -253,7 +258,7 @@ class ChatController extends State<ChatPageWithRoom>
|
|||
|
||||
void _loadDraft() async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
final draft = prefs.getString('draft_$roomId');
|
||||
final draft = widget.shareText ?? prefs.getString('draft_$roomId');
|
||||
if (draft != null && draft.isNotEmpty) {
|
||||
sendController.text = draft;
|
||||
}
|
||||
|
|
|
@ -124,10 +124,15 @@ class ChatListItem extends StatelessWidget {
|
|||
room: room,
|
||||
),
|
||||
);
|
||||
Matrix.of(context).shareContent = null;
|
||||
} else {
|
||||
room.sendEvent(shareContent);
|
||||
final text = shareContent.tryGet<String>('body');
|
||||
Matrix.of(context).shareContent = null;
|
||||
context.go(
|
||||
'/rooms/${room.id}?body=$text',
|
||||
);
|
||||
return;
|
||||
}
|
||||
Matrix.of(context).shareContent = null;
|
||||
}
|
||||
|
||||
context.go('/rooms/${room.id}');
|
||||
|
|
Loading…
Reference in a new issue