reblogs now show up correctly
This commit is contained in:
parent
f71bcf1d42
commit
e46876f10a
|
@ -15,6 +15,7 @@ enum Visibility { public, unlisted, private, direct }
|
|||
|
||||
class PostModel implements Comparable {
|
||||
late String id;
|
||||
late String createdAt;
|
||||
late String uri;
|
||||
late String content;
|
||||
late Visibility visibility;
|
||||
|
@ -23,10 +24,18 @@ class PostModel implements Comparable {
|
|||
late bool favourited;
|
||||
late bool reblogged;
|
||||
late AccountModel account;
|
||||
late AccountModel? rebloggedBy;
|
||||
late List<MediaAttachmentModel> attachments;
|
||||
|
||||
PostModel.fromJson(Map<String, dynamic> json) {
|
||||
id = json["id"] as String;
|
||||
createdAt = json["created_at"];
|
||||
if (json["reblog"] != null) {
|
||||
rebloggedBy = AccountModel.fromJson(json["account"]);
|
||||
json = json["reblog"];
|
||||
} else {
|
||||
rebloggedBy = null;
|
||||
}
|
||||
uri = json["uri"] as String;
|
||||
content = json["content"] as String;
|
||||
visibility = Visibility.values.firstWhere(
|
||||
|
@ -106,8 +115,13 @@ Future<ThreadModel> getTimelineFromServer(String? olderThan) async {
|
|||
headers.addAll(global.defaultHeaders);
|
||||
|
||||
final response = await http.get(url, headers: headers);
|
||||
final List<dynamic> json = jsonDecode(response.body);
|
||||
final post = PostModel.fromJson(json[0]);
|
||||
final List<dynamic> json = await jsonDecode(response.body);
|
||||
if (json.isEmpty) {
|
||||
print(" error json empty");
|
||||
print(response.body);
|
||||
}
|
||||
|
||||
final PostModel post = PostModel.fromJson(json[0]);
|
||||
|
||||
return await post.getThread();
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
"account-settings": "account settings",
|
||||
"logout": "log out",
|
||||
"show-in-browser": "show in browser",
|
||||
"post-options": "post options"
|
||||
"post-options": "post options",
|
||||
"reblogged-by": "reblogged by:"
|
||||
}
|
||||
|
|
@ -29,6 +29,7 @@ class _PostState extends State<Post> {
|
|||
media: widget.model.attachments,
|
||||
),
|
||||
postActionBar(context, widget.model),
|
||||
RebloggedBy(account: widget.model.rebloggedBy),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
@ -72,6 +73,33 @@ class DisplayName extends StatelessWidget {
|
|||
}
|
||||
}
|
||||
|
||||
class RebloggedBy extends StatelessWidget {
|
||||
const RebloggedBy({
|
||||
required this.account,
|
||||
Key? key,
|
||||
}) : super(key: key);
|
||||
final AccountModel? account;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (account != null) {
|
||||
return Column(
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
const Icon(Icons.repeat),
|
||||
Flexible(child: SelectableText("reblogged-by".i18n())),
|
||||
],
|
||||
),
|
||||
DisplayName(account: account!),
|
||||
],
|
||||
);
|
||||
} else {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ProfilePic extends StatelessWidget {
|
||||
const ProfilePic({required this.url, Key? key}) : super(key: key);
|
||||
final String url;
|
||||
|
|
|
@ -12,7 +12,9 @@ void popupPostOptions(context, PostModel model) {
|
|||
backgroundColor: Theme.of(context).colorScheme.surface,
|
||||
title: SelectableText("post-options".i18n()),
|
||||
alignment: Alignment.center,
|
||||
contentPadding: EdgeInsetsDirectional.all(8),
|
||||
children: [
|
||||
SelectableText(model.createdAt),
|
||||
TextButton.icon(
|
||||
onPressed: () {
|
||||
launchUrl(
|
||||
|
|
Loading…
Reference in New Issue