fix: preserve abnormal device status in root list
This commit is contained in:
@@ -59,9 +59,15 @@ public final class WechatSurfaceMapper {
|
||||
}
|
||||
|
||||
private static String buildSubtitle(JSONObject source) {
|
||||
String status = source.optBoolean("online", "online".equals(source.optString("status", "")))
|
||||
? "在线"
|
||||
: "离线";
|
||||
String statusValue = source.optString("status", "");
|
||||
String status;
|
||||
if (source.optBoolean("online", false) || "online".equals(statusValue)) {
|
||||
status = "在线";
|
||||
} else if ("abnormal".equals(statusValue)) {
|
||||
status = "异常";
|
||||
} else {
|
||||
status = "离线";
|
||||
}
|
||||
String account = source.optString("account", "");
|
||||
if (account.isEmpty()) {
|
||||
return status;
|
||||
|
||||
@@ -40,6 +40,19 @@ public class WechatSurfaceMapperTest {
|
||||
assertEquals("在线 · 17600003315", row.subtitle);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void toDeviceRow_preservesAbnormalStatus() throws Exception {
|
||||
JSONObject item = new StubJSONObject()
|
||||
.withString("name", "Mac Studio")
|
||||
.withString("status", "abnormal")
|
||||
.withString("account", "17600003315");
|
||||
|
||||
WechatSurfaceMapper.DeviceRow row = WechatSurfaceMapper.toDeviceRow(item);
|
||||
|
||||
assertEquals("Mac Studio", row.title);
|
||||
assertEquals("异常 · 17600003315", row.subtitle);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void rootMeMenuTitles_matchApprovedSimpleMenu() throws Exception {
|
||||
assertArrayEquals(
|
||||
|
||||
Reference in New Issue
Block a user