Skip to content

Commit be7b103

Browse files
authored
Merge pull request #123 from medyo/feat/onboarding
Implement the onboarding feature
2 parents 38a3dba + 6968945 commit be7b103

30 files changed

Lines changed: 1166 additions & 441 deletions

File tree

.github/workflows/distribute.yml

Lines changed: 32 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -26,29 +26,6 @@ env:
2626
REACT_APP_BUILD_TARGET: 'extension'
2727

2828
jobs:
29-
install-dependencies:
30-
needs: tag_version
31-
runs-on: ubuntu-latest
32-
steps:
33-
- uses: actions/checkout@v2
34-
with:
35-
ref: master
36-
- uses: actions/cache@v2
37-
with:
38-
path: '**/node_modules'
39-
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
40-
- name: Install yarn dependencies
41-
run: yarn
42-
- name: Build and zip the extension
43-
run: |
44-
echo version=${{ steps.tag_version.outputs.new_version }}
45-
if [ ${{github.event.inputs.targetStore}} == 'chrome' ] || [ ${{github.event.inputs.targetStore}} == 'all' ]; then
46-
yarn build-chrome
47-
fi
48-
if [ ${{github.event.inputs.targetStore}} == 'firefox' ] || [ ${{github.event.inputs.targetStore}} == 'all' ]; then
49-
yarn build-firefox
50-
fi
51-
5229
tag_version:
5330
runs-on: ubuntu-latest
5431
steps:
@@ -58,7 +35,7 @@ jobs:
5835
uses: mathieudutour/github-tag-action@v6.1
5936
with:
6037
github_token: ${{ secrets.GITHUB_TOKEN }}
61-
dry_run: ${{ github.event.inputs.testMode == 'true' }}
38+
dry_run: ${{ github.event.inputs.autoTag == 'false' }}
6239

6340
- name: Update manifest.json
6441
if: github.event.inputs.autoTag == 'true'
@@ -75,9 +52,22 @@ jobs:
7552

7653
chrome-deploy:
7754
if: ${{ (github.event.inputs.targetStore == 'chrome') || (github.event.inputs.targetStore == 'all') }}
78-
needs: install-dependencies
55+
needs: tag_version
7956
runs-on: ubuntu-latest
80-
steps:
57+
steps:
58+
- uses: actions/checkout@v2
59+
with:
60+
ref: master
61+
- uses: actions/cache@v2
62+
with:
63+
path: '**/node_modules'
64+
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
65+
- name: Install yarn dependencies
66+
run: yarn
67+
68+
- name: Build and zip the extension
69+
run: yarn build-chrome
70+
8171
- name: Install chrome dependencies
8272
run: yarn global add chrome-webstore-upload-cli
8373

@@ -87,13 +77,27 @@ jobs:
8777
EXTENSION_ID: ${{ secrets.CHROME_EXTENSION_ID }}
8878
CLIENT_ID: ${{secrets.CHROME_EXTENSION_CLIENT_ID}}
8979
REFRESH_TOKEN: ${{secrets.CHROME_EXTENSION_REFRESH_TOKEN}}
90-
run: chrome-webstore-upload upload --source dist/chrome_extension.zip --extension-id $EXTENSION_ID --auto-publish
80+
CLIENT_SECRET: ${{secrets.CHROME_EXTENSION_CLIENT_SECRET}}
81+
run: chrome-webstore-upload upload --source chrome_extension.zip --extension-id $EXTENSION_ID --auto-publish
9182

9283
firefox-deploy:
9384
if: ${{ (github.event.inputs.targetStore == 'firefox') || (github.event.inputs.targetStore == 'all') }}
94-
needs: install-dependencies
85+
needs: tag_version
9586
runs-on: ubuntu-latest
9687
steps:
88+
- uses: actions/checkout@v2
89+
with:
90+
ref: master
91+
- uses: actions/cache@v2
92+
with:
93+
path: '**/node_modules'
94+
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
95+
- name: Install yarn dependencies
96+
run: yarn
97+
98+
- name: Build and zip the extension
99+
run: yarn build-firefox
100+
97101
- name: Install Firefox dependencies
98102
run: yarn global add web-ext web-ext-submit@6
99103

.vscode/settings.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
{
2+
"editor.formatOnSave": true,
3+
"editor.codeActionsOnSave": {
4+
"source.organizeImports": true
5+
}
26
}

public/base.manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "Hackertab.dev - developer news",
33
"description": "All developer news in one tab",
4-
"version": "1.15.2",
4+
"version": "1.15.9",
55
"chrome_url_overrides": {
66
"newtab": "index.html"
77
}

public/manifest.json

Lines changed: 0 additions & 15 deletions
This file was deleted.

script/build-chrome.sh

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,5 @@
11
echo 'building extension for Chrome...'
22

3-
# install jq if not installed
4-
if ! command -v jq &> /dev/null
5-
then
6-
echo "jq command not found. attempting to download jq binary"
7-
pth=$(pwd)
8-
export PATH=$PATH:$pth
9-
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
10-
curl -L https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64 -o jq
11-
elif [[ "$OSTYPE" == "darwin"* ]]; then
12-
curl -L https://github.com/stedolan/jq/releases/download/jq-1.6/jq-osx-amd64 -o jq
13-
else
14-
echo "Unsupported OS type. Exiting..."
15-
exit 1
16-
fi
17-
chmod +x jq
18-
fi
19-
203
# Merge base and chrome jsons
214
if [ -n "$version" ]; then
225
echo "Change manifest version to ${version}"

script/build-firefox.sh

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,5 @@
11
echo 'building extension for Firefox...'
22

3-
# install jq if not installed
4-
if ! command -v jq &> /dev/null
5-
then
6-
echo "jq command not found. attempting to download jq binary"
7-
pth=$(pwd)
8-
export PATH=$PATH:$pth
9-
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
10-
curl -L https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64 -o jq
11-
elif [[ "$OSTYPE" == "darwin"* ]]; then
12-
curl -L https://github.com/stedolan/jq/releases/download/jq-1.6/jq-osx-amd64 -o jq
13-
else
14-
echo "Unsupported OS type. Exiting..."
15-
exit 1
16-
fi
17-
chmod +x jq
18-
fi
19-
203
# Merge base and Firefox jsons
214
if [ -n "$version" ]; then
225
echo "Change manifest version to ${version}"

src/App.js

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,35 @@
1-
import { useState, useEffect } from 'react'
1+
import React, { Suspense, useEffect, useLayoutEffect, useState } from 'react'
2+
import 'react-contexify/dist/ReactContexify.css'
23
import 'src/assets/App.css'
34
import { Footer, Header } from 'src/components/Layout'
45
import { BookmarksSidebar } from 'src/features/bookmarks'
56
import { MarketingBanner } from 'src/features/MarketingBanner'
6-
import { ScrollCardsNavigator } from './components/Layout'
7-
import { AppContentLayout } from './components/Layout'
8-
import 'react-contexify/dist/ReactContexify.css'
9-
import { setupAnalytics, trackPageView, setupIdentification } from 'src/lib/analytics'
7+
import { setupAnalytics, setupIdentification, trackPageView } from 'src/lib/analytics'
8+
import { useUserPreferences } from 'src/stores/preferences'
9+
import { diffBetweenTwoDatesInDays } from 'src/utils/DateUtils'
10+
import { AppContentLayout, ScrollCardsNavigator } from './components/Layout'
11+
import { isWebOrExtensionVersion } from './utils/Environment'
12+
import { getAppVersion } from './utils/Os'
13+
14+
const OnboardingModal = React.lazy(() =>
15+
import('src/features/onboarding').then((module) => ({ default: module.OnboardingModal }))
16+
)
1017

1118
function App() {
1219
const [showSideBar, setShowSideBar] = useState(false)
1320
const [showSettings, setShowSettings] = useState(false)
21+
const [showOnboarding, setShowOnboarding] = useState(true)
22+
const { onboardingCompleted, firstSeenDate, markOnboardingAsCompleted } = useUserPreferences()
23+
24+
useLayoutEffect(() => {
25+
if (!onboardingCompleted && getAppVersion() <= '1.15.9') {
26+
const usageDays = diffBetweenTwoDatesInDays(firstSeenDate, Date.now())
27+
if (usageDays > 0) {
28+
markOnboardingAsCompleted(null)
29+
}
30+
}
31+
// eslint-disable-next-line react-hooks/exhaustive-deps
32+
}, [onboardingCompleted, firstSeenDate])
1433

1534
useEffect(() => {
1635
setupAnalytics()
@@ -21,7 +40,16 @@ function App() {
2140
return (
2241
<>
2342
<MarketingBanner />
43+
2444
<div className="App">
45+
{!onboardingCompleted && isWebOrExtensionVersion() === 'extension' && (
46+
<Suspense fallback={null}>
47+
<OnboardingModal
48+
showOnboarding={showOnboarding}
49+
setShowOnboarding={setShowOnboarding}
50+
/>
51+
</Suspense>
52+
)}
2553
<Header
2654
setShowSideBar={setShowSideBar}
2755
showSideBar={showSideBar}

0 commit comments

Comments
 (0)