fix reblogging responses

This commit is contained in:
zoe 2022-08-10 23:48:09 +02:00
parent 5255bad5ab
commit 2ca8c6b83e
1 changed files with 6 additions and 3 deletions

View File

@ -15,6 +15,7 @@ enum Visibility { public, unlisted, private, direct }
class PostModel implements Comparable {
late String id;
late String? reblogId;
late String createdAt;
late String uri;
late String content;
@ -29,10 +30,12 @@ class PostModel implements Comparable {
PostModel.fromJson(Map<String, dynamic> json) {
id = json["id"] as String;
reblogId = null;
createdAt = json["created_at"];
if (json["reblog"] != null) {
rebloggedBy = AccountModel.fromJson(json["account"]);
json = json["reblog"];
reblogId = json["id"];
} else {
rebloggedBy = null;
}
@ -63,13 +66,13 @@ class PostModel implements Comparable {
final baseUrl = await settings.loadInstanceUrl();
Map<String, String> headers = {"Authorization": "Bearer $token"};
headers.addAll(global.defaultHeaders);
String currentId = reblogId ?? id;
final url = Uri(
scheme: "https",
host: baseUrl,
path: "/api/v1/statuses/$id/context",
path: "/api/v1/statuses/$currentId/context",
);
final response = await http.get(url, headers: headers);
http.Response response = await http.get(url, headers: headers);
if (response.statusCode != 200) {
return ThreadModel([this]);
}