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: web notification #147

Merged
merged 23 commits into from
Feb 10, 2022
Merged

feat: web notification #147

merged 23 commits into from
Feb 10, 2022

Conversation

devrsi0n
Copy link
Owner

@devrsi0n devrsi0n commented Jan 29, 2022

Description

Web notification based on web-push

Related Issue

Fixed #134

Motivation and Context

How Has This Been Tested?

Screenshots (if appropriate):

Ask user for permission:
image

Notification permission popup (Only shows up if user agrees):
image

Notification example:
image

Notify user a new service worker is available:
image

Checklist

  • Unit tests and integration tests passed
  • No reduction in test coverage
  • Documentation is up to date (if appropriate)
  • Related issues linked using fixes #number

@vercel
Copy link

vercel bot commented Jan 29, 2022

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/devrsi0n/chirpy/88YSzp2ANEghkqBFvR2baZpnLKNK
✅ Preview: https://chirpy-git-feat-web-notification-devrsi0n.vercel.app

@devrsi0n
Copy link
Owner Author

devrsi0n commented Jan 29, 2022

@github-actions
Copy link
Contributor

github-actions bot commented Jan 29, 2022

jest coverage report 🧪

Total coverage

Status Category Percentage Covered / Total
🟡 Statements 26.57% (-2.41% 🔻) 839/3157
🔴 Branches 21.72% (-1.47% 🔻) 456/2099
🔴 Functions 24.89% (-1.92% 🔻) 247/992
🟡 Lines 26.66% (-2.4% 🔻) 819/3071

Status of coverage: 🟢 - ok, 🟡 - slightly more than threshold, 🔴 - under the threshold

Show new covered files 🌑

Coverage of new files

Status Filename Statements Branches Functions Lines
🟢 external/bootstrapper/comment 62.22% 26.08% 60% 61.36%
🔴 external/sw 0% 0% 0% 0%
🔴 pages/api/notification 0% 100% 100% 0%
🔴 server/gql 0% 0% 0% 0%
🔴 like.ts 0% 0% 0% 0%
🔴 notification.ts 0% 0% 0% 0%
🔴 server/services/notification 0% 0% 0% 0%
🔴 register.ts 0% 0% 0% 0%
🔴 send.ts 0% 0% 0% 0%
🔴 string.ts 0% 100% 0% 0%

Status of coverage: 🟢 - ok, 🟡 - slightly more than threshold, 🔴 - under the threshold

Show files with reduced coverage 🔻

Reduced coverage

Status Filename Statements Branches Functions Lines
🟢 components/toast 69.44% (-4.08% 🔻) 58.33% (-4.17% 🔻) 50% (-3.33% 🔻) 71.87% (-4.79% 🔻)
🔴 utilities.ts 0% (-93.75% 🔻) 0% (-69.23% 🔻) 0% (-100% 🔻) 0% (-93.75% 🔻)
🔴 comment.ts 0% 0% 0% (-100% 🔻) 0%
🟡 hooks 37.11% 30.61% 45% 36.77%
🔴 server/utilities 8.33% 0% 0% 8.33%
🔴 response.ts 0% 0% (-100% 🔻) 0% 0%
🟢 utilities 66.66% (-28.34% 🔻) 54.54% 83.33% (-16.67% 🔻) 68% (-26.44% 🔻)

Status of coverage: 🟢 - ok, 🟡 - slightly more than threshold, 🔴 - under the threshold

@cypress
Copy link

cypress bot commented Jan 29, 2022



Test summary

7 0 0 0


Run details

Project chirpy
Status Passed
Commit 2664175
Started Feb 10, 2022 1:13 PM
Ended Feb 10, 2022 1:14 PM
Duration 01:09 💡
OS Linux Ubuntu - 20.04
Browser Electron 94

View run in Cypress Dashboard ➡️


This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard

@github-actions
Copy link
Contributor

github-actions bot commented Jan 29, 2022

📦 Next.js Bundle Analysis

This analysis was generated by the next.js bundle analysis action 🤖

⚠️ Global Bundle Size Increased

Page Size (compressed)
global 161.02 KB (🟡 +1.19 KB)
Details

The global bundle is the javascript bundle that loads alongside every page. It is in its own category because its impact is much higher - an increase to its size means that every page on your website loads slower, and a decrease means every page loads faster.

Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis

If you want further insight into what is behind the changes, give @next/bundle-analyzer a try!

Eighteen Pages Changed Size

The following pages changed size from the code in this PR compared to its base branch:

Page Size (compressed) First Load % of Budget (250 KB)
/ 25.91 KB 186.93 KB 74.77% (+/- <0.01%)
/404 24.15 KB 185.17 KB 74.07% (🟢 -0.01%)
/500 23.05 KB 184.07 KB 73.63% (🟢 -0.01%)
/analytics/[domain] 23.22 KB 184.24 KB 73.70% (🟢 -0.01%)
/auth/delete-confirmation 22.57 KB 183.59 KB 73.44% (🟢 -0.01%)
/auth/redirecting 22.79 KB 183.81 KB 73.53% (🟢 -0.01%)
/auth/sign-in 24.14 KB 185.16 KB 74.06% (+/- <0.01%)
/auth/welcome 30.06 KB 191.08 KB 76.43% (🟢 -0.05%)
/blog 26.65 KB 187.67 KB 75.07% (🟢 -0.01%)
/blog/[...slug] 29.53 KB 190.55 KB 76.22% (+/- <0.01%)
/dashboard 39.9 KB 200.92 KB 80.37% (🟢 -0.06%)
/docs/[[...slug]] 26.65 KB 187.67 KB 75.07% (🟢 -0.01%)
/privacy-policy 25.4 KB 186.42 KB 74.57% (🟢 -0.01%)
/profile 32.2 KB 193.22 KB 77.29% (🟢 -0.06%)
/terms-of-service 25.39 KB 186.41 KB 74.56% (+/- <0.01%)
/theme/[domain] 159 KB 320.01 KB 128.01% (🔴 +44.98%)
/widget/comment/[pageURL] 150.68 KB 311.69 KB 124.68% (🔴 +44.68%)
/widget/comment/details/[commentId] 150.3 KB 311.32 KB 124.53% (🔴 +44.63%)
Details

Only the gzipped size is provided here based on an expert tip.

First Load is the size of the global bundle plus the bundle for the individual page. If a user were to show up to your website and land on a given page, the first load size represents the amount of javascript that user would need to download. If next/link is used, subsequent page loads would only need to download that page's bundle (the number in the "Size" column), since the global bundle has already been downloaded.

Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis

The "Budget %" column shows what percentage of your performance budget the First Load total takes up. For example, if your budget was 100kb, and a given page's first load size was 10kb, it would be 10% of your budget. You can also see how much this has increased or decreased compared to the base branch of your PR. If this percentage has increased by 10% or more, there will be a red status indicator applied, indicating that special attention should be given to this. If you see "+/- <0.01%" it means that there was a change in bundle size, but it is a trivial enough amount that it can be ignored.

@devrsi0n devrsi0n marked this pull request as ready for review February 5, 2022 09:23
@devrsi0n devrsi0n changed the title [WIP]feat: web notification feat: web notification Feb 5, 2022
const buttonChildren = (
<>
{isLoading ? <Loader tw="animate-spin w-5 h-5" /> : <Send size="14" />}
<span>{'Post'}</span>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Post is a constant, delete {' '} better

Copy link
Owner Author

Choose a reason for hiding this comment

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

Yes

devrsi0n added a commit that referenced this pull request Feb 26, 2022
* fix(deps): update dependency framer-motion to v6.2.4 (#165)

Co-authored-by: Renovate Bot <bot@renovateapp.com>

* feat: web notification (#147)

* feat: web notification

* feat: send message with a test request

* feat: set up mutation event

* feat: send notification to site owner

* fix: window is undefined

* feat: add title and icon to notification

* feat: focus on existing tab or open a new tab after click a notification

* feat: add body to notification

* fix: refactor the sw

* feat: only register notification when user is posting

* feat: add a popover to ask user notification permission

* fix: delete notification subscription

* feat: add a toast to notify user a new service worker is available

* feat: add notification of reply

* feat: save like notificatioin

* fix: delete like notification failed

* feat: add comment deleted notificatioin

* fix: prettier is not working

* feat: delete the existing comment after deleted a comment

* fix: build error

* fix: ut error

* fix: cypress error

* docs: update progress

* fix: should redirect to previous page after logging in (#172)

* fix: fix bug Footer should be sticky to the bottom

* fix: fix bug Footer should be sticky to the bottom

* fix: fix bug should redirect to previous page after logging in

* fix: change sessionStorage name

* fix: change

* fix: change sessionStorage and localSession key

* fix: sessionStorage bugfix

Co-authored-by: 吴兴利 <xinglee@Xinglees-MacBook-Pro.local>

* refactor: use next-auth callback url  (#174)

* fix: use next-auth callback url

* fix: remove stale comment

* fix: update comment

* fix: remove a duplicated environment variable

* fix: remove comment script url on blog page

* fix: add notification type seed

* feat: add environment badges (#179)

* chore(deps): update dependency superjson to 1.8.1 [security] (#178)

Co-authored-by: Renovate Bot <bot@renovateapp.com>

* fix(deps): update dependency type-fest to v2.11.2 (#166)

Co-authored-by: Renovate Bot <bot@renovateapp.com>

* Polish web notification (#181)

* fix: polish favicon

* fix: don't show popup if user deny the notification permission

* feat: add a playground page for testing

* fix: remove unused variables

* fix(deps): update tiptap packages (#167)

Co-authored-by: Renovate Bot <bot@renovateapp.com>
Co-authored-by: Qing <7880675+devrsi0n@users.noreply.github.com>

* fix: polish favicon (#183)

* fix(deps): update dependency urql to v2.1.3 (#171)

* Fix: database schema migration (#186)

* fix: migrate database

* fix: squash notification database schema

* fix: remove alter

* feat: add hasura ci/cd github action

* Feat: use on-demand ISR and use middleware to protect API and pages (#188)

* fix: prepare for next-auth middleware

* fix: use middleware to check the authorized

* fix: use next-auth middleware to protect pages

* feat: use ondemand revalidate when hasura events happening

* fix: enable swc minify

* fix: squash schema

* fix: cypress test

* fix: missing env

* chore: polish readme image

* fix: cypress index page

* fix: cypress test failed

* fix: cypress test failed (#192)

* fix: hasura ci target branch

* fix: cypress error

* fix: test error (#195)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Renovate Bot <bot@renovateapp.com>
Co-authored-by: Xinglee23 <xinglee23@outlook.com>
Co-authored-by: 吴兴利 <xinglee@Xinglees-MacBook-Pro.local>
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.

Notification
2 participants