This commit is contained in:
janisslsm committed 2026-11-01 12:12:55 +02:00
1 parent 1781d25a15
commit 732c0ad767
33051 files changed
+2591613 -3019689

No files matched your search

@@ -0,0 +1,61 @@
// Metro module 15545 (f15546).
import MessageRecord from "../../../../records/MessageRecord";
import { CachedSearchResultParser } from "./CachedSearchResultParser";
import { getQueryContentString, getSearchQueryFromTokens, tokenizeQuery } from "../../SearchUtils";
import { analyze, shouldHighlight } from "../../../../lib/search/EnglishAnalyzer";
import { chain } from "../../../../_bundle/Module12";
class SearchResultMessageParser extends CachedSearchResultParser {
constructor(a0, a1) {
super();
const _this = this;
this.truncateMessage = function truncateMessage(a0, a1, r10 = 1) {
if (a0 == null) {
return null;
}
const r15 = a0.replace(/(\r\n|\n|\r)/gm, " ");
let c28077_0 = new Set(analyze(a1));
const r31 = r15.split(/(\W+)/g).find((item) => shouldHighlight(item, c28077_0));
if (r31 == null) {
return null;
}
const r41 = r15.search(new RegExp("\\b" + r31 + "\\b"));
if (r41 === -1) {
return null;
}
const r49 = Math.max(0, r41 - (30 * r10 - r31.length));
return `${r49 > 0 ? "..." : ""}${r15.substring(r49)}`;
};
this.getSearchResults = (a0) => {
if (_this.tokenizedQueryContent != null && _this.tokenizedQueryContent !== "") {
const content = _this.truncateMessage(a0.content, _this.tokenizedQueryContent, _this.lineClamp);
if (content != null) {
const messageRecord2 = new MessageRecord(a0);
messageRecord2.content = content;
return messageRecord2;
}
const content2 = chain(a0.embeds).map((item) => {
let r8 = _this.truncateMessage(item.rawTitle, _this.tokenizedQueryContent, _this.lineClamp);
if (r8 == null) {
r8 = _this.truncateMessage(item.rawDescription, _this.tokenizedQueryContent, _this.lineClamp);
}
return r8;
}).find((item) => item != null).value();
if (content2 != null) {
const messageRecord = new MessageRecord(a0);
messageRecord.content = content2;
return messageRecord;
}
return a0;
}
return a0;
};
const queryContentString = getQueryContentString(getSearchQueryFromTokens(tokenizeQuery(a0)));
let tokenizedQueryContent = queryContentString == null ? void 0 : queryContentString.trim();
if (tokenizedQueryContent == null) {
tokenizedQueryContent = "";
}
this.tokenizedQueryContent = tokenizedQueryContent;
this.lineClamp = a1;
}
}
export default SearchResultMessageParser;