From a217167667896935d699f08ecb7faef35fd65aaa Mon Sep 17 00:00:00 2001 From: Grishka Date: Sat, 16 Nov 2024 15:04:46 +0300 Subject: [PATCH] Increase robustness of instance data loading --- .../android/api/session/AccountSessionManager.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/mastodon/src/main/java/org/joinmastodon/android/api/session/AccountSessionManager.java b/mastodon/src/main/java/org/joinmastodon/android/api/session/AccountSessionManager.java index ea896dc3..402eebd4 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/api/session/AccountSessionManager.java +++ b/mastodon/src/main/java/org/joinmastodon/android/api/session/AccountSessionManager.java @@ -395,8 +395,14 @@ public class AccountSessionManager{ case 2 -> InstanceV2.class; default -> throw new IllegalStateException("Unexpected value: "+version); }); + instances.put(domain, instance); StringBuilder emojiSB=new StringBuilder(); - emojiSB.append(values.getAsString("emojis")); + String emojiPart=values.getAsString("emojis"); + if(emojiPart==null){ + // not putting anything into instancesLastUpdated to force a reload + continue; + } + emojiSB.append(emojiPart); //get emoji in chunks of 1MB if it didn't fit in the first query int emojiStringLength=values.getAsInteger("emoji_length"); if(emojiStringLength>maxEmojiLength){ @@ -409,13 +415,12 @@ public class AccountSessionManager{ } } List emojis=MastodonAPIController.gson.fromJson(emojiSB.toString(), new TypeToken>(){}.getType()); - instances.put(domain, instance); customEmojis.put(domain, groupCustomEmojis(emojis)); instancesLastUpdated.put(domain, values.getAsLong("last_updated")); } }catch(Exception ex){ Log.d(TAG, "readInstanceInfo failed", ex); - return; + // instancesLastUpdated will not contain that domain, so instance data will be forced to be reloaded } } if(!loadedInstances){