🐛 Fix article edit shows the post edit sheet
This commit is contained in:
@@ -1 +0,0 @@
|
||||
|
||||
@@ -6,6 +6,7 @@ import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:island/widgets/app_scaffold.dart';
|
||||
import 'package:island/widgets/extended_refresh_indicator.dart';
|
||||
import 'package:island/widgets/post/post_item.dart';
|
||||
import 'package:island/widgets/post/post_item_skeleton.dart';
|
||||
import 'package:island/widgets/posts/post_filter.dart';
|
||||
import 'package:gap/gap.dart';
|
||||
import 'package:island/pods/post/post_list.dart';
|
||||
@@ -140,6 +141,12 @@ class PostSearchScreen extends HookConsumerWidget {
|
||||
).notifier,
|
||||
isSliver: true,
|
||||
isRefreshable: false,
|
||||
footerSkeletonChild: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 8,
|
||||
),
|
||||
child: const PostItemSkeleton(),
|
||||
),
|
||||
itemBuilder: (context, index, post) {
|
||||
return Card(
|
||||
margin: EdgeInsets.symmetric(
|
||||
@@ -261,6 +268,10 @@ class PostSearchScreen extends HookConsumerWidget {
|
||||
).notifier,
|
||||
isSliver: true,
|
||||
isRefreshable: false,
|
||||
footerSkeletonChild: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||
child: const PostItemSkeleton(),
|
||||
),
|
||||
itemBuilder: (context, index, post) {
|
||||
return Center(
|
||||
child: ConstrainedBox(
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:island/models/file.dart';
|
||||
import 'package:island/models/post.dart';
|
||||
@@ -32,12 +33,17 @@ class PostComposeSheet extends HookConsumerWidget {
|
||||
SnPost? originalPost,
|
||||
PostComposeInitialState? initialState,
|
||||
}) {
|
||||
// Check if editing an article
|
||||
if (originalPost != null && originalPost.type == 1) {
|
||||
context.pushNamed('articleEdit', pathParameters: {'id': originalPost.id});
|
||||
return Future.value(true);
|
||||
}
|
||||
|
||||
return showModalBottomSheet<bool>(
|
||||
context: context,
|
||||
isScrollControlled: true,
|
||||
useRootNavigator: true,
|
||||
builder:
|
||||
(context) => PostComposeSheet(
|
||||
builder: (context) => PostComposeSheet(
|
||||
originalPost: originalPost,
|
||||
initialState: initialState,
|
||||
isBottomSheet: true,
|
||||
@@ -52,8 +58,7 @@ class PostComposeSheet extends HookConsumerWidget {
|
||||
final prompted = useState(false);
|
||||
|
||||
// Fetch full post data if we're editing a post
|
||||
final fullPostData =
|
||||
originalPost != null
|
||||
final fullPostData = originalPost != null
|
||||
? ref.watch(postProvider(originalPost!.id))
|
||||
: const AsyncValue.data(null);
|
||||
|
||||
@@ -115,7 +120,11 @@ class PostComposeSheet extends HookConsumerWidget {
|
||||
}, [drafts, prompted.value]);
|
||||
|
||||
// Dispose state when widget is disposed
|
||||
useEffect(() => () => ComposeLogic.dispose(state), []);
|
||||
useEffect(
|
||||
() =>
|
||||
() => ComposeLogic.dispose(state),
|
||||
[],
|
||||
);
|
||||
|
||||
// Helper methods for actions
|
||||
void showSettingsSheet() {
|
||||
@@ -147,8 +156,7 @@ class PostComposeSheet extends HookConsumerWidget {
|
||||
(state.submitting.value || state.currentPublisher.value == null)
|
||||
? null
|
||||
: performSubmit,
|
||||
icon:
|
||||
state.submitting.value
|
||||
icon: state.submitting.value
|
||||
? SizedBox(
|
||||
width: 24,
|
||||
height: 24,
|
||||
@@ -157,8 +165,7 @@ class PostComposeSheet extends HookConsumerWidget {
|
||||
: Icon(
|
||||
effectiveOriginalPost != null ? Symbols.edit : Symbols.upload,
|
||||
),
|
||||
tooltip:
|
||||
effectiveOriginalPost != null
|
||||
tooltip: effectiveOriginalPost != null
|
||||
? 'postUpdate'.tr()
|
||||
: 'postPublish'.tr(),
|
||||
),
|
||||
@@ -192,8 +199,7 @@ class PostComposeSheet extends HookConsumerWidget {
|
||||
final restore = await showDialog<bool>(
|
||||
context: ref.context,
|
||||
useRootNavigator: true,
|
||||
builder:
|
||||
(context) => AlertDialog(
|
||||
builder: (context) => AlertDialog(
|
||||
title: Text('restoreDraftTitle'.tr()),
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
@@ -226,8 +232,7 @@ class PostComposeSheet extends HookConsumerWidget {
|
||||
description: latestDraft.description,
|
||||
content: latestDraft.content,
|
||||
visibility: latestDraft.visibility,
|
||||
attachments:
|
||||
latestDraft.attachments
|
||||
attachments: latestDraft.attachments
|
||||
.map((e) => UniversalFile.fromAttachment(e))
|
||||
.toList(),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user