fix: support archived thread search on android homepage
This commit is contained in:
@@ -1086,12 +1086,12 @@ public class MainActivity extends AppCompatActivity {
|
||||
return;
|
||||
}
|
||||
if ("folder_archive".equals(conversationType)
|
||||
|| (conversationSearchMode && isArchivedProjectThread(item))) {
|
||||
|| (conversationSearchMode && !item.optString("searchMatchLabel", "").isEmpty())) {
|
||||
if (folderKey.isEmpty()) {
|
||||
showMessage("缺少 folderKey");
|
||||
return;
|
||||
}
|
||||
openConversationFolder(folderKey, resolveConversationFolderName(item, finalDisplayRow));
|
||||
openConversationFolder(folderKey, resolveConversationFolderName(item, row));
|
||||
return;
|
||||
}
|
||||
if (projectId.isEmpty()) {
|
||||
@@ -1105,22 +1105,14 @@ public class MainActivity extends AppCompatActivity {
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isArchivedProjectThread(JSONObject item) {
|
||||
String folderKey = item.optString("folderKey", "").trim();
|
||||
if (folderKey.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
return item.optInt("threadCount", 0) > 1;
|
||||
}
|
||||
|
||||
private static String buildConversationSearchLabel(JSONObject item, WechatSurfaceMapper.ConversationRow row) {
|
||||
if (row == null) {
|
||||
return "";
|
||||
}
|
||||
if (isArchivedProjectThread(item)) {
|
||||
String folderLabel = row.folderLabel == null ? "" : row.folderLabel.trim();
|
||||
if (!folderLabel.isEmpty()) {
|
||||
return folderLabel + " / " + row.threadTitle;
|
||||
if ("folder_archive".equals(item.optString("conversationType", ""))) {
|
||||
String matchedThreadTitle = item.optString("searchMatchLabel", "").trim();
|
||||
if (!matchedThreadTitle.isEmpty()) {
|
||||
return row.threadTitle + " / " + matchedThreadTitle;
|
||||
}
|
||||
}
|
||||
return row.threadTitle;
|
||||
@@ -1321,7 +1313,17 @@ public class MainActivity extends AppCompatActivity {
|
||||
continue;
|
||||
}
|
||||
if (matchesConversationQuery(item, query)) {
|
||||
filtered.put(item);
|
||||
JSONObject filteredItem = item;
|
||||
try {
|
||||
filteredItem = new JSONObject(item.toString());
|
||||
String matchLabel = resolveConversationSearchMatchLabel(item, query);
|
||||
if (!matchLabel.isEmpty()) {
|
||||
filteredItem.put("searchMatchLabel", matchLabel);
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
// Keep the original item if JSON cloning fails.
|
||||
}
|
||||
filtered.put(filteredItem);
|
||||
}
|
||||
}
|
||||
return filtered;
|
||||
@@ -1426,6 +1428,9 @@ public class MainActivity extends AppCompatActivity {
|
||||
if (query.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
if (!resolveConversationSearchMatchLabel(item, query).isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
String[] fields = new String[] {
|
||||
item.optString("projectTitle", ""),
|
||||
item.optString("threadTitle", ""),
|
||||
@@ -1441,6 +1446,26 @@ public class MainActivity extends AppCompatActivity {
|
||||
return false;
|
||||
}
|
||||
|
||||
private static String resolveConversationSearchMatchLabel(JSONObject item, String query) {
|
||||
if (item == null || query == null || query.isEmpty()) {
|
||||
return "";
|
||||
}
|
||||
if (!"folder_archive".equals(item.optString("conversationType", ""))) {
|
||||
return "";
|
||||
}
|
||||
JSONArray searchAliases = item.optJSONArray("searchAliases");
|
||||
if (searchAliases == null) {
|
||||
return "";
|
||||
}
|
||||
for (int i = 0; i < searchAliases.length(); i++) {
|
||||
String alias = searchAliases.optString(i, "").trim();
|
||||
if (!alias.isEmpty() && alias.toLowerCase().contains(query)) {
|
||||
return alias;
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
private void renderDevicesRoot() {
|
||||
if (screenList == null) {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user