fix editing scheduled/drafted polls
closes sk22#894
This commit is contained in:
@@ -200,7 +200,7 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
|
||||
public Instance instance;
|
||||
|
||||
public Status editingStatus;
|
||||
private ScheduledStatus scheduledStatus;
|
||||
public ScheduledStatus scheduledStatus;
|
||||
private boolean redraftStatus;
|
||||
|
||||
private ContentType contentType;
|
||||
|
||||
@@ -6,6 +6,7 @@ import org.joinmastodon.android.model.Poll.Option;
|
||||
import org.parceler.Parcel;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -73,6 +74,7 @@ public class ScheduledStatus extends BaseModel implements DisplayItemsParent{
|
||||
p.ownVotes=List.of();
|
||||
p.multiple=multiple;
|
||||
p.options=options.stream().map(Option::new).collect(Collectors.toList());
|
||||
p.expiresAt=Instant.now().plus(Integer.parseInt(expiresIn)+1, ChronoUnit.SECONDS);
|
||||
return p;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,6 +134,9 @@ public class ComposePollViewController{
|
||||
DraftPollOption opt=createDraftPollOption(false);
|
||||
opt.edit.setText(eopt.title);
|
||||
}
|
||||
if(fragment.scheduledStatus!=null && fragment.scheduledStatus.params.poll!=null)
|
||||
pollDuration=Integer.parseInt(fragment.scheduledStatus.params.poll.expiresIn);
|
||||
else if(fragment.editingStatus.poll.expiresAt!=null)
|
||||
pollDuration=(int)fragment.editingStatus.poll.expiresAt.minus(fragment.editingStatus.createdAt.toEpochMilli(), ChronoUnit.MILLIS).getEpochSecond();
|
||||
updatePollOptionHints();
|
||||
pollDurationValue.setText(UiUtils.formatDuration(fragment.getContext(), pollDuration));
|
||||
|
||||
Reference in New Issue
Block a user