Skip to content

feat: boosted post as ad#4613

Merged
sshanzel merged 45 commits into
MI-888from
MI-888-ad
Jul 2, 2025
Merged

feat: boosted post as ad#4613
sshanzel merged 45 commits into
MI-888from
MI-888-ad

Conversation

@sshanzel
Copy link
Copy Markdown
Contributor

@sshanzel sshanzel commented Jun 23, 2025

Changes

  • Integration of mutations and queries to be connected to the actual elements.

Events

Did you introduce any new tracking events?

Experiment

Did you introduce any new experiments?

Manual Testing

Caution

Please make sure existing components are not breaking/affected by this PR

Jira ticket

MI-888

Preview domain

https://mi-888-ad.preview.app.daily.dev

@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 23, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
daily-webapp ✅ Ready (Inspect) Visit Preview Jul 2, 2025 1:43pm
1 Skipped Deployment
Name Status Preview Updated (UTC)
storybook ⬜️ Ignored (Inspect) Jul 2, 2025 1:43pm

Comment on lines +1 to +12
import { createContext, useContext } from 'react';

interface FeedCardContextData {
isBoostedReach: boolean;
}

export const FeedCardContext = createContext<FeedCardContextData>({
isBoostedReach: false,
});

export const useFeedCardContext = (): FeedCardContextData =>
useContext(FeedCardContext);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the createContextProvider from @kickass-coderz/react to generate both of these in single function.
See https://github.com/dailydotdev/apps/blob/546082bd6fe3954747909b8bfe4593a8430792db/packages/shared/src/contexts/search/SearchContext.tsx

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait let me check quickly.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is, I don't need a managed state, I just need to pass down some values.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's just a wrapper of useContext, but easier to use.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried it, but didn't work for me 😢

It was not allowing me to pass props down to the provider that was generated.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is always that one guy moment (a guy that uses interface :lolsob:).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hahaha

Copy link
Copy Markdown
Contributor Author

@sshanzel sshanzel Jun 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@capJavert is there a way to set a default value? Unfortunately, I had to revert at the moment because the areas where I am trying to pull the context break. We need to have a way to set a default value of the Context for when the provider is not present.

I'd be glad to raise another PR for this 😉

Tests with the util:
https://app.circleci.com/pipelines/github/dailydotdev/apps/27367/workflows/03d8b707-2836-43f1-990d-7e008dfc66ce/jobs/93218

After revert is what we have now.

Commit:
720efbd

Copy link
Copy Markdown
Contributor

@capJavert capJavert Jun 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Throwing when there is not context is by design. Yeah if it does not fit feel free to do it by hand. I'll look if we can add support for it.

Copy link
Copy Markdown
Contributor Author

@sshanzel sshanzel Jun 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see. I mean it makes sense if the consuming end strictly needs proper values.

Copy link
Copy Markdown
Member

@nimrodkra nimrodkra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

look great :P

Copy link
Copy Markdown
Contributor

@rebelchris rebelchris left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think we need to move this context file out of this folder :)

isBoostedReach: boolean;
};

export const FeedCardContext = createContext<FeedCardContextData>({
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But then let's move it out of the boost feature folder?
And just make it value <Optional> no?

const { mutateAsync: onCancelBoost } = useMutation({
mutationFn: cancelPostBoost,
onSuccess: async () => {
await client.invalidateQueries({
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So much invalidation can't we do it optimistic?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't because this involves integration with another service that requires value from there.

Comment thread packages/shared/src/hooks/useFeed.ts Outdated
index: adPage,
updatedAt: adsUpdatedAt,
};
// TODO: remove this once integration comes in
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be removed now?

@sshanzel sshanzel merged commit 8f4ba74 into MI-888 Jul 2, 2025
10 checks passed
@sshanzel sshanzel deleted the MI-888-ad branch July 2, 2025 13:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants