Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F32167630
D10460.1765052858.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
7 KB
Referenced Files
None
Subscribers
None
D10460.1765052858.diff
View Options
diff --git a/lib/components/chat-mention-provider.react.js b/lib/components/chat-mention-provider.react.js
--- a/lib/components/chat-mention-provider.react.js
+++ b/lib/components/chat-mention-provider.react.js
@@ -7,12 +7,12 @@
import SentencePrefixSearchIndex from '../shared/sentence-prefix-search-index.js';
import { threadTypes } from '../types/thread-types-enum.js';
import type {
- ChatMentionCandidates,
ChatMentionCandidatesObj,
ResolvedThreadInfo,
ThreadInfo,
} from '../types/thread-types.js';
import { useResolvedThreadInfosObj } from '../utils/entity-helpers.js';
+import type { ThreadEntity } from '../utils/entity-text.js';
import { useSelector } from '../utils/redux-utils.js';
type Props = {
@@ -80,7 +80,7 @@
} {
const result: {
[string]: {
- [string]: ResolvedThreadInfo,
+ [string]: { ...ResolvedThreadInfo, rawChatName: string | ThreadEntity },
},
} = {};
const visitedGenesisThreads = new Set<string>();
@@ -98,8 +98,10 @@
}
if (!result[currentThreadCommunity]) {
result[currentThreadCommunity] = {};
- result[currentThreadCommunity][currentThreadCommunity] =
- resolvedThreadInfos[currentThreadCommunity];
+ result[currentThreadCommunity][currentThreadCommunity] = {
+ ...resolvedThreadInfos[currentThreadCommunity],
+ rawChatName: threadInfos[currentThreadCommunity].uiName,
+ };
}
// Handle GENESIS community case: mentioning inside GENESIS should only
// show chats and threads inside the top level that is below GENESIS.
@@ -146,7 +148,10 @@
result[lastThreadInTraversePath.id] = {};
}
for (const threadInfo of threadTraversePath) {
- result[lastThreadInTraversePath.id][threadInfo.id] = threadInfo;
+ result[lastThreadInTraversePath.id][threadInfo.id] = {
+ ...threadInfo,
+ rawChatName: threadInfos[threadInfo.id].uiName,
+ };
communityThreadIDForGenesisThreads[threadInfo.id] =
lastThreadInTraversePath.id;
}
@@ -154,8 +159,10 @@
lastThreadInTraversePath.type !== threadTypes.PERSONAL &&
lastThreadInTraversePath.type !== threadTypes.PRIVATE
) {
- result[genesis.id][lastThreadInTraversePath.id] =
- lastThreadInTraversePath;
+ result[genesis.id][lastThreadInTraversePath.id] = {
+ ...lastThreadInTraversePath,
+ rawChatName: threadInfos[lastThreadInTraversePath.id].uiName,
+ };
}
} else {
if (
@@ -170,14 +177,20 @@
for (const threadInfo of threadTraversePath) {
result[lastThreadInTraversePathParentCommunityThreadID][
threadInfo.id
- ] = threadInfo;
+ ] = {
+ ...threadInfo,
+ rawChatName: threadInfos[threadInfo.id].uiName,
+ };
communityThreadIDForGenesisThreads[threadInfo.id] =
lastThreadInTraversePathParentCommunityThreadID;
}
}
continue;
}
- result[currentThreadCommunity][currentThreadID] = currentResolvedThreadInfo;
+ result[currentThreadCommunity][currentThreadID] = {
+ ...currentResolvedThreadInfo,
+ rawChatName: threadInfos[currentThreadID].uiName,
+ };
}
return {
chatMentionCandidatesObj: result,
@@ -193,7 +206,7 @@
function useChatMentionCandidatesObjAndUtils(): {
chatMentionCandidatesObj: ChatMentionCandidatesObj,
- resolvedThreadInfos: ChatMentionCandidates,
+ resolvedThreadInfos: { +[id: string]: ResolvedThreadInfo },
communityThreadIDForGenesisThreads: { +[id: string]: string },
} {
const threadInfos = useSelector(threadInfoSelector);
diff --git a/lib/shared/markdown.js b/lib/shared/markdown.js
--- a/lib/shared/markdown.js
+++ b/lib/shared/markdown.js
@@ -289,13 +289,24 @@
content: string,
hasAccessToChat: boolean,
} {
- const threadInfo = chatMentionCandidates[capture[3]];
- const threadName = threadInfo?.uiName ?? decodeChatMentionText(capture[4]);
+ const chatCandidate = chatMentionCandidates[capture[3]];
+
+ let threadName;
+ let resolvedThreadInfo;
+
+ if (chatCandidate) {
+ const { rawChatName, ...threadInfo } = chatCandidate;
+ resolvedThreadInfo = threadInfo;
+ threadName = threadInfo.uiName;
+ } else {
+ threadName = decodeChatMentionText(capture[4]);
+ }
+
const content = `${capture[1]}@${threadName}`;
return {
- threadInfo,
+ threadInfo: resolvedThreadInfo,
content,
- hasAccessToChat: !!threadInfo,
+ hasAccessToChat: !!resolvedThreadInfo,
};
}
diff --git a/lib/shared/mention-utils.js b/lib/shared/mention-utils.js
--- a/lib/shared/mention-utils.js
+++ b/lib/shared/mention-utils.js
@@ -15,6 +15,7 @@
ThreadInfo,
ResolvedThreadInfo,
} from '../types/thread-types.js';
+import type { ThreadEntity } from '../utils/entity-text';
import { idSchemaRegex, chatNameMaxLength } from '../utils/validation-utils.js';
export type TypeaheadMatchedStrings = {
@@ -35,6 +36,7 @@
type MentionTypeaheadChatSuggestionItem = {
+type: 'chat',
+threadInfo: ResolvedThreadInfo,
+ +rawChatName: string | ThreadEntity,
};
export type MentionTypeaheadSuggestionItem =
@@ -153,9 +155,11 @@
if (!chatMentionCandidates[threadID]) {
continue;
}
+ const { rawChatName, ...threadInfo } = chatMentionCandidates[threadID];
result.push({
type: 'chat',
- threadInfo: chatMentionCandidates[threadID],
+ threadInfo,
+ rawChatName,
});
}
return result;
diff --git a/lib/types/thread-types.js b/lib/types/thread-types.js
--- a/lib/types/thread-types.js
+++ b/lib/types/thread-types.js
@@ -490,7 +490,7 @@
export type ThreadStoreThreadInfos = LegacyRawThreadInfos;
export type ChatMentionCandidates = {
- +[id: string]: ResolvedThreadInfo,
+ +[id: string]: { ...ResolvedThreadInfo, +rawChatName: string | ThreadEntity },
};
export type ChatMentionCandidatesObj = {
+[id: string]: ChatMentionCandidates,
diff --git a/native/utils/typeahead-utils.js b/native/utils/typeahead-utils.js
--- a/native/utils/typeahead-utils.js
+++ b/native/utils/typeahead-utils.js
@@ -92,7 +92,7 @@
},
});
} else if (suggestion.type === 'chat') {
- const { threadInfo } = suggestion;
+ const { rawChatName, threadInfo } = suggestion;
const mentionText = getRawChatMention(threadInfo);
actions.push({
key: threadInfo.id,
@@ -107,6 +107,7 @@
actionButtonContent: {
type: 'chat',
threadInfo,
+ rawChatName,
},
});
}
diff --git a/web/utils/typeahead-utils.js b/web/utils/typeahead-utils.js
--- a/web/utils/typeahead-utils.js
+++ b/web/utils/typeahead-utils.js
@@ -143,10 +143,10 @@
},
});
} else if (suggestion.type === 'chat') {
- const suggestedChat = suggestion.threadInfo;
- const mentionText = getRawChatMention(suggestedChat);
+ const { rawChatName, threadInfo } = suggestion;
+ const mentionText = getRawChatMention(threadInfo);
actions.push({
- key: suggestedChat.id,
+ key: threadInfo.id,
execute: () =>
mentionTypeaheadTooltipActionExecuteHandler({
textBeforeAtSymbol,
@@ -158,7 +158,8 @@
}),
actionButtonContent: {
type: 'chat',
- threadInfo: suggestedChat,
+ threadInfo,
+ rawChatName,
},
});
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Dec 6, 8:27 PM (14 h, 28 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5840635
Default Alt Text
D10460.1765052858.diff (7 KB)
Attached To
Mode
D10460: [lib/web/native] Update ChatMentionCandidates type to include a rawChatName
Attached
Detach File
Event Timeline
Log In to Comment