🐛 Fix edit post didn't inherent poll and fund
This commit is contained in:
@@ -104,6 +104,22 @@ class ComposeLogic {
|
|||||||
// Initialize categories from original post
|
// Initialize categories from original post
|
||||||
final categories = originalPost?.categories ?? <SnPostCategory>[];
|
final categories = originalPost?.categories ?? <SnPostCategory>[];
|
||||||
|
|
||||||
|
// Extract poll and fund IDs from embeds
|
||||||
|
String? pollId;
|
||||||
|
String? fundId;
|
||||||
|
if (originalPost?.meta?['embeds'] is List) {
|
||||||
|
final embeds =
|
||||||
|
(originalPost!.meta!['embeds'] as List).cast<Map<String, dynamic>>();
|
||||||
|
try {
|
||||||
|
final pollEmbed = embeds.firstWhere((e) => e['type'] == 'poll');
|
||||||
|
pollId = pollEmbed['id'];
|
||||||
|
} catch (_) {}
|
||||||
|
try {
|
||||||
|
final fundEmbed = embeds.firstWhere((e) => e['type'] == 'fund');
|
||||||
|
fundId = fundEmbed['id'];
|
||||||
|
} catch (_) {}
|
||||||
|
}
|
||||||
|
|
||||||
return ComposeState(
|
return ComposeState(
|
||||||
attachments: ValueNotifier<List<UniversalFile>>(
|
attachments: ValueNotifier<List<UniversalFile>>(
|
||||||
originalPost?.attachments
|
originalPost?.attachments
|
||||||
@@ -137,10 +153,8 @@ class ComposeLogic {
|
|||||||
embedView: ValueNotifier<SnPostEmbedView?>(originalPost?.embedView),
|
embedView: ValueNotifier<SnPostEmbedView?>(originalPost?.embedView),
|
||||||
draftId: id,
|
draftId: id,
|
||||||
postType: postType,
|
postType: postType,
|
||||||
// initialize without poll by default
|
pollId: pollId,
|
||||||
pollId: null,
|
fundId: fundId,
|
||||||
// initialize without fund by default
|
|
||||||
fundId: null,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user