🐛 Dozens of bug fixes

This commit is contained in:
2025-07-23 02:33:28 +08:00
parent 19f0e11384
commit 170ea4f2c0
6 changed files with 65 additions and 60 deletions

View File

@@ -4,28 +4,27 @@ import 'package:island/models/webfeed.dart';
import 'package:island/pods/network.dart';
/// Provider that fetches a single article by its ID
final articleDetailProvider = FutureProvider.autoDispose.family<SnWebArticle, String>(
(ref, articleId) async {
final dio = ref.watch(apiClientProvider);
try {
final response = await dio.get<Map<String, dynamic>>(
'/feeds/articles/$articleId',
);
if (response.statusCode == 200 && response.data != null) {
return SnWebArticle.fromJson(response.data!);
} else {
throw Exception('Failed to load article');
final articleDetailProvider = FutureProvider.autoDispose
.family<SnWebArticle, String>((ref, articleId) async {
final dio = ref.watch(apiClientProvider);
try {
final response = await dio.get<Map<String, dynamic>>(
'/sphere/feeds/articles/$articleId',
);
if (response.statusCode == 200 && response.data != null) {
return SnWebArticle.fromJson(response.data!);
} else {
throw Exception('Failed to load article');
}
} on DioException catch (e) {
if (e.response?.statusCode == 404) {
throw Exception('Article not found');
} else {
throw Exception('Failed to load article: ${e.message}');
}
} catch (e) {
throw Exception('Failed to load article: $e');
}
} on DioException catch (e) {
if (e.response?.statusCode == 404) {
throw Exception('Article not found');
} else {
throw Exception('Failed to load article: ${e.message}');
}
} catch (e) {
throw Exception('Failed to load article: $e');
}
},
);
});

View File

@@ -30,7 +30,11 @@ class AttachmentPreview extends StatelessWidget {
@override
Widget build(BuildContext context) {
var ratio =
(item.isOnCloud ? (item.data.fileMeta?['ratio'] ?? 1) : 1).toDouble();
item.isOnCloud
? (item.data.fileMeta?['ratio'] is num
? item.data.fileMeta!['ratio'].toDouble()
: 1.0)
: 1.0;
if (ratio == 0) ratio = 1.0;
return AspectRatio(

View File

@@ -30,8 +30,6 @@ class CloudFileWidget extends ConsumerWidget {
var ratio =
item.fileMeta?['ratio'] is num
? item.fileMeta!['ratio'].toDouble()
: item.fileMeta?['ratio'] is String
? double.parse(item.fileMeta!['ratio'])
: 1.0;
if (ratio == 0) ratio = 1.0;
final content = switch (item.mimeType?.split('/').firstOrNull) {
@@ -39,7 +37,10 @@ class CloudFileWidget extends ConsumerWidget {
aspectRatio: ratio,
child: UniversalImage(
uri: uri,
blurHash: noBlurhash ? null : item.fileMeta?['blur'],
blurHash:
noBlurhash
? null
: (item.fileMeta is String ? item.fileMeta!['blur'] : null),
),
),
"video" => AspectRatio(

View File

@@ -609,6 +609,7 @@ Widget _buildReferencePost(BuildContext context, SnPost item) {
final isReply = item.repliedPost != null;
return Container(
margin: const EdgeInsets.only(bottom: 8),
padding: const EdgeInsets.all(12),
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.surfaceVariant.withOpacity(0.5),