✨ Realm basis
This commit is contained in:
@ -13,9 +13,16 @@ import 'package:solian/widgets/exts.dart';
|
||||
class ChannelCallAction extends StatefulWidget {
|
||||
final Call? call;
|
||||
final Channel channel;
|
||||
final String realm;
|
||||
final Function onUpdate;
|
||||
|
||||
const ChannelCallAction({super.key, this.call, required this.channel, required this.onUpdate});
|
||||
const ChannelCallAction({
|
||||
super.key,
|
||||
this.call,
|
||||
required this.channel,
|
||||
required this.onUpdate,
|
||||
this.realm = 'global',
|
||||
});
|
||||
|
||||
@override
|
||||
State<ChannelCallAction> createState() => _ChannelCallActionState();
|
||||
@ -33,7 +40,7 @@ class _ChannelCallActionState extends State<ChannelCallAction> {
|
||||
return;
|
||||
}
|
||||
|
||||
var uri = getRequestUri('messaging', '/api/channels/global/${widget.channel.alias}/calls');
|
||||
var uri = getRequestUri('messaging', '/api/channels/${widget.realm}/${widget.channel.alias}/calls');
|
||||
|
||||
var res = await auth.client!.post(uri);
|
||||
if (res.statusCode != 200) {
|
||||
@ -54,7 +61,7 @@ class _ChannelCallActionState extends State<ChannelCallAction> {
|
||||
return;
|
||||
}
|
||||
|
||||
var uri = getRequestUri('messaging', '/api/channels/global/${widget.channel.alias}/calls/ongoing');
|
||||
var uri = getRequestUri('messaging', '/api/channels/${widget.realm}/${widget.channel.alias}/calls/ongoing');
|
||||
|
||||
var res = await auth.client!.delete(uri);
|
||||
if (res.statusCode != 200) {
|
||||
@ -90,17 +97,26 @@ class _ChannelCallActionState extends State<ChannelCallAction> {
|
||||
class ChannelManageAction extends StatelessWidget {
|
||||
final Channel channel;
|
||||
final Function onUpdate;
|
||||
final String realm;
|
||||
|
||||
const ChannelManageAction({super.key, required this.channel, required this.onUpdate});
|
||||
const ChannelManageAction({
|
||||
super.key,
|
||||
required this.channel,
|
||||
required this.onUpdate,
|
||||
this.realm = 'global',
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return IconButton(
|
||||
onPressed: () async {
|
||||
final result = await SolianRouter.router.pushNamed(
|
||||
'chat.channel.manage',
|
||||
realm == 'global' ? 'chat.channel.manage' : 'realms.chat.channel.manage',
|
||||
extra: channel,
|
||||
pathParameters: {'channel': channel.alias},
|
||||
pathParameters: {
|
||||
'channel': channel.alias,
|
||||
...(realm == 'global' ? {} : {'realm': realm}),
|
||||
},
|
||||
);
|
||||
switch (result) {
|
||||
case 'disposed':
|
||||
|
@ -10,10 +10,15 @@ import 'package:solian/widgets/exts.dart';
|
||||
|
||||
class ChannelDeletion extends StatefulWidget {
|
||||
final Channel channel;
|
||||
final String realm;
|
||||
final bool isOwned;
|
||||
|
||||
const ChannelDeletion(
|
||||
{super.key, required this.channel, required this.isOwned});
|
||||
const ChannelDeletion({
|
||||
super.key,
|
||||
required this.channel,
|
||||
required this.realm,
|
||||
required this.isOwned,
|
||||
});
|
||||
|
||||
@override
|
||||
State<ChannelDeletion> createState() => _ChannelDeletionState();
|
||||
@ -32,7 +37,7 @@ class _ChannelDeletionState extends State<ChannelDeletion> {
|
||||
}
|
||||
|
||||
var res = await auth.client!.delete(
|
||||
getRequestUri('messaging', '/api/channels/global/${widget.channel.id}'),
|
||||
getRequestUri('messaging', '/api/channels/${widget.realm}/${widget.channel.id}'),
|
||||
);
|
||||
if (res.statusCode != 200) {
|
||||
var message = utf8.decode(res.bodyBytes);
|
||||
@ -53,8 +58,8 @@ class _ChannelDeletionState extends State<ChannelDeletion> {
|
||||
return;
|
||||
}
|
||||
|
||||
var res = await auth.client!.post(
|
||||
getRequestUri('messaging', '/api/channels/global/${widget.channel.alias}/leave'),
|
||||
var res = await auth.client!.delete(
|
||||
getRequestUri('messaging', '/api/channels/${widget.realm}/${widget.channel.alias}/me'),
|
||||
);
|
||||
if (res.statusCode != 200) {
|
||||
var message = utf8.decode(res.bodyBytes);
|
||||
|
@ -4,8 +4,9 @@ import 'package:solian/router.dart';
|
||||
|
||||
class ChatNewAction extends StatelessWidget {
|
||||
final Function onUpdate;
|
||||
final String? realm;
|
||||
|
||||
const ChatNewAction({super.key, required this.onUpdate});
|
||||
const ChatNewAction({super.key, required this.onUpdate, this.realm});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@ -29,7 +30,10 @@ class ChatNewAction extends StatelessWidget {
|
||||
leading: const Icon(Icons.add),
|
||||
title: Text(AppLocalizations.of(context)!.chatNewCreate),
|
||||
onTap: () {
|
||||
SolianRouter.router.pushNamed('chat.channel.editor').then((did) {
|
||||
SolianRouter.router.pushNamed(
|
||||
'chat.channel.editor',
|
||||
queryParameters: {'realm': realm},
|
||||
).then((did) {
|
||||
if (did == true) {
|
||||
onUpdate();
|
||||
if (Navigator.canPop(context)) {
|
||||
|
@ -14,11 +14,19 @@ import 'package:badges/badges.dart' as badge;
|
||||
|
||||
class ChatMessageEditor extends StatefulWidget {
|
||||
final String channel;
|
||||
final String realm;
|
||||
final Message? editing;
|
||||
final Message? replying;
|
||||
final Function? onReset;
|
||||
|
||||
const ChatMessageEditor({super.key, required this.channel, this.editing, this.replying, this.onReset});
|
||||
const ChatMessageEditor({
|
||||
super.key,
|
||||
required this.channel,
|
||||
this.realm = 'global',
|
||||
this.editing,
|
||||
this.replying,
|
||||
this.onReset,
|
||||
});
|
||||
|
||||
@override
|
||||
State<ChatMessageEditor> createState() => _ChatMessageEditorState();
|
||||
@ -53,8 +61,8 @@ class _ChatMessageEditorState extends State<ChatMessageEditor> {
|
||||
if (!await auth.isAuthorized()) return;
|
||||
|
||||
final uri = widget.editing == null
|
||||
? getRequestUri('messaging', '/api/channels/global/${widget.channel}/messages')
|
||||
: getRequestUri('messaging', '/api/channels/global/${widget.channel}/messages/${widget.editing!.id}');
|
||||
? getRequestUri('messaging', '/api/channels/${widget.realm}/${widget.channel}/messages')
|
||||
: getRequestUri('messaging', '/api/channels/${widget.realm}/${widget.channel}/messages/${widget.editing!.id}');
|
||||
|
||||
final req = Request(widget.editing == null ? 'POST' : 'PUT', uri);
|
||||
req.headers['Content-Type'] = 'application/json';
|
||||
|
Reference in New Issue
Block a user