⬆️ Upgrade to support latest version of server
This commit is contained in:
@ -24,12 +24,12 @@ class AccountAvatar extends StatelessWidget {
|
||||
if (content is String) {
|
||||
direct = content.startsWith('http');
|
||||
if (!isEmpty) isEmpty = content.isEmpty;
|
||||
if (!isEmpty) isEmpty = content.endsWith('/api/attachments/0');
|
||||
if (!isEmpty) isEmpty = content.endsWith('/attachments/0');
|
||||
}
|
||||
|
||||
final url = direct
|
||||
? content
|
||||
: '${ServiceFinder.services['paperclip']}/api/attachments/$content';
|
||||
: ServiceFinder.buildUrl('files', '/attachments/$content');
|
||||
|
||||
return CircleAvatar(
|
||||
key: Key('a$content'),
|
||||
@ -68,12 +68,12 @@ class AccountProfileImage extends StatelessWidget {
|
||||
if (content is String) {
|
||||
direct = content.startsWith('http');
|
||||
if (!isEmpty) isEmpty = content.isEmpty;
|
||||
if (!isEmpty) isEmpty = content.endsWith('/api/attachments/0');
|
||||
if (!isEmpty) isEmpty = content.endsWith('/attachments/0');
|
||||
}
|
||||
|
||||
final url = direct
|
||||
? content
|
||||
: '${ServiceFinder.services['paperclip']}/api/attachments/$content';
|
||||
: ServiceFinder.buildUrl('files', '/attachments/$content');
|
||||
|
||||
if (PlatformInfo.canCacheImage) {
|
||||
return CachedNetworkImage(
|
||||
|
@ -24,9 +24,9 @@ class _AccountProfilePopupState extends State<AccountProfilePopup> {
|
||||
setState(() => _isBusy = true);
|
||||
|
||||
final client = GetConnect();
|
||||
client.httpClient.baseUrl = ServiceFinder.services['passport'];
|
||||
client.httpClient.baseUrl = ServiceFinder.buildUrl('auth', null);
|
||||
|
||||
final resp = await client.get('/api/users/${widget.account.name}');
|
||||
final resp = await client.get('/users/${widget.account.name}');
|
||||
if (resp.statusCode == 200) {
|
||||
_userinfo = Account.fromJson(resp.body);
|
||||
setState(() => _isBusy = false);
|
||||
|
@ -123,7 +123,7 @@ class _ArticleDeletionDialogState extends State<ArticleDeletionDialog> {
|
||||
final client = auth.configureClient('interactive');
|
||||
|
||||
setState(() => _isBusy = true);
|
||||
final resp = await client.delete('/api/articles/${widget.item.id}');
|
||||
final resp = await client.delete('/articles/${widget.item.id}');
|
||||
setState(() => _isBusy = false);
|
||||
|
||||
if (resp.statusCode != 200) {
|
||||
|
@ -192,8 +192,8 @@ class _ArticleItemState extends State<ArticleItem> {
|
||||
item: widget.item,
|
||||
onReact: (symbol, changes) {
|
||||
setState(() {
|
||||
item.reactionList[symbol] =
|
||||
(item.reactionList[symbol] ?? 0) + changes;
|
||||
item.metric!.reactionList[symbol] =
|
||||
(item.metric!.reactionList[symbol] ?? 0) + changes;
|
||||
});
|
||||
},
|
||||
).paddingOnly(
|
||||
|
@ -30,7 +30,7 @@ class _ArticleQuickActionState extends State<ArticleQuickAction> {
|
||||
useRootNavigator: true,
|
||||
context: context,
|
||||
builder: (context) => PostReactionPopup(
|
||||
reactionList: widget.item.reactionList,
|
||||
reactionList: widget.item.metric!.reactionList,
|
||||
onReact: (key, value) {
|
||||
doWidgetReact(key, value.attitude);
|
||||
},
|
||||
@ -50,7 +50,7 @@ class _ArticleQuickActionState extends State<ArticleQuickAction> {
|
||||
|
||||
setState(() => _isSubmitting = true);
|
||||
|
||||
final resp = await client.post('/api/articles/${widget.item.alias}/react', {
|
||||
final resp = await client.post('/articles/${widget.item.alias}/react', {
|
||||
'symbol': symbol,
|
||||
'attitude': attitude,
|
||||
});
|
||||
@ -71,7 +71,7 @@ class _ArticleQuickActionState extends State<ArticleQuickAction> {
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
if (!widget.isReactable && widget.item.reactionList.isEmpty) {
|
||||
if (!widget.isReactable && widget.item.metric!.reactionList.isEmpty) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
widget.onReact('thumb_up', 0);
|
||||
});
|
||||
@ -94,7 +94,7 @@ class _ArticleQuickActionState extends State<ArticleQuickAction> {
|
||||
shrinkWrap: true,
|
||||
scrollDirection: Axis.horizontal,
|
||||
children: [
|
||||
...widget.item.reactionList.entries.map((x) {
|
||||
...widget.item.metric!.reactionList.entries.map((x) {
|
||||
final info = reactions[x.key];
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(right: 8),
|
||||
|
@ -82,7 +82,8 @@ class _AttachmentItemState extends State<AttachmentItem> {
|
||||
),
|
||||
onPressed: () {
|
||||
launchUrlString(
|
||||
'${ServiceFinder.services['paperclip']}/api/attachments/${widget.item.id}',
|
||||
ServiceFinder.buildUrl(
|
||||
'files', '/attachments/${widget.item.id}'),
|
||||
);
|
||||
},
|
||||
),
|
||||
@ -117,7 +118,7 @@ class _AttachmentItemImage extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Hero(
|
||||
tag: Key('a${item.uuid}p${parentId}'),
|
||||
tag: Key('a${item.uuid}p$parentId'),
|
||||
child: Stack(
|
||||
fit: StackFit.expand,
|
||||
children: [
|
||||
@ -125,7 +126,7 @@ class _AttachmentItemImage extends StatelessWidget {
|
||||
CachedNetworkImage(
|
||||
fit: fit,
|
||||
imageUrl:
|
||||
'${ServiceFinder.services['paperclip']}/api/attachments/${item.id}',
|
||||
ServiceFinder.buildUrl('files', '/attachments/${item.id}'),
|
||||
progressIndicatorBuilder: (context, url, downloadProgress) =>
|
||||
Center(
|
||||
child: CircularProgressIndicator(
|
||||
@ -135,7 +136,7 @@ class _AttachmentItemImage extends StatelessWidget {
|
||||
)
|
||||
else
|
||||
Image.network(
|
||||
'${ServiceFinder.services['paperclip']}/api/attachments/${item.id}',
|
||||
ServiceFinder.buildUrl('files', '/attachments/${item.id}'),
|
||||
fit: fit,
|
||||
loadingBuilder: (BuildContext context, Widget child,
|
||||
ImageChunkEvent? loadingProgress) {
|
||||
@ -205,7 +206,7 @@ class _AttachmentItemVideoState extends State<_AttachmentItemVideo> {
|
||||
super.initState();
|
||||
_player.open(
|
||||
Media(
|
||||
'${ServiceFinder.services['paperclip']}/api/attachments/${widget.item.id}',
|
||||
ServiceFinder.buildUrl('files', '/attachments/${widget.item.id}'),
|
||||
),
|
||||
play: false,
|
||||
);
|
||||
|
@ -32,7 +32,7 @@ class _ChannelDeletionDialogState extends State<ChannelDeletionDialog> {
|
||||
final client = auth.configureClient('messaging');
|
||||
|
||||
final resp = await client
|
||||
.delete('/api/channels/${widget.realm}/${widget.channel.id}');
|
||||
.delete('/channels/${widget.realm}/${widget.channel.id}');
|
||||
if (resp.statusCode != 200) {
|
||||
context.showErrorDialog(resp.bodyString);
|
||||
} else if (Navigator.canPop(context)) {
|
||||
@ -51,7 +51,7 @@ class _ChannelDeletionDialogState extends State<ChannelDeletionDialog> {
|
||||
final client = auth.configureClient('messaging');
|
||||
|
||||
final resp = await client.delete(
|
||||
'/api/channels/${widget.realm}/${widget.channel.alias}/members/me',
|
||||
'/channels/${widget.realm}/${widget.channel.alias}/members/me',
|
||||
);
|
||||
if (resp.statusCode != 200) {
|
||||
context.showErrorDialog(resp.bodyString);
|
||||
|
@ -118,11 +118,7 @@ class _ChannelListWidgetState extends State<ChannelListWidget> {
|
||||
);
|
||||
} else {
|
||||
return ListTile(
|
||||
minTileHeight: item.realmId == null
|
||||
? 48
|
||||
: widget.isDense
|
||||
? 24
|
||||
: null,
|
||||
minTileHeight: widget.isDense ? 48 : null,
|
||||
leading: CircleAvatar(
|
||||
backgroundColor:
|
||||
item.realmId == null ? Colors.indigo : Colors.transparent,
|
||||
|
@ -43,7 +43,7 @@ class _ChannelMemberListPopupState extends State<ChannelMemberListPopup> {
|
||||
final client = ServiceFinder.configureClient('messaging');
|
||||
|
||||
final resp = await client
|
||||
.get('/api/channels/${widget.realm}/${widget.channel.alias}/members');
|
||||
.get('/channels/${widget.realm}/${widget.channel.alias}/members');
|
||||
if (resp.statusCode == 200) {
|
||||
setState(() {
|
||||
_members = resp.body
|
||||
@ -79,7 +79,7 @@ class _ChannelMemberListPopupState extends State<ChannelMemberListPopup> {
|
||||
final client = auth.configureClient('messaging');
|
||||
|
||||
final resp = await client.post(
|
||||
'/api/channels/${widget.realm}/${widget.channel.alias}/members',
|
||||
'/channels/${widget.realm}/${widget.channel.alias}/members',
|
||||
{'target': username},
|
||||
);
|
||||
if (resp.statusCode == 200) {
|
||||
@ -100,7 +100,7 @@ class _ChannelMemberListPopupState extends State<ChannelMemberListPopup> {
|
||||
final client = auth.configureClient('messaging');
|
||||
|
||||
final resp = await client.request(
|
||||
'/api/channels/${widget.realm}/${widget.channel.alias}/members',
|
||||
'/channels/${widget.realm}/${widget.channel.alias}/members',
|
||||
'delete',
|
||||
body: {'target': item.account.name},
|
||||
);
|
||||
|
@ -41,7 +41,7 @@ class _ChatCallButtonState extends State<ChatCallButton> {
|
||||
? widget.realm?.alias
|
||||
: 'global';
|
||||
final resp = await client.post(
|
||||
'/api/channels/$scope/${widget.channel.alias}/calls',
|
||||
'/channels/$scope/${widget.channel.alias}/calls',
|
||||
{},
|
||||
);
|
||||
if (resp.statusCode == 200) {
|
||||
@ -65,7 +65,7 @@ class _ChatCallButtonState extends State<ChatCallButton> {
|
||||
? widget.realm?.alias
|
||||
: 'global';
|
||||
final resp = await client
|
||||
.delete('/api/channels/$scope/${widget.channel.alias}/calls/ongoing');
|
||||
.delete('/channels/$scope/${widget.channel.alias}/calls/ongoing');
|
||||
if (resp.statusCode == 200) {
|
||||
if (widget.onEnded != null) widget.onEnded!();
|
||||
} else {
|
||||
|
@ -38,7 +38,7 @@ class _ChatEventDeletionDialogState extends State<ChatEventDeletionDialog> {
|
||||
? widget.realm?.alias
|
||||
: 'global';
|
||||
final resp = await client.delete(
|
||||
'/api/channels/$scope/${widget.channel.alias}/messages/${widget.item.id}',
|
||||
'/channels/$scope/${widget.channel.alias}/messages/${widget.item.id}',
|
||||
);
|
||||
if (resp.statusCode == 200) {
|
||||
Navigator.pop(context, resp.body);
|
||||
|
@ -114,12 +114,12 @@ class _ChatMessageInputState extends State<ChatMessageInput> {
|
||||
Response resp;
|
||||
if (_editTo != null) {
|
||||
resp = await client.put(
|
||||
'/api/channels/${widget.realm}/${widget.channel.alias}/messages/${_editTo!.id}',
|
||||
'/channels/${widget.realm}/${widget.channel.alias}/messages/${_editTo!.id}',
|
||||
payload,
|
||||
);
|
||||
} else {
|
||||
resp = await client.post(
|
||||
'/api/channels/${widget.realm}/${widget.channel.alias}/messages',
|
||||
'/channels/${widget.realm}/${widget.channel.alias}/messages',
|
||||
payload,
|
||||
);
|
||||
}
|
||||
|
@ -1,9 +1,8 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_animate/flutter_animate.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:solian/providers/account.dart';
|
||||
import 'package:solian/providers/websocket.dart';
|
||||
import 'package:solian/providers/auth.dart';
|
||||
import 'package:solian/providers/chat.dart';
|
||||
|
||||
class BackgroundStateWidget extends StatelessWidget {
|
||||
const BackgroundStateWidget({super.key});
|
||||
@ -11,14 +10,11 @@ class BackgroundStateWidget extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final AuthProvider auth = Get.find();
|
||||
final AccountProvider account = Get.find();
|
||||
final ChatProvider chat = Get.find();
|
||||
final WebSocketProvider ws = Get.find();
|
||||
|
||||
return Obx(() {
|
||||
final disconnected =
|
||||
chat.isConnected.isFalse || account.isConnected.isFalse;
|
||||
final connecting =
|
||||
chat.isConnecting.isTrue || account.isConnecting.isTrue;
|
||||
final disconnected = ws.isConnected.isFalse;
|
||||
final connecting = ws.isConnecting.isTrue;
|
||||
|
||||
return Row(children: [
|
||||
if (disconnected && !connecting)
|
||||
@ -30,10 +26,8 @@ class BackgroundStateWidget extends StatelessWidget {
|
||||
}
|
||||
return IconButton(
|
||||
tooltip: [
|
||||
if (account.isConnected.isFalse)
|
||||
'Lost Connection with Passport Server...',
|
||||
if (chat.isConnected.isFalse)
|
||||
'Lost Connection with Messaging Server...',
|
||||
if (ws.isConnected.isFalse)
|
||||
'Lost Connection with Solar Network...',
|
||||
].join('\n'),
|
||||
icon: const Icon(Icons.wifi_off)
|
||||
.animate(onPlay: (c) => c.repeat())
|
||||
@ -41,8 +35,7 @@ class BackgroundStateWidget extends StatelessWidget {
|
||||
.then()
|
||||
.fadeOut(duration: 800.ms),
|
||||
onPressed: () {
|
||||
if (account.isConnected.isFalse) account.connect();
|
||||
if (chat.isConnected.isFalse) chat.connect();
|
||||
if (ws.isConnected.isFalse) ws.connect();
|
||||
},
|
||||
);
|
||||
},
|
||||
@ -56,10 +49,8 @@ class BackgroundStateWidget extends StatelessWidget {
|
||||
}
|
||||
return IconButton(
|
||||
tooltip: [
|
||||
if (account.isConnecting.isTrue)
|
||||
'Waiting Passport Server Response...',
|
||||
if (chat.isConnecting.isTrue)
|
||||
'Waiting Messaging Server Response...',
|
||||
if (ws.isConnecting.isTrue)
|
||||
'Waiting Solar Network Connection...',
|
||||
].join('\n'),
|
||||
icon: const Icon(Icons.sync)
|
||||
.animate(onPlay: (c) => c.repeat())
|
||||
|
@ -158,7 +158,7 @@ class _PostDeletionDialogState extends State<PostDeletionDialog> {
|
||||
final client = auth.configureClient('interactive');
|
||||
|
||||
setState(() => _isBusy = true);
|
||||
final resp = await client.delete('/api/posts/${widget.item.id}');
|
||||
final resp = await client.delete('/posts/${widget.item.id}');
|
||||
setState(() => _isBusy = false);
|
||||
|
||||
if (resp.statusCode != 200) {
|
||||
|
@ -304,8 +304,8 @@ class _PostItemState extends State<PostItem> {
|
||||
item: widget.item,
|
||||
onReact: (symbol, changes) {
|
||||
setState(() {
|
||||
item.reactionList[symbol] =
|
||||
(item.reactionList[symbol] ?? 0) + changes;
|
||||
item.metric!.reactionList[symbol] =
|
||||
(item.metric!.reactionList[symbol] ?? 0) + changes;
|
||||
});
|
||||
},
|
||||
).paddingOnly(
|
||||
|
@ -33,7 +33,7 @@ class _PostQuickActionState extends State<PostQuickAction> {
|
||||
useRootNavigator: true,
|
||||
context: context,
|
||||
builder: (context) => PostReactionPopup(
|
||||
reactionList: widget.item.reactionList,
|
||||
reactionList: widget.item.metric!.reactionList,
|
||||
onReact: (key, value) {
|
||||
doWidgetReact(key, value.attitude);
|
||||
},
|
||||
@ -53,7 +53,7 @@ class _PostQuickActionState extends State<PostQuickAction> {
|
||||
|
||||
setState(() => _isSubmitting = true);
|
||||
|
||||
final resp = await client.post('/api/posts/${widget.item.alias}/react', {
|
||||
final resp = await client.post('/posts/${widget.item.alias}/react', {
|
||||
'symbol': symbol,
|
||||
'attitude': attitude,
|
||||
});
|
||||
@ -74,7 +74,7 @@ class _PostQuickActionState extends State<PostQuickAction> {
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
if (!widget.isReactable && widget.item.reactionList.isEmpty) {
|
||||
if (!widget.isReactable && widget.item.metric!.reactionList.isEmpty) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
widget.onReact('thumb_up', 0);
|
||||
});
|
||||
@ -95,7 +95,7 @@ class _PostQuickActionState extends State<PostQuickAction> {
|
||||
if (widget.isReactable && widget.isShowReply)
|
||||
ActionChip(
|
||||
avatar: const Icon(Icons.comment),
|
||||
label: Text(widget.item.replyCount.toString()),
|
||||
label: Text(widget.item.metric!.replyCount.toString()),
|
||||
visualDensity: density,
|
||||
onPressed: () {
|
||||
showModalBottomSheet(
|
||||
@ -119,7 +119,7 @@ class _PostQuickActionState extends State<PostQuickAction> {
|
||||
shrinkWrap: true,
|
||||
scrollDirection: Axis.horizontal,
|
||||
children: [
|
||||
...widget.item.reactionList.entries.map((x) {
|
||||
...widget.item.metric!.reactionList.entries.map((x) {
|
||||
final info = reactions[x.key];
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(right: 8),
|
||||
|
@ -27,9 +27,9 @@ class _RealmDeletionDialogState extends State<RealmDeletionDialog> {
|
||||
|
||||
setState(() => _isBusy = true);
|
||||
|
||||
final client = auth.configureClient('passport');
|
||||
final client = auth.configureClient('auth');
|
||||
|
||||
final resp = await client.delete('/api/realms/${widget.realm.id}');
|
||||
final resp = await client.delete('/realms/${widget.realm.id}');
|
||||
if (resp.statusCode != 200) {
|
||||
context.showErrorDialog(resp.bodyString);
|
||||
} else if (Navigator.canPop(context)) {
|
||||
@ -45,10 +45,10 @@ class _RealmDeletionDialogState extends State<RealmDeletionDialog> {
|
||||
|
||||
setState(() => _isBusy = true);
|
||||
|
||||
final client = auth.configureClient('passport');
|
||||
final client = auth.configureClient('auth');
|
||||
|
||||
final resp =
|
||||
await client.delete('/api/realms/${widget.realm.id}/members/me');
|
||||
await client.delete('/realms/${widget.realm.id}/members/me');
|
||||
if (resp.statusCode != 200) {
|
||||
context.showErrorDialog(resp.bodyString);
|
||||
} else if (Navigator.canPop(context)) {
|
||||
|
@ -38,9 +38,9 @@ class _RealmMemberListPopupState extends State<RealmMemberListPopup> {
|
||||
void getMembers() async {
|
||||
setState(() => _isBusy = true);
|
||||
|
||||
final client = ServiceFinder.configureClient('passport');
|
||||
final client = ServiceFinder.configureClient('auth');
|
||||
|
||||
final resp = await client.get('/api/realms/${widget.realm.alias}/members');
|
||||
final resp = await client.get('/realms/${widget.realm.alias}/members');
|
||||
if (resp.statusCode == 200) {
|
||||
setState(() {
|
||||
_members = resp.body
|
||||
@ -73,10 +73,10 @@ class _RealmMemberListPopupState extends State<RealmMemberListPopup> {
|
||||
|
||||
setState(() => _isBusy = true);
|
||||
|
||||
final client = auth.configureClient('passport');
|
||||
final client = auth.configureClient('auth');
|
||||
|
||||
final resp = await client.post(
|
||||
'/api/realms/${widget.realm.alias}/members',
|
||||
'/realms/${widget.realm.alias}/members',
|
||||
{'target': username},
|
||||
);
|
||||
if (resp.statusCode == 200) {
|
||||
@ -94,10 +94,10 @@ class _RealmMemberListPopupState extends State<RealmMemberListPopup> {
|
||||
|
||||
setState(() => _isBusy = true);
|
||||
|
||||
final client = auth.configureClient('passport');
|
||||
final client = auth.configureClient('auth');
|
||||
|
||||
final resp = await client.request(
|
||||
'/api/realms/${widget.realm.alias}/members',
|
||||
'/realms/${widget.realm.alias}/members',
|
||||
'delete',
|
||||
body: {'target': item.account.name},
|
||||
);
|
||||
|
Reference in New Issue
Block a user