emoji reactions for announcements!
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
package org.joinmastodon.android.model;
|
||||
|
||||
import org.joinmastodon.android.api.ObjectValidationException;
|
||||
import org.joinmastodon.android.api.RequiredField;
|
||||
import org.parceler.Parcel;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Parcel
|
||||
@@ -20,6 +22,7 @@ public class Announcement extends BaseModel implements DisplayItemsParent {
|
||||
public Instant updatedAt;
|
||||
public boolean read;
|
||||
public List<Emoji> emojis;
|
||||
public List<EmojiReaction> reactions;
|
||||
public List<Mention> mentions;
|
||||
public List<Hashtag> tags;
|
||||
|
||||
@@ -41,10 +44,17 @@ public class Announcement extends BaseModel implements DisplayItemsParent {
|
||||
'}';
|
||||
}
|
||||
|
||||
public Status toStatus() {
|
||||
Status s = Status.ofFake(id, content, publishedAt);
|
||||
s.createdAt = startsAt != null ? startsAt : publishedAt;
|
||||
if (updatedAt != null) s.editedAt = updatedAt;
|
||||
@Override
|
||||
public void postprocess() throws ObjectValidationException{
|
||||
super.postprocess();
|
||||
if(reactions==null) reactions=new ArrayList<>();
|
||||
}
|
||||
|
||||
public Status toStatus() {
|
||||
Status s=Status.ofFake(id, content, publishedAt);
|
||||
s.createdAt=startsAt != null ? startsAt : publishedAt;
|
||||
s.reactions=reactions;
|
||||
if(updatedAt != null) s.editedAt=updatedAt;
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
@@ -100,7 +100,7 @@ public class Status extends BaseModel implements DisplayItemsParent, Searchable{
|
||||
t.postprocess();
|
||||
for(Emoji e:emojis)
|
||||
e.postprocess();
|
||||
if (mediaAttachments == null) mediaAttachments = List.of();
|
||||
if (mediaAttachments == null) mediaAttachments=List.of();
|
||||
for(Attachment a:mediaAttachments)
|
||||
a.postprocess();
|
||||
account.postprocess();
|
||||
@@ -201,17 +201,18 @@ public class Status extends BaseModel implements DisplayItemsParent, Searchable{
|
||||
}
|
||||
|
||||
public static Status ofFake(String id, String text, Instant createdAt) {
|
||||
Status s = new Status();
|
||||
s.id = id;
|
||||
s.mediaAttachments = List.of();
|
||||
s.createdAt = createdAt;
|
||||
s.content = s.text = text;
|
||||
s.spoilerText = "";
|
||||
s.visibility = StatusPrivacy.PUBLIC;
|
||||
s.mentions = List.of();
|
||||
s.tags = List.of();
|
||||
s.emojis = List.of();
|
||||
s.filtered = List.of();
|
||||
Status s=new Status();
|
||||
s.id=id;
|
||||
s.mediaAttachments=List.of();
|
||||
s.createdAt=createdAt;
|
||||
s.content=s.text=text;
|
||||
s.spoilerText="";
|
||||
s.visibility=StatusPrivacy.PUBLIC;
|
||||
s.reactions=List.of();
|
||||
s.mentions=List.of();
|
||||
s.tags =List.of();
|
||||
s.emojis=List.of();
|
||||
s.filtered=List.of();
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -223,21 +224,21 @@ public class Status extends BaseModel implements DisplayItemsParent, Searchable{
|
||||
public static class StatusDeserializer implements JsonDeserializer<Status> {
|
||||
@Override
|
||||
public Status deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
|
||||
JsonObject obj = json.getAsJsonObject();
|
||||
JsonObject obj=json.getAsJsonObject();
|
||||
|
||||
Status quote = null;
|
||||
Status quote=null;
|
||||
if (obj.has("quote") && obj.get("quote").isJsonObject())
|
||||
quote = gson.fromJson(obj.get("quote"), Status.class);
|
||||
quote=gson.fromJson(obj.get("quote"), Status.class);
|
||||
obj.remove("quote");
|
||||
|
||||
Status reblog = null;
|
||||
Status reblog=null;
|
||||
if (obj.has("reblog"))
|
||||
reblog = gson.fromJson(obj.get("reblog"), Status.class);
|
||||
reblog=gson.fromJson(obj.get("reblog"), Status.class);
|
||||
obj.remove("reblog");
|
||||
|
||||
Status status = gsonWithoutDeserializer.fromJson(json, Status.class);
|
||||
status.quote = quote;
|
||||
status.reblog = reblog;
|
||||
Status status=gsonWithoutDeserializer.fromJson(json, Status.class);
|
||||
status.quote=quote;
|
||||
status.reblog=reblog;
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user