Skip to content

Commit

Permalink
fix at mentions, for real
Browse files Browse the repository at this point in the history
  • Loading branch information
hellno committed Sep 7, 2023
1 parent f3d9301 commit dbfc577
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/common/components/CastRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ interface CastRowProps {
}

export const CastRow = ({ cast, isSelected, showChannel, onSelect, channels, showEmbed, isThreadView = false }: CastRowProps) => {
if (isSelected) console.log(cast);
// if (isSelected) console.log(cast);

const { accounts, selectedAccountIdx } = useAccountStore();
const [didLike, setDidLike] = useState(false)
Expand Down
2 changes: 1 addition & 1 deletion src/common/components/CastThreadView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export const CastThreadView = ({ cast, onBack, fid, isActive }: CastThreadViewPr
addNewPostDraft({ parentCastId: { hash: cast.hash, fid: cast.author.fid } })

return () => {
console.log('exit thread view')
// console.log('exit thread view')
removePostDraft(draftIdx, true)
}
}, [cast.hash])
Expand Down
4 changes: 2 additions & 2 deletions src/common/components/FarcasterLogin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ const FarcasterLogin = () => {
}, [runPolling])

const onCreateNewAccount = async () => {
console.log('onCreateNewAccount', accountName);
// console.log('onCreateNewAccount', accountName);
if (!accountName) {
setErrorMessage('Account name is required');
return;
Expand All @@ -89,7 +89,7 @@ const FarcasterLogin = () => {
setIsLoading(true);

const { publicKey, privateKey, token, deeplinkUrl } = await generateWarpcastSigner();
console.log('onCreateNewAccount', publicKey, token, deeplinkUrl);
// console.log('onCreateNewAccount', publicKey, token, deeplinkUrl);

try {
addAccount({
Expand Down
6 changes: 4 additions & 2 deletions src/common/helpers/farcaster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ export const convertEditorCastToPublishableCast = async (draft: DraftType): Prom

const mentionRegex = /\s?@(\S+)/g;
let match;
let idxReducedByPreviousMentions = 0;

while ((match = mentionRegex.exec(text)) != null) {
// match contains [@username, username]
const casterUsername = match[1];
Expand All @@ -47,13 +49,13 @@ export const convertEditorCastToPublishableCast = async (draft: DraftType): Prom
console.log(err);
continue;
}

cast = {
...cast,
text: cast.text.replace(match[0], ''),
mentions: [...cast.mentions, Number(fid)],
mentionsPositions: [...cast.mentionsPositions, match.index]
mentionsPositions: [...cast.mentionsPositions, match.index - idxReducedByPreviousMentions]
}
idxReducedByPreviousMentions += match[0].length;
}

if (!isEmpty(draft.parentCastId)) {
Expand Down
2 changes: 1 addition & 1 deletion src/stores/useNewPostStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ const store = (set: StoreSet) => ({
try {
state.updatePostDraft(draftIdx, { ...draft, status: DraftStatus.publishing });
const castBody = await Promise.resolve(convertEditorCastToPublishableCast(draft));
// console.log('publishPostdraft castBody', castBody)
console.log('publishPostdraft castBody', castBody)
await Promise.resolve(
publishCast({
castBody,
Expand Down

0 comments on commit dbfc577

Please sign in to comment.