🐛 Fix webfeed issues, close #235
This commit is contained in:
@@ -35,7 +35,7 @@ class WebFeedNotifier extends AsyncNotifier<SnWebFeed> {
|
|||||||
try {
|
try {
|
||||||
final client = ref.read(apiClientProvider);
|
final client = ref.read(apiClientProvider);
|
||||||
final response = await client.get(
|
final response = await client.get(
|
||||||
'/sphere/publishers/${arg.pubName}/feeds/${arg.feedId}',
|
'/insight/publishers/${arg.pubName}/feeds/${arg.feedId}',
|
||||||
);
|
);
|
||||||
return SnWebFeed.fromJson(response.data);
|
return SnWebFeed.fromJson(response.data);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -47,7 +47,7 @@ class WebFeedNotifier extends AsyncNotifier<SnWebFeed> {
|
|||||||
state = const AsyncValue.loading();
|
state = const AsyncValue.loading();
|
||||||
try {
|
try {
|
||||||
final client = ref.read(apiClientProvider);
|
final client = ref.read(apiClientProvider);
|
||||||
final url = '/sphere/publishers/${feed.publisherId}/feeds';
|
final url = '/insight/publishers/${feed.publisherId}/feeds';
|
||||||
|
|
||||||
final response = feed.id.isEmpty
|
final response = feed.id.isEmpty
|
||||||
? await client.post(url, data: feed.toJson())
|
? await client.post(url, data: feed.toJson())
|
||||||
@@ -67,7 +67,7 @@ class WebFeedNotifier extends AsyncNotifier<SnWebFeed> {
|
|||||||
state = const AsyncValue.loading();
|
state = const AsyncValue.loading();
|
||||||
try {
|
try {
|
||||||
final client = ref.read(apiClientProvider);
|
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(
|
state = AsyncValue.data(
|
||||||
SnWebFeed(
|
SnWebFeed(
|
||||||
id: '',
|
id: '',
|
||||||
@@ -93,7 +93,7 @@ class WebFeedNotifier extends AsyncNotifier<SnWebFeed> {
|
|||||||
try {
|
try {
|
||||||
final client = ref.read(apiClientProvider);
|
final client = ref.read(apiClientProvider);
|
||||||
await client.post(
|
await client.post(
|
||||||
'/sphere/publishers/${arg.pubName}/feeds/$feedId/scrap',
|
'/insight/publishers/${arg.pubName}/feeds/$feedId/scrap',
|
||||||
options: Options(
|
options: Options(
|
||||||
sendTimeout: const Duration(seconds: 60),
|
sendTimeout: const Duration(seconds: 60),
|
||||||
receiveTimeout: const Duration(seconds: 180),
|
receiveTimeout: const Duration(seconds: 180),
|
||||||
|
|||||||
@@ -105,11 +105,9 @@ class WebfeedForm extends HookConsumerWidget {
|
|||||||
|
|
||||||
return feedAsync.when(
|
return feedAsync.when(
|
||||||
loading: () => const Center(child: CircularProgressIndicator()),
|
loading: () => const Center(child: CircularProgressIndicator()),
|
||||||
error:
|
error: (error, _) => ResponseErrorWidget(
|
||||||
(error, _) => ResponseErrorWidget(
|
|
||||||
error: error,
|
error: error,
|
||||||
onRetry:
|
onRetry: () => ref.invalidate(
|
||||||
() => ref.invalidate(
|
|
||||||
webFeedNotifierProvider((pubName: pubName, feedId: feedId)),
|
webFeedNotifierProvider((pubName: pubName, feedId: feedId)),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -140,7 +138,7 @@ class WebfeedForm extends HookConsumerWidget {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
showErrorAlert(e);
|
showErrorAlert(e);
|
||||||
} finally {
|
} finally {
|
||||||
isLoading.value = false;
|
if (context.mounted) isLoading.value = false;
|
||||||
}
|
}
|
||||||
}, [pubName, feedId, ref, context, isLoading]);
|
}, [pubName, feedId, ref, context, isLoading]);
|
||||||
|
|
||||||
@@ -160,8 +158,8 @@ class WebfeedForm extends HookConsumerWidget {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
onTapOutside:
|
onTapOutside: (_) =>
|
||||||
(_) => FocusManager.instance.primaryFocus?.unfocus(),
|
FocusManager.instance.primaryFocus?.unfocus(),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
TextFormField(
|
TextFormField(
|
||||||
@@ -184,8 +182,8 @@ class WebfeedForm extends HookConsumerWidget {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
onTapOutside:
|
onTapOutside: (_) =>
|
||||||
(_) => FocusManager.instance.primaryFocus?.unfocus(),
|
FocusManager.instance.primaryFocus?.unfocus(),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
TextFormField(
|
TextFormField(
|
||||||
@@ -197,8 +195,8 @@ class WebfeedForm extends HookConsumerWidget {
|
|||||||
borderRadius: BorderRadius.all(Radius.circular(12)),
|
borderRadius: BorderRadius.all(Radius.circular(12)),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
onTapOutside:
|
onTapOutside: (_) =>
|
||||||
(_) => FocusManager.instance.primaryFocus?.unfocus(),
|
FocusManager.instance.primaryFocus?.unfocus(),
|
||||||
maxLines: 3,
|
maxLines: 3,
|
||||||
),
|
),
|
||||||
const SizedBox(height: 24),
|
const SizedBox(height: 24),
|
||||||
@@ -256,7 +254,12 @@ class WebfeedForm extends HookConsumerWidget {
|
|||||||
],
|
],
|
||||||
).padding(horizontal: 20, vertical: 12);
|
).padding(horizontal: 20, vertical: 12);
|
||||||
|
|
||||||
return Column(children: [Expanded(child: formWidget), buttonsRow]);
|
return Column(
|
||||||
|
children: [
|
||||||
|
Expanded(child: formWidget),
|
||||||
|
buttonsRow,
|
||||||
|
],
|
||||||
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user