-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Mentions v2] Support mentions in editing comments #40565
Merged
rlinoz
merged 21 commits into
Expensify:main
from
software-mansion-labs:mention-editing
Jun 14, 2024
Merged
Changes from 20 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
f7275e0
introduce OnyxAwareParser
robertKozik 959af6b
Merge branch 'refs/heads/main' into mention-editing
war-in 7b3fe65
`parser.htmlTo` -> `parseHtmlTo`
war-in baf2a8c
add fallback when displayName does not exist
war-in 63a7098
bring back removed trim
war-in 94e4adf
Merge branch 'refs/heads/main' into mention-editing
war-in de7ddaf
Merge branch 'refs/heads/main' into mention-editing
war-in 8daba9d
update expensify-common
war-in d2bb72f
Merge branch 'refs/heads/main' into mention-editing
war-in 1f08080
Merge branch 'refs/heads/main' into mention-editing
war-in 46a1f6e
fix failing typecheck
war-in 1828050
Merge branch 'refs/heads/main' into mention-editing
war-in 2dc7236
Merge branch 'refs/heads/main' into mention-editing
war-in 98c0acf
remove leftovers
war-in dafa5a4
replace htmlToText in `OptionRowLHN`
war-in 6bac08a
Merge branch 'refs/heads/main' into mention-editing
war-in 01aa522
Merge remote-tracking branch 'refs/remotes/origin/main' into mention-…
war-in a8fbfa6
use `personalDetails.login` as account name
war-in 5132b5c
Merge branch 'refs/heads/main' into mention-editing
war-in f0b59c0
allow passing custom extras to OnyxAwareParser
war-in 8846545
Merge branch 'refs/heads/main' into mention-editing
war-in File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import {ExpensiMark} from 'expensify-common'; | ||
import Onyx from 'react-native-onyx'; | ||
import ONYXKEYS from '@src/ONYXKEYS'; | ||
|
||
const parser = new ExpensiMark(); | ||
|
||
const reportIDToNameMap: Record<string, string> = {}; | ||
const accountIDToNameMap: Record<string, string> = {}; | ||
|
||
Onyx.connect({ | ||
key: ONYXKEYS.COLLECTION.REPORT, | ||
callback: (report) => { | ||
if (!report) { | ||
return; | ||
} | ||
|
||
reportIDToNameMap[report.reportID] = report.reportName ?? report.displayName ?? report.reportID; | ||
}, | ||
}); | ||
|
||
Onyx.connect({ | ||
key: ONYXKEYS.PERSONAL_DETAILS_LIST, | ||
callback: (personalDetailsList) => { | ||
Object.values(personalDetailsList ?? {}).forEach((personalDetails) => { | ||
if (!personalDetails) { | ||
return; | ||
} | ||
|
||
accountIDToNameMap[personalDetails.accountID] = personalDetails.login ?? String(personalDetails.accountID); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It doesn't make sense to use accountID as fallback. |
||
}); | ||
}, | ||
}); | ||
|
||
function parseHtmlToMarkdown(html: string, reportIDToName?: Record<string, string>, accountIDToName?: Record<string, string>): string { | ||
return parser.htmlToMarkdown(html, {reportIDToName: reportIDToName ?? reportIDToNameMap, accountIDToName: accountIDToName ?? accountIDToNameMap}); | ||
} | ||
|
||
function parseHtmlToText(html: string, reportIDToName?: Record<string, string>, accountIDToName?: Record<string, string>): string { | ||
return parser.htmlToText(html, {reportIDToName: reportIDToName ?? reportIDToNameMap, accountIDToName: accountIDToName ?? accountIDToNameMap}); | ||
} | ||
|
||
export {parseHtmlToMarkdown, parseHtmlToText}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if we should fallback to id, but we did it before so should be fine
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think it makes sense to fallback to reportID. And if we would prefer reportID to empty string
""
, then we can use logical OR||
and add comment to disable lint checkThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of curiosity, do you know when
displayName
is filled?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tbh I don't know 😅 It's useful for the users but I'm not sure about the rooms