mirror of
https://github.com/krille-chan/fluffychat
synced 2024-09-10 12:25:11 +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,
|
||||
),
|
||||
);
|
||||
} else {
|
||||
room.sendEvent(shareContent);
|
||||
}
|
||||
Matrix.of(context).shareContent = null;
|
||||
} else {
|
||||
final text = shareContent.tryGet<String>('body');
|
||||
Matrix.of(context).shareContent = null;
|
||||
context.go(
|
||||
'/rooms/${room.id}?body=$text',
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
context.go('/rooms/${room.id}');
|
||||
|
|
Loading…
Reference in a new issue