Post editor able to edit article

This commit is contained in:
2024-07-30 16:44:04 +08:00
parent 58bb549217
commit fc77c8693f
3 changed files with 40 additions and 2 deletions

View File

@ -94,6 +94,7 @@ class PostEditorController extends GetxController {
'repost_to': repostTo.value?.toJson(),
'edit_to': editTo.value?.toJson(),
'realm': realmZone.value?.toJson(),
'type': type,
}),
);
}
@ -131,6 +132,7 @@ class PostEditorController extends GetxController {
return;
}
type = value.type;
editTo.value = value;
isDraft.value = value.isDraft ?? false;
titleController.text = value.body['title'] ?? '';
@ -142,6 +144,37 @@ class PostEditorController extends GetxController {
contentLength.value = contentController.text.length;
}
String get typeEndpoint {
switch(mode.value) {
case 0:
return 'stories';
case 1:
return 'articles';
default:
return 'stories';
}
}
String get type {
switch(mode.value) {
case 0:
return 'story';
case 1:
return 'article';
default:
return 'story';
}
}
set type(String value) {
switch (value) {
case 'story':
mode.value = 0;
case 'article':
mode.value = 1;
}
}
String? get title {
if (titleController.text.isEmpty) return null;
return titleController.text;
@ -168,6 +201,7 @@ class PostEditorController extends GetxController {
}
set payload(Map<String, dynamic> value) {
type = value['type'];
titleController.text = value['title'] ?? '';
descriptionController.text = value['description'] ?? '';
contentController.text = value['content'] ?? '';