Compare commits
2 Commits
46919dec31
...
a20c2598fc
Author | SHA1 | Date | |
---|---|---|---|
a20c2598fc | |||
2eba871a6d |
@ -532,7 +532,7 @@
|
||||
"aboutScreenContactUsTitle": "联系我们",
|
||||
"aboutScreenLicenseTitle": "许可证",
|
||||
"aboutScreenLicenseContent": "GNU Affero General Public License v3.0",
|
||||
"aboutScreenCopyright": "版权所有 © Solsynth {}",
|
||||
"aboutScreenCopyright": "版权所有 © 索尔辛茨 {}",
|
||||
"aboutScreenMadeWith": "由 Solar Network Team 用 ❤︎️ 制作",
|
||||
"aboutScreenFailedToLoadPackageInfo": "加载包信息失败:{error}",
|
||||
"copiedToClipboard": "已复制到剪贴板",
|
||||
|
@ -221,7 +221,7 @@ class IslandApp extends HookConsumerWidget {
|
||||
Future(() {
|
||||
userNotifier.fetchUser().then((_) {
|
||||
final user = ref.watch(userInfoProvider);
|
||||
if (user.hasValue) {
|
||||
if (user.value != null) {
|
||||
final apiClient = ref.read(apiClientProvider);
|
||||
subscribePushNotification(apiClient);
|
||||
final wsNotifier = ref.read(websocketStateProvider.notifier);
|
||||
|
@ -18,8 +18,13 @@ class UserInfoNotifier extends StateNotifier<AsyncValue<SnAccount?>> {
|
||||
final user = SnAccount.fromJson(response.data);
|
||||
state = AsyncValue.data(user);
|
||||
} catch (error, stackTrace) {
|
||||
log("[UserInfo] Failed to fetch user info: $error");
|
||||
state = AsyncValue.error(error, stackTrace);
|
||||
log(
|
||||
"[UserInfo] Failed to fetch user info...",
|
||||
name: 'UserInfoNotifier',
|
||||
error: error,
|
||||
stackTrace: stackTrace,
|
||||
);
|
||||
state = AsyncValue.data(null);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -59,7 +59,7 @@ class AccountScreen extends HookConsumerWidget {
|
||||
notificationUnreadCountNotifierProvider,
|
||||
);
|
||||
|
||||
if (!user.hasValue || user.value == null) {
|
||||
if (user.value == null || user.value == null) {
|
||||
return _UnauthorizedAccountScreen();
|
||||
}
|
||||
|
||||
@ -367,12 +367,23 @@ class _UnauthorizedAccountScreen extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
const Gap(8),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
context.push('/about');
|
||||
},
|
||||
child: Text('about').tr(),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
context.push('/settings');
|
||||
},
|
||||
child: Text('appSettings').tr(),
|
||||
).center(),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
).center(),
|
||||
|
@ -82,7 +82,7 @@ class EventCalanderScreen extends HookConsumerWidget {
|
||||
),
|
||||
|
||||
// Show user profile if viewing someone else's calendar
|
||||
if (name != 'me' && user.hasValue)
|
||||
if (name != 'me' && user.value != null)
|
||||
AccountNameplate(name: name),
|
||||
],
|
||||
),
|
||||
@ -106,7 +106,7 @@ class EventCalanderScreen extends HookConsumerWidget {
|
||||
).padding(horizontal: 8, vertical: 4),
|
||||
|
||||
// Show user profile if viewing someone else's calendar
|
||||
if (name != 'me' && user.hasValue)
|
||||
if (name != 'me' && user.value != null)
|
||||
AccountNameplate(name: name),
|
||||
Gap(MediaQuery.of(context).padding.bottom + 16),
|
||||
],
|
||||
|
@ -72,6 +72,8 @@ Future<Color?> accountAppbarForcegroundColor(Ref ref, String uname) async {
|
||||
|
||||
@riverpod
|
||||
Future<SnChatRoom?> accountDirectChat(Ref ref, String uname) async {
|
||||
final userInfo = ref.watch(userInfoProvider);
|
||||
if (userInfo.value == null) return null;
|
||||
final account = await ref.watch(accountProvider(uname).future);
|
||||
final apiClient = ref.watch(apiClientProvider);
|
||||
try {
|
||||
@ -87,6 +89,8 @@ Future<SnChatRoom?> accountDirectChat(Ref ref, String uname) async {
|
||||
|
||||
@riverpod
|
||||
Future<SnRelationship?> accountRelationship(Ref ref, String uname) async {
|
||||
final userInfo = ref.watch(userInfoProvider);
|
||||
if (userInfo.value == null) return null;
|
||||
final account = await ref.watch(accountProvider(uname).future);
|
||||
final apiClient = ref.watch(apiClientProvider);
|
||||
try {
|
||||
@ -219,6 +223,8 @@ class AccountProfileScreen extends HookConsumerWidget {
|
||||
];
|
||||
}
|
||||
|
||||
final user = ref.watch(userInfoProvider);
|
||||
|
||||
return account.when(
|
||||
data:
|
||||
(data) => AppScaffold(
|
||||
@ -379,9 +385,13 @@ class AccountProfileScreen extends HookConsumerWidget {
|
||||
).padding(horizontal: 24),
|
||||
),
|
||||
|
||||
if (user.value != null)
|
||||
SliverToBoxAdapter(
|
||||
child: const Divider(height: 1).padding(top: 24, bottom: 12),
|
||||
child: const Divider(
|
||||
height: 1,
|
||||
).padding(top: 24, bottom: 12),
|
||||
),
|
||||
if (user.value != null)
|
||||
SliverToBoxAdapter(
|
||||
child: Row(
|
||||
spacing: 8,
|
||||
|
@ -51,6 +51,9 @@ class _ArticleDetailContent extends HookConsumerWidget {
|
||||
);
|
||||
|
||||
return SingleChildScrollView(
|
||||
child: Center(
|
||||
child: ConstrainedBox(
|
||||
constraints: const BoxConstraints(maxWidth: 560),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
@ -100,6 +103,8 @@ class _ArticleDetailContent extends HookConsumerWidget {
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -126,7 +126,10 @@ class ArticlesScreen extends ConsumerWidget {
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: Text(title ?? 'Articles')),
|
||||
body: CustomScrollView(
|
||||
body: Center(
|
||||
child: ConstrainedBox(
|
||||
constraints: const BoxConstraints(maxWidth: 560),
|
||||
child: CustomScrollView(
|
||||
slivers: [
|
||||
SliverPadding(
|
||||
padding: const EdgeInsets.only(top: 8, left: 8, right: 8),
|
||||
@ -137,6 +140,8 @@ class ArticlesScreen extends ConsumerWidget {
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -307,7 +307,7 @@ class _ActivityListView extends HookConsumerWidget {
|
||||
|
||||
return CustomScrollView(
|
||||
slivers: [
|
||||
if (user.hasValue && !contentOnly)
|
||||
if (user.value != null && !contentOnly)
|
||||
SliverToBoxAdapter(child: CheckInWidget()),
|
||||
SliverList.builder(
|
||||
itemCount: widgetCount,
|
||||
|
@ -59,7 +59,7 @@ class AccountStatusCreationSheet extends HookConsumerWidget {
|
||||
},
|
||||
options: Options(method: initialStatus == null ? 'POST' : 'PATCH'),
|
||||
);
|
||||
if (user.hasValue) {
|
||||
if (user.value != null) {
|
||||
ref.invalidate(accountStatusProvider(user.value!.name));
|
||||
}
|
||||
if (!context.mounted) return;
|
||||
|
@ -350,7 +350,7 @@ class _WebSocketIndicator extends HookConsumerWidget {
|
||||
return AnimatedPositioned(
|
||||
duration: Duration(milliseconds: 1850),
|
||||
top:
|
||||
!user.hasValue ||
|
||||
user.value == null ||
|
||||
user.value == null ||
|
||||
websocketState == WebSocketState.connected()
|
||||
? -indicatorHeight
|
||||
@ -362,7 +362,7 @@ class _WebSocketIndicator extends HookConsumerWidget {
|
||||
child: IgnorePointer(
|
||||
child: Material(
|
||||
elevation:
|
||||
!user.hasValue || websocketState == WebSocketState.connected()
|
||||
user.value == null || websocketState == WebSocketState.connected()
|
||||
? 0
|
||||
: 4,
|
||||
child: AnimatedContainer(
|
||||
|
@ -56,7 +56,7 @@ class PostItem extends HookConsumerWidget {
|
||||
|
||||
final user = ref.watch(userInfoProvider);
|
||||
final isAuthor = useMemoized(
|
||||
() => user.hasValue && user.value?.id == item.publisher.accountId,
|
||||
() => user.value != null && user.value?.id == item.publisher.accountId,
|
||||
[user],
|
||||
);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user