Skip to content

Commit

Permalink
fix(polls): maybe fix on vote poll crash issues
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasGGamerM committed Jan 12, 2024
1 parent 38f74c9 commit a1a4c59
Showing 1 changed file with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,25 @@ protected void updatePoll(String itemID, Status status, Poll poll){
}
i++;
}

// This is a temporary measure to deal with the app crashing when the poll isn't updated.
// This is needed because of a possible id mismatch that screws with things
if(firstOptionIndex==-1 || footerIndex==-1){
for(StatusDisplayItem item:displayItems){
if(status.id.equals(itemID)){
if(item instanceof SpoilerStatusDisplayItem){
spoilerItem=(SpoilerStatusDisplayItem) item;
}else if(item instanceof PollOptionStatusDisplayItem && firstOptionIndex==-1){
firstOptionIndex=i;
}else if(item instanceof PollFooterStatusDisplayItem){
footerIndex=i;
break;
}
}
i++;
}
}

if(firstOptionIndex==-1 || footerIndex==-1)
throw new IllegalStateException("Can't find all poll items in displayItems");
List<StatusDisplayItem> pollItems=displayItems.subList(firstOptionIndex, footerIndex+1);
Expand Down

0 comments on commit a1a4c59

Please sign in to comment.