Skip to content
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

feat: add support for highlight.new #1487

Merged
merged 8 commits into from
Aug 8, 2023
Merged

feat: add support for highlight.new #1487

merged 8 commits into from
Aug 8, 2023

Conversation

diivi
Copy link
Contributor

@diivi diivi commented Aug 4, 2023

Description

Fixes #1079

added a ?new=true query param that auto clicks and focuses on the highlight creation form so the user can create a highlight.

What type of PR is this? (check all applicable)

  • 🍕 Feature
  • 🐛 Bug Fix
  • 📝 Documentation Update
  • 🎨 Style
  • 🧑‍💻 Code Refactor
  • 🔥 Performance Improvements
  • ✅ Test
  • 🤖 Build
  • 🔁 CI
  • 📦 Chore (Release)
  • ⏩ Revert

Related Tickets & Documents

#1079

Mobile & Desktop Screenshots/Recordings

Peek 2023-08-05 00-46

Added tests?

  • 👍 yes
  • 🙅 no, because they aren't needed
  • 🙋 no, because I need help

Added to documentation?

  • 📜 README.md
  • 📓 docs.opensauced.pizza
  • 🍕 dev.to/opensauced
  • 📕 storybook
  • 🙅 no documentation needed

[optional] Are there any post-deployment tasks we need to perform?

[optional] What gif best describes this PR or how it makes you feel?

@netlify
Copy link

netlify bot commented Aug 4, 2023

Deploy Preview for design-insights ready!

Name Link
🔨 Latest commit e4e4daf
🔍 Latest deploy log https://app.netlify.com/sites/design-insights/deploys/64d252c1d60784000862377e
😎 Deploy Preview https://deploy-preview-1487--design-insights.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@netlify
Copy link

netlify bot commented Aug 4, 2023

Deploy Preview for oss-insights ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit e4e4daf
🔍 Latest deploy log https://app.netlify.com/sites/oss-insights/deploys/64d252c1777b2d00080496ce
😎 Deploy Preview https://deploy-preview-1487--oss-insights.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@diivi diivi requested review from brandonroberts and bdougie August 4, 2023 19:18
@bdougie
Copy link
Member

bdougie commented Aug 4, 2023

@diivi visiting this link https://deploy-preview-1487--oss-insights.netlify.app/feed?new=true does not force a login currently. It works otherwise

@diivi
Copy link
Contributor Author

diivi commented Aug 4, 2023

Checking if a user is logged in is proving to be harder than I thought :/

Using this code is not working for some reason, I might need more context, as in where I can check if a user is logged in or not

  useEffect(() => {
    const queryParams = new URLSearchParams(window.location.search);
    const newHighlight = queryParams.get("new");

    const checkUserAuth = async () => {
      const sessionData = await loadSession();
      console.log(sessionData)
      // if (newHighlight && !sessionData) {
      //   signIn({ provider: "github", options: { redirectTo: `${window.location.href}` } });
      // }
    };
    void checkUserAuth();

    const focusOnHighlighCreationInput = setInterval(() => {
      const highlightCreationInput = document.getElementById("highlight-create-input");
      if (newHighlight && highlightCreationInput) {
        highlightCreationInput.click();
        highlightCreationInput.focus();
        clearInterval(focusOnHighlighCreationInput);
      }
    }, 1000);

    return () => {
      clearInterval(focusOnHighlighCreationInput);
    };
  }, []);

Running this logs false to the console even when I'm logged in.

@bdougie
Copy link
Member

bdougie commented Aug 4, 2023

@diivi
Copy link
Contributor Author

diivi commented Aug 4, 2023

update: Does this help @diivi?

https://github.com/open-sauced/insights/blob/0cedccc612c5080df3552e9d62580c540a4ac9c9/pages/hub/insights/new.tsx#L11

I checked that, yes.
But this ended up being a little more complex than expected lol. The end solution finally works though.

lib/hooks/useSession.ts Outdated Show resolved Hide resolved
@bdougie
Copy link
Member

bdougie commented Aug 5, 2023

Mobile needs the same treatment

image

Copy link
Contributor

@babblebey babblebey left a comment

Choose a reason for hiding this comment

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

Hey @diivi, I'd suggest we use next/router over here, considering its usage is already established... It should save the extra steps in instantiating the URLSearchParams multiple times.

Kindly note, I am just thinking out loud with the below suggestions, if there's a reason why you chose to use the URLSearchParams api, I'm curious to know.

pages/feed/index.tsx Show resolved Hide resolved
pages/feed/index.tsx Show resolved Hide resolved
pages/feed/index.tsx Show resolved Hide resolved
pages/feed/index.tsx Show resolved Hide resolved
@diivi
Copy link
Contributor Author

diivi commented Aug 5, 2023

I'm aware of router.query, but it didn't work when I started development for this PR, so I moved to the browser based solution. I think it was due to race conditions (had some trouble with these on this PR).

If router.query works, I'll use that.

@diivi
Copy link
Contributor Author

diivi commented Aug 5, 2023

The mobile form should now open up automatically when ?new=true

pages/feed/index.tsx Outdated Show resolved Hide resolved
pages/feed/index.tsx Show resolved Hide resolved
Copy link
Contributor

@brandonroberts brandonroberts left a comment

Choose a reason for hiding this comment

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

It works. Question about the delay time

@brandonroberts
Copy link
Contributor

@diivi nevermind on the delay. This will continue to check on the interval

@brandonroberts brandonroberts merged commit 3daa5c0 into open-sauced:beta Aug 8, 2023
open-sauced bot pushed a commit that referenced this pull request Aug 8, 2023
## [1.59.0-beta.8](v1.59.0-beta.7...v1.59.0-beta.8) (2023-08-08)

### 🍕 Features

* add support for highlight.new ([#1487](#1487)) ([3daa5c0](3daa5c0))
* improved the UX on the feeds page and scroll behaviour ([#1506](#1506)) ([31c1593](31c1593))
open-sauced bot pushed a commit that referenced this pull request Aug 8, 2023
## [1.59.0](v1.58.0...v1.59.0) (2023-08-08)

### 🧑‍💻 Code Refactoring

* replace supabase/ui in design system typography components ([#1438](#1438)) ([38cfb30](38cfb30))

### 🍕 Features

* add a user notifications page ([#1478](#1478)) ([022dc69](022dc69))
* add conditional routing to single highlight dialog close action ([#1473](#1473)) ([1341cba](1341cba))
* add github link to profile ([#1459](#1459)) ([d42bc6d](d42bc6d))
* add support for highlight.new ([#1487](#1487)) ([3daa5c0](3daa5c0))
* improved the UX on the feeds page and scroll behaviour ([#1506](#1506)) ([31c1593](31c1593))
* onboarding auto fetch timezone ([#1488](#1488)) ([ae5cdd7](ae5cdd7))

### 🐛 Bug Fixes

* Feed page responsiveness  ([#1490](#1490)) ([67662b2](67662b2))
* feeds page typography and styles improvements ([#1467](#1467)) ([a3b289e](a3b289e))
* on page reload Insights page redirecting to Dashboard ([#1517](#1517)) ([397c36e](397c36e))
* update environment variable for Sentry ([#1521](#1521)) ([56ac14b](56ac14b))
* update release workflow to use GitHub app for semantic versioning ([#1484](#1484)) ([3f1ce84](3f1ce84))
* update user interest logo error for machine learning ([#1474](#1474)) ([a286eda](a286eda))
* uses session to update user info for notifications check ([#1486](#1486)) ([60d787e](60d787e))
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.

Feature: highlight.new path
4 participants