+
Skip to content

Fix online presence values getting reset #2601

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

Merged
merged 1 commit into from
Jul 2, 2025
Merged

Conversation

TWilson023
Copy link
Collaborator

@TWilson023 TWilson023 commented Jul 2, 2025

Summary by CodeRabbit

  • Bug Fixes

    • Improved handling of missing social media handles and website URLs, ensuring that undefined values remain unchanged instead of being processed.
    • Relaxed validation rules by no longer requiring at least one social platform handle to be provided.
  • Chores

    • Updated validation logic for online presence updates to enhance data consistency.

@TWilson023 TWilson023 requested a review from steven-tey July 2, 2025 19:53
Copy link

vercel bot commented Jul 2, 2025

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

Name Status Preview Updated (UTC)
dub ✅ Ready (Inspect) Visit Preview Jul 2, 2025 8:05pm

Copy link
Contributor

coderabbitai bot commented Jul 2, 2025

Walkthrough

The transformation logic for social media handles and website URLs in the updateOnlinePresenceSchema was updated to preserve undefined values rather than processing them. Additionally, the schema's requirement for at least one social platform handle was removed, leaving only website URL format validation if provided.

Changes

File(s) Change Summary
apps/web/lib/actions/partners/update-online-presence.ts Updated transformation functions to return undefined for undefined input; removed social handle presence refinement.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant updateOnlinePresenceAction
    participant updateOnlinePresenceSchema

    User->>updateOnlinePresenceAction: Submit online presence update
    updateOnlinePresenceAction->>updateOnlinePresenceSchema: Validate input
    updateOnlinePresenceSchema-->>updateOnlinePresenceAction: Transform fields (preserve undefined, validate website)
    updateOnlinePresenceAction-->>User: Return response
Loading

Possibly related PRs

Poem

A schema refined, with care and intent,
Now leaves undefined just as it went.
No more must handles be always supplied,
Website checked, but rules simplified.
In the garden of code, such gentle change—
A rabbit hops on, within schema's range! 🐇

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Comment on lines -59 to -72
)
.refine(
(data) => {
return (
data.youtube ||
data.twitter ||
data.linkedin ||
data.instagram ||
data.tiktok
);
},
{
message: "At least one social platform is required.",
},
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't think this is necessary, e.g. a partner should be able to clear out all values or update the website without adding any socials

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
apps/web/lib/actions/partners/update-online-presence.ts (1)

44-48: Minor formatting inconsistency.

The Instagram transform uses multi-line formatting while others use single-line. Consider using consistent formatting for better readability.

-    .transform((input) =>
-      input === undefined
-        ? undefined
-        : sanitizeSocialHandle(input, "instagram"),
-    ),
+    .transform((input) =>
+      input === undefined ? undefined : sanitizeSocialHandle(input, "instagram"),
+    ),
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0c5f6b4 and a862077.

📒 Files selected for processing (1)
  • apps/web/lib/actions/partners/update-online-presence.ts (2 hunks)
🧰 Additional context used
🧠 Learnings (1)
apps/web/lib/actions/partners/update-online-presence.ts (1)
Learnt from: devkiran
PR: dubinc/dub#2177
File: apps/web/lib/api/links/bulk-create-links.ts:66-84
Timestamp: 2025-06-06T07:59:03.120Z
Learning: In apps/web/lib/api/links/bulk-create-links.ts, the team accepts the risk of potential undefined results from links.find() operations when building invalidLinks arrays, because existing links are fetched from the database based on the input links, so matches are expected to always exist.
🧬 Code Graph Analysis (1)
apps/web/lib/actions/partners/update-online-presence.ts (1)
apps/web/lib/social-utils.ts (2)
  • sanitizeWebsite (48-64)
  • sanitizeSocialHandle (66-102)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build
🔇 Additional comments (3)
apps/web/lib/actions/partners/update-online-presence.ts (3)

18-22: LGTM! Correctly preserves undefined values.

The transform logic now prevents undefined values from being processed by sanitizeWebsite, which is crucial for the conditional spreading logic in the action that depends on undefined checks.


26-28: LGTM! Consistent transform pattern for social handles.

All social media transforms correctly preserve undefined values using the same pattern, preventing unintended field resets.

Also applies to: 32-34, 38-40, 52-54


67-74: LGTM! Simplified schema refinement appropriately.

Removing the requirement for at least one social platform handle aligns with the goal of allowing partial updates without resetting values. The website URL validation is retained appropriately.

@TWilson023 TWilson023 added this pull request to the merge queue Jul 2, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jul 2, 2025
@TWilson023 TWilson023 added this pull request to the merge queue Jul 2, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jul 2, 2025
@steven-tey steven-tey merged commit eb3e244 into main Jul 2, 2025
9 checks passed
@steven-tey steven-tey deleted the online-presence-fix branch July 2, 2025 20:55
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.

2 participants
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载