Put clean up recycled files back

This commit is contained in:
2025-11-17 23:53:11 +08:00
parent b233f9a410
commit 0767bb53ce

View File

@@ -408,6 +408,8 @@ class FileListView extends HookConsumerWidget {
), ),
), ),
).padding(horizontal: 8), ).padding(horizontal: 8),
if (mode.value == FileListMode.unindexed && recycled.value)
_buildClearRecycledButton(ref).padding(horizontal: 8),
if (isRefreshing) if (isRefreshing)
const LinearProgressIndicator( const LinearProgressIndicator(
minHeight: 4, minHeight: 4,
@@ -1070,4 +1072,59 @@ class FileListView extends HookConsumerWidget {
), ),
); );
} }
Widget _buildClearRecycledButton(WidgetRef ref) {
return Card(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 12),
child: Row(
spacing: 16,
children: [
const Icon(Symbols.recycling).padding(horizontal: 2),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text('Clear All Recycled Files').bold(),
const Text(
'Permanently delete all marked recycled files to free up space.',
).fontSize(13),
],
),
),
ElevatedButton.icon(
icon: const Icon(Symbols.delete_forever),
label: const Text('Clear'),
onPressed: () async {
final confirmed = await showConfirmAlert(
'Are you sure you want to clear all recycled files?',
'Clear Recycled Files',
);
if (!confirmed) return;
if (ref.context.mounted) {
showLoadingModal(ref.context);
}
try {
final client = ref.read(apiClientProvider);
final response = await client.delete(
'/drive/files/me/recycle',
);
final count = response.data['count'] as int? ?? 0;
showSnackBar('Cleared $count recycled files.');
ref.invalidate(unindexedFileListNotifierProvider);
} catch (e) {
showSnackBar('Failed to clear recycled files.');
} finally {
if (ref.context.mounted) {
hideLoadingModal(ref.context);
}
}
},
),
],
),
),
);
}
} }