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',
|
path: ':roomid',
|
||||||
pageBuilder: (context, state) => defaultPageBuilder(
|
pageBuilder: (context, state) => defaultPageBuilder(
|
||||||
context,
|
context,
|
||||||
ChatPage(roomId: state.pathParameters['roomid']!),
|
ChatPage(
|
||||||
|
roomId: state.pathParameters['roomid']!,
|
||||||
|
shareText: state.uri.queryParameters['body'],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
redirect: loggedOutRedirect,
|
redirect: loggedOutRedirect,
|
||||||
routes: [
|
routes: [
|
||||||
|
|
|
@ -41,10 +41,12 @@ import 'sticker_picker_dialog.dart';
|
||||||
|
|
||||||
class ChatPage extends StatelessWidget {
|
class ChatPage extends StatelessWidget {
|
||||||
final String roomId;
|
final String roomId;
|
||||||
|
final String? shareText;
|
||||||
|
|
||||||
const ChatPage({
|
const ChatPage({
|
||||||
super.key,
|
super.key,
|
||||||
required this.roomId,
|
required this.roomId,
|
||||||
|
this.shareText,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -69,6 +71,7 @@ class ChatPage extends StatelessWidget {
|
||||||
child: ChatPageWithRoom(
|
child: ChatPageWithRoom(
|
||||||
key: Key('chat_page_$roomId'),
|
key: Key('chat_page_$roomId'),
|
||||||
room: room,
|
room: room,
|
||||||
|
shareText: shareText,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (FluffyThemes.isThreeColumnMode(context) &&
|
if (FluffyThemes.isThreeColumnMode(context) &&
|
||||||
|
@ -93,10 +96,12 @@ class ChatPage extends StatelessWidget {
|
||||||
|
|
||||||
class ChatPageWithRoom extends StatefulWidget {
|
class ChatPageWithRoom extends StatefulWidget {
|
||||||
final Room room;
|
final Room room;
|
||||||
|
final String? shareText;
|
||||||
|
|
||||||
const ChatPageWithRoom({
|
const ChatPageWithRoom({
|
||||||
super.key,
|
super.key,
|
||||||
required this.room,
|
required this.room,
|
||||||
|
this.shareText,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -253,7 +258,7 @@ class ChatController extends State<ChatPageWithRoom>
|
||||||
|
|
||||||
void _loadDraft() async {
|
void _loadDraft() async {
|
||||||
final prefs = await SharedPreferences.getInstance();
|
final prefs = await SharedPreferences.getInstance();
|
||||||
final draft = prefs.getString('draft_$roomId');
|
final draft = widget.shareText ?? prefs.getString('draft_$roomId');
|
||||||
if (draft != null && draft.isNotEmpty) {
|
if (draft != null && draft.isNotEmpty) {
|
||||||
sendController.text = draft;
|
sendController.text = draft;
|
||||||
}
|
}
|
||||||
|
|
|
@ -124,10 +124,15 @@ class ChatListItem extends StatelessWidget {
|
||||||
room: room,
|
room: room,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
Matrix.of(context).shareContent = null;
|
||||||
} else {
|
} 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}');
|
context.go('/rooms/${room.id}');
|
||||||
|
|
Loading…
Reference in a new issue