Skip to content

Commit

Permalink
fix: last item feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
rebelchris committed Feb 5, 2025
1 parent 0d93332 commit 04336aa
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import {
TypographyType,
} from '../../../typography/Typography';
import { PlusUser } from '../../../PlusUser';
import ConditionalWrapper from '../../../ConditionalWrapper';
import { SimpleTooltip } from '../../../tooltips';
import { LogEvent, Origin, TargetId } from '../../../../lib/log';
import { Button, ButtonSize, ButtonVariant } from '../../../buttons/Button';
import { plusUrl } from '../../../../lib/constants';
Expand All @@ -20,6 +18,8 @@ import { useSettingsContext } from '../../../../contexts/SettingsContext';
import { labels } from '../../../../lib';
import { useLogContext } from '../../../../contexts/LogContext';
import { useFeedSettingsEditContext } from '../FeedSettingsEditContext';
import { SimpleTooltip } from '../../../tooltips';
import ConditionalWrapper from '../../../ConditionalWrapper';

export const SmartPrompts = (): ReactElement => {
const { editFeedSettings } = useFeedSettingsEditContext();
Expand Down Expand Up @@ -54,39 +54,41 @@ export const SmartPrompts = (): ReactElement => {
of every post in one click.
</Typography>
</div>
<ConditionalWrapper
condition={!isPlus}
wrapper={(child) => {
return (
<SimpleTooltip
container={{
className: 'max-w-70 text-center typo-subhead',
}}
content="Upgrade to Plus to unlock Smart Prompts."
>
<div className="w-fit">{child as ReactElement}</div>
</SimpleTooltip>
);
}}
>
<div className="flex flex-col gap-2">
{prompts?.map(({ id, label, description }) => (

<div className="flex flex-col gap-2">
{prompts?.map(({ id, label, description }) => (
<ConditionalWrapper
condition={!isPlus}
key={`w-${id}`}
wrapper={(child) => {
return (
<SimpleTooltip
container={{
className: 'max-w-70 text-center typo-subhead',
}}
content="Upgrade to Plus to unlock Smart Prompts."
>
<div className="w-fit">{child as ReactElement}</div>
</SimpleTooltip>
);
}}
>
<FilterCheckbox
key={id}
name={`prompt-${id}`}
checked={promptFlags?.[id] ?? true}
description={description}
disabled={!isPlus}
onToggleCallback={() => {
const newState = !(promptFlags?.[id] || true);
const newState = !promptFlags?.[id] || false;
editFeedSettings(() => updatePromptFlag(id, newState));
displayToast(
labels.feed.settings.globalPreferenceNotice.smartPrompt,
);

logEvent({
event_name: LogEvent.ToggleSmartPrompts,
target_type: label,
target_type: id,
target_id: newState ? TargetId.On : TargetId.Off,
extra: JSON.stringify({
origin: Origin.Settings,
Expand All @@ -97,9 +99,9 @@ export const SmartPrompts = (): ReactElement => {
>
<Typography bold>{label}</Typography>
</FilterCheckbox>
))}
</div>
</ConditionalWrapper>
</ConditionalWrapper>
))}
</div>
{!isPlus && (
<Button
className="w-fit"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,16 @@ import { labels } from '../../../lib';
import { RenderMarkdown } from '../../RenderMarkdown';
import { CopyIcon, EditIcon } from '../../icons';
import { useCopyText } from '../../../hooks/useCopy';
import { postLogEvent } from '../../../lib/feed';
import { LogEvent } from '../../../lib/log';
import { useLogContext } from '../../../contexts/LogContext';

type CustomPromptProps = {
post: Post;
};

export const CustomPrompt = ({ post }: CustomPromptProps): ReactElement => {
const { logEvent } = useLogContext();
const { data: prompts } = usePromptsQuery();
const [isEdit, setIsEdit] = useState(false);
const [copying, copy] = useCopyText();
Expand All @@ -34,10 +38,15 @@ export const CustomPrompt = ({ post }: CustomPromptProps): ReactElement => {
const onSubmitCustomPrompt = useCallback(
(e) => {
e.preventDefault();
logEvent(
postLogEvent(LogEvent.SmartPrompt, post, {
extra: { prompt: 'custom-prompt' },
}),
);
setIsEdit(false);
executePrompt(e.target[0].value);
},
[executePrompt],
[executePrompt, logEvent, post],
);

if (!data || isEdit) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ export const PromptButtons = ({
</SimpleTooltip>
))}

{!showAll && !isMobile && promptList?.length > 0 && (
{!showAll && !isMobile && promptList?.length > 0 && remainingTags > 0 && (
<SimpleTooltip content="See more prompts">
<Button
variant={ButtonVariant.Subtle}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ export const SmartPrompt = ({ post }: { post: Post }): ReactElement => {
if (!triedSmartPrompts) {
completeAction(ActionType.SmartPrompt);
}
}

if (![PromptDisplay.CustomPrompt, PromptDisplay.TLDR].includes(prompt)) {
logEvent(
postLogEvent(LogEvent.SmartPrompt, post, {
extra: { prompt },
Expand Down

0 comments on commit 04336aa

Please sign in to comment.