hotfix: model v3按钮排序
This commit is contained in:
parent
7a6767e56e
commit
f46bfe65fd
@ -93,6 +93,10 @@ public class ParsedButtonV3 implements MessageButton {
|
||||
@Nullable @JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
private Integer priority;
|
||||
|
||||
public int determinePriority() {
|
||||
return priority == null ? Integer.MAX_VALUE : priority;
|
||||
}
|
||||
|
||||
public List<ButtonStyleEnum> parseStyle() {
|
||||
if (style == null) return Collections.emptyList();
|
||||
return JSON.parseArray(style.toJSONString(), ButtonStyleEnum.class);
|
||||
|
||||
@ -12,6 +12,7 @@ import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@ -82,7 +83,9 @@ public class ParsedModelV3 implements MessageButtonProvider<ParsedButtonV3> {
|
||||
}
|
||||
|
||||
public List<ParsedButtonV3> determineButtons() {
|
||||
return buttons == null ? Collections.emptyList() : buttons;
|
||||
List<ParsedButtonV3> buttons = this.buttons == null ? Collections.emptyList() : this.buttons;
|
||||
buttons.sort(Comparator.comparingInt(ParsedButtonV3::determinePriority));
|
||||
return buttons;
|
||||
}
|
||||
|
||||
public void removeEmptyKVGroups() {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user