🐛 Fix webfeed issues, close #235

This commit is contained in:
2026-01-14 01:49:27 +08:00
parent 0328a7736a
commit ac5193e1f6
2 changed files with 23 additions and 20 deletions

View File

@@ -35,7 +35,7 @@ class WebFeedNotifier extends AsyncNotifier<SnWebFeed> {
try {
final client = ref.read(apiClientProvider);
final response = await client.get(
'/sphere/publishers/${arg.pubName}/feeds/${arg.feedId}',
'/insight/publishers/${arg.pubName}/feeds/${arg.feedId}',
);
return SnWebFeed.fromJson(response.data);
} catch (e) {
@@ -47,7 +47,7 @@ class WebFeedNotifier extends AsyncNotifier<SnWebFeed> {
state = const AsyncValue.loading();
try {
final client = ref.read(apiClientProvider);
final url = '/sphere/publishers/${feed.publisherId}/feeds';
final url = '/insight/publishers/${feed.publisherId}/feeds';
final response = feed.id.isEmpty
? await client.post(url, data: feed.toJson())
@@ -67,7 +67,7 @@ class WebFeedNotifier extends AsyncNotifier<SnWebFeed> {
state = const AsyncValue.loading();
try {
final client = ref.read(apiClientProvider);
await client.delete('/sphere/publishers/${arg.pubName}/feeds/$feedId');
await client.delete('/insight/publishers/${arg.pubName}/feeds/$feedId');
state = AsyncValue.data(
SnWebFeed(
id: '',
@@ -93,7 +93,7 @@ class WebFeedNotifier extends AsyncNotifier<SnWebFeed> {
try {
final client = ref.read(apiClientProvider);
await client.post(
'/sphere/publishers/${arg.pubName}/feeds/$feedId/scrap',
'/insight/publishers/${arg.pubName}/feeds/$feedId/scrap',
options: Options(
sendTimeout: const Duration(seconds: 60),
receiveTimeout: const Duration(seconds: 180),

View File

@@ -105,14 +105,12 @@ class WebfeedForm extends HookConsumerWidget {
return feedAsync.when(
loading: () => const Center(child: CircularProgressIndicator()),
error:
(error, _) => ResponseErrorWidget(
error: error,
onRetry:
() => ref.invalidate(
webFeedNotifierProvider((pubName: pubName, feedId: feedId)),
),
),
error: (error, _) => ResponseErrorWidget(
error: error,
onRetry: () => ref.invalidate(
webFeedNotifierProvider((pubName: pubName, feedId: feedId)),
),
),
data: (feed) {
// Initialize form fields if they're empty and we have a feed
if (titleController.text.isEmpty) {
@@ -140,7 +138,7 @@ class WebfeedForm extends HookConsumerWidget {
} catch (e) {
showErrorAlert(e);
} finally {
isLoading.value = false;
if (context.mounted) isLoading.value = false;
}
}, [pubName, feedId, ref, context, isLoading]);
@@ -160,8 +158,8 @@ class WebfeedForm extends HookConsumerWidget {
}
return null;
},
onTapOutside:
(_) => FocusManager.instance.primaryFocus?.unfocus(),
onTapOutside: (_) =>
FocusManager.instance.primaryFocus?.unfocus(),
),
const SizedBox(height: 16),
TextFormField(
@@ -184,8 +182,8 @@ class WebfeedForm extends HookConsumerWidget {
}
return null;
},
onTapOutside:
(_) => FocusManager.instance.primaryFocus?.unfocus(),
onTapOutside: (_) =>
FocusManager.instance.primaryFocus?.unfocus(),
),
const SizedBox(height: 16),
TextFormField(
@@ -197,8 +195,8 @@ class WebfeedForm extends HookConsumerWidget {
borderRadius: BorderRadius.all(Radius.circular(12)),
),
),
onTapOutside:
(_) => FocusManager.instance.primaryFocus?.unfocus(),
onTapOutside: (_) =>
FocusManager.instance.primaryFocus?.unfocus(),
maxLines: 3,
),
const SizedBox(height: 24),
@@ -256,7 +254,12 @@ class WebfeedForm extends HookConsumerWidget {
],
).padding(horizontal: 20, vertical: 12);
return Column(children: [Expanded(child: formWidget), buttonsRow]);
return Column(
children: [
Expanded(child: formWidget),
buttonsRow,
],
);
},
);
}