🐛 Fix some post related bugs

This commit is contained in:
2025-10-06 12:51:28 +08:00
parent 277e9ae3d1
commit 3cbc1a59a7
5 changed files with 32 additions and 17 deletions

View File

@@ -22,10 +22,17 @@ part 'compose_settings_sheet.g.dart';
Future<List<SnPostCategory>> postCategories(Ref ref) async {
final apiClient = ref.watch(apiClientProvider);
final resp = await apiClient.get('/sphere/posts/categories');
return resp.data
.map((e) => SnPostCategory.fromJson(e))
.cast<SnPostCategory>()
.toList();
final categories =
resp.data
.map((e) => SnPostCategory.fromJson(e))
.cast<SnPostCategory>()
.toList();
// Remove duplicates based on id
final uniqueCategories = <String, SnPostCategory>{};
for (final category in categories) {
uniqueCategories[category.id] = category;
}
return uniqueCategories.values.toList();
}
/// A reusable widget for tag input fields with chip display