Post tags

This commit is contained in:
2024-11-27 00:06:11 +08:00
parent 312d68286e
commit 420588860a
12 changed files with 616 additions and 17 deletions

View File

@ -172,6 +172,7 @@ class PostWriteController extends ChangeNotifier {
SnPublisher? publisher;
SnPost? editingPost, repostingPost, replyingPost;
List<String> tags = List.empty();
List<PostWriteMedia> attachments = List.empty(growable: true);
DateTime? publishedAt, publishedUntil;
@ -195,6 +196,7 @@ class PostWriteController extends ChangeNotifier {
contentController.text = post.body['content'] ?? '';
publishedAt = post.publishedAt;
publishedUntil = post.publishedUntil;
tags = List.from(post.tags.map((ele) => ele.alias));
attachments.addAll(
post.preload?.attachments?.map((ele) => PostWriteMedia(ele)) ?? [],
);
@ -290,6 +292,7 @@ class PostWriteController extends ChangeNotifier {
.where((e) => e.attachment != null)
.map((e) => e.attachment!.rid)
.toList(),
'tags': tags.map((ele) => {'alias': ele}).toList(),
if (publishedAt != null)
'published_at': publishedAt!.toUtc().toIso8601String(),
if (publishedUntil != null)
@ -351,6 +354,11 @@ class PostWriteController extends ChangeNotifier {
notifyListeners();
}
void setTags(List<String> value) {
tags = value;
notifyListeners();
}
void setIsBusy(bool value) {
isBusy = value;
notifyListeners();