🐛 Fix upload file in share sheet

This commit is contained in:
LittleSheep 2025-06-29 18:03:18 +08:00
parent c4becb0a05
commit f04285848f
3 changed files with 3 additions and 10 deletions

View File

@ -11,11 +11,6 @@ class UserInfoNotifier extends StateNotifier<AsyncValue<SnAccount?>> {
UserInfoNotifier(this._ref) : super(const AsyncValue.data(null));
Future<String?> getAccessToken() async {
final prefs = _ref.read(sharedPreferencesProvider);
return prefs.getString(kTokenPairStoreKey);
}
Future<void> fetchUser() async {
try {
final client = _ref.read(apiClientProvider);

View File

@ -44,7 +44,7 @@ class AudioCallButton extends HookConsumerWidget {
try {
await apiClient.post('/chat/realtime/$roomId');
if (context.mounted) {
context.push('/chat/call/roomId');
context.push('/chat/call/$roomId');
}
} catch (e) {
showErrorAlert(e);
@ -96,7 +96,7 @@ class AudioCallButton extends HookConsumerWidget {
tooltip: 'Join Ongoing Call',
onPressed: () {
if (context.mounted) {
context.push('/chat/call/roomId');
context.push('/chat/$roomId/call');
}
},
);

View File

@ -11,7 +11,6 @@ import 'package:island/models/file.dart';
import 'package:island/pods/link_preview.dart';
import 'package:island/pods/network.dart';
import 'package:island/pods/config.dart';
import 'package:island/pods/userinfo.dart';
import 'package:island/services/file.dart';
import 'package:mime/mime.dart';
@ -193,7 +192,6 @@ class _ShareSheetState extends ConsumerState<ShareSheet> {
setState(() => _isLoading = true);
try {
final apiClient = ref.read(apiClientProvider);
final userInfo = ref.read(userInfoProvider.notifier);
final serverUrl = ref.read(serverUrlProvider);
String content = _messageController.text.trim();
@ -218,7 +216,7 @@ class _ShareSheetState extends ConsumerState<ShareSheet> {
case ShareContentType.file:
// Upload files to cloud storage
if (widget.content.files?.isNotEmpty == true) {
final token = await userInfo.getAccessToken();
final token = ref.watch(tokenProvider)?.token;
if (token == null) {
throw Exception('Authentication required');
}