Skip to content

Commit 4adc0d9

Browse files
committed
Add release notes modal
1 parent 8368419 commit 4adc0d9

10 files changed

Lines changed: 92 additions & 18 deletions

File tree

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
"browser-image-compression": "^2.0.2",
5858
"cachified": "^3.5.4",
5959
"clsx": "^2.0.0",
60+
"compare-versions": "^6.1.0",
6061
"cookie": "^0.6.0",
6162
"dayjs": "^1.11.10",
6263
"eventsource-parser": "^1.1.1",

src/app/components/Dialog.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@ const Dialog: FC<PropsWithChildren<Props>> = (props) => {
3838
>
3939
<HeadlessDialog.Panel
4040
className={cx(
41-
'mx-auto rounded-3xl bg-primary-background shadow-2xl max-h-full overflow-hidden flex flex-col',
41+
'mx-auto rounded-2xl bg-primary-background shadow-2xl max-h-full overflow-hidden flex flex-col',
4242
props.className,
4343
)}
4444
>
4545
{props.title ? (
4646
<HeadlessDialog.Title
4747
className={cx(
4848
!props.borderless && 'border-b',
49-
'border-solid border-primary-border flex flex-row justify-center items-center py-4 px-5',
49+
'border-solid border-primary-border flex flex-row justify-center items-center py-3 px-5',
5050
)}
5151
>
5252
<span className="ml-auto" />

src/app/components/Layout.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import { Outlet } from '@tanstack/react-router'
22
import { useAtomValue } from 'jotai'
33
import { followArcThemeAtom, themeColorAtom } from '~app/state'
4+
import ReleaseNotesModal from './Modals/ReleaseNotesModal'
45
import DiscountModal from './Premium/DiscountModal'
5-
import Sidebar from './Sidebar'
66
import PremiumModal from './Premium/Modal'
7+
import Sidebar from './Sidebar'
78

89
function Layout() {
910
const themeColor = useAtomValue(themeColorAtom)
@@ -19,6 +20,7 @@ function Layout() {
1920
</div>
2021
<DiscountModal />
2122
<PremiumModal />
23+
<ReleaseNotesModal />
2224
</main>
2325
)
2426
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { useAtom } from 'jotai'
2+
import { FC } from 'react'
3+
import { useTranslation } from 'react-i18next'
4+
import { releaseNotesAtom } from '~app/state'
5+
import Dialog from '../Dialog'
6+
7+
const ReleaseNotesModal: FC = () => {
8+
const { t } = useTranslation()
9+
const [notes, setNotes] = useAtom(releaseNotesAtom)
10+
return (
11+
<Dialog title={t('Recent Updates')} open={notes.length > 0} onClose={() => setNotes([])} className="w-[600px]">
12+
<div className="flex flex-col gap-3 px-5 py-5">
13+
{notes.map((note, i) => {
14+
return (
15+
<div key={i} className="flex flex-row gap-2 items-center">
16+
<div className="flex-none rounded-full p-1 text-green-400 bg-green-400/10">
17+
<div className="h-2 w-2 rounded-full bg-current" />
18+
</div>
19+
<span className="text-primary-text font-medium">{t(note)}</span>
20+
</div>
21+
)
22+
})}
23+
</div>
24+
</Dialog>
25+
)
26+
}
27+
28+
export default ReleaseNotesModal

src/app/components/Sidebar/index.tsx

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@ import feedbackIcon from '~/assets/icons/feedback.svg'
99
import githubIcon from '~/assets/icons/github.svg'
1010
import settingIcon from '~/assets/icons/setting.svg'
1111
import themeIcon from '~/assets/icons/theme.svg'
12-
import logo from '~/assets/santa-logo.png'
1312
import minimalLogo from '~/assets/minimal-logo.svg'
13+
import logo from '~/assets/santa-logo.png'
1414
import { cx } from '~/utils'
1515
import { useEnabledBots } from '~app/hooks/use-enabled-bots'
16-
import { showDiscountModalAtom, sidebarCollapsedAtom } from '~app/state'
16+
import { releaseNotesAtom, showDiscountModalAtom, sidebarCollapsedAtom } from '~app/state'
1717
import { getPremiumActivation } from '~services/premium'
18+
import { checkReleaseNotes } from '~services/release-notes'
1819
import * as api from '~services/server-api'
1920
import { getAppOpenTimes, getPremiumModalOpenTimes } from '~services/storage/open-times'
2021
import GuideModal from '../GuideModal'
@@ -40,19 +41,25 @@ function Sidebar() {
4041
const [themeSettingModalOpen, setThemeSettingModalOpen] = useState(false)
4142
const enabledBots = useEnabledBots()
4243
const setShowDiscountModal = useSetAtom(showDiscountModalAtom)
44+
const setReleaseNotes = useSetAtom(releaseNotesAtom)
4345

4446
useEffect(() => {
45-
Promise.all([getAppOpenTimes(), getPremiumModalOpenTimes()]).then(async ([appOpenTimes, premiumModalOpenTimes]) => {
46-
if (getPremiumActivation()) {
47-
return
48-
}
49-
const { show, campaign } = await api.checkDiscount({ appOpenTimes, premiumModalOpenTimes })
50-
if (show) {
51-
setShowDiscountModal(true)
52-
} else if (campaign) {
53-
setShowDiscountModal(campaign)
54-
}
55-
})
47+
Promise.all([getAppOpenTimes(), getPremiumModalOpenTimes(), checkReleaseNotes()]).then(
48+
async ([appOpenTimes, premiumModalOpenTimes, releaseNotes]) => {
49+
if (!getPremiumActivation()) {
50+
const { show, campaign } = await api.checkDiscount({ appOpenTimes, premiumModalOpenTimes })
51+
if (show) {
52+
setShowDiscountModal(true)
53+
return
54+
}
55+
if (campaign) {
56+
setShowDiscountModal(campaign)
57+
return
58+
}
59+
}
60+
setReleaseNotes(releaseNotes)
61+
},
62+
)
5663
}, [])
5764

5865
return (

src/app/i18n/locales/japanese.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,5 +96,7 @@
9696
"Webapp mode uses your login session in current browser": "Webアプリモードでは、現在のブラウザでのログインセッションが使用されます",
9797
"Your keys are stored locally": "キーはローカルに保存されます",
9898
"Login to Claude.ai": "Claude.aiにログインする",
99-
"Login to Bard": "Bardにログインする"
99+
"Login to Bard": "Bardにログインする",
100+
"Recent Updates": "最近の更新",
101+
"Added a separate Gemini Pro bot, can be enabled in the settings": "独立したGemini Proボットを追加しました。設定で有効にできます"
100102
}

src/app/i18n/locales/simplified-chinese.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,5 +97,7 @@
9797
"Webapp mode uses your login session in current browser": "Webapp模式会使用当前浏览器中的登录状态",
9898
"Your keys are stored locally": "您的key只会保存在本地",
9999
"Login to Claude.ai": "登录Claude.ai",
100-
"Login to Bard": "登录Bard"
100+
"Login to Bard": "登录Bard",
101+
"Recent Updates": "最近更新",
102+
"Added a separate Gemini Pro bot, can be enabled in the settings": "添加了Gemini Pro,可在设置中启用"
101103
}

src/app/state/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,4 @@ export const followArcThemeAtom = atomWithStorage('followArcTheme', false)
3131
export const sidePanelBotAtom = atomWithStorage<BotId>('sidePanelBot', 'chatgpt')
3232
export const showDiscountModalAtom = atom<false | true | Campaign>(false)
3333
export const showPremiumModalAtom = atom<false | true | FeatureId>(false)
34+
export const releaseNotesAtom = atom<string[]>([])

src/services/release-notes.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { compareVersions } from 'compare-versions'
2+
import Browser from 'webextension-polyfill'
3+
import { getVersion } from '~utils'
4+
5+
const RELEASE_NOTES = [
6+
{
7+
version: '1.45.0',
8+
notes: ['Added a separate Gemini Pro bot, can be enabled in the settings'],
9+
},
10+
]
11+
12+
export async function checkReleaseNotes(): Promise<string[]> {
13+
const version = getVersion()
14+
const { lastCheckReleaseNotesVersion } = await Browser.storage.sync.get('lastCheckReleaseNotesVersion')
15+
Browser.storage.sync.set({ lastCheckReleaseNotesVersion: version })
16+
if (!lastCheckReleaseNotesVersion) {
17+
return []
18+
}
19+
return RELEASE_NOTES.slice(0, 3)
20+
.filter(({ version: v }) => compareVersions(v, lastCheckReleaseNotesVersion) > 0)
21+
.map(({ notes }) => notes)
22+
.flat()
23+
}

yarn.lock

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2498,6 +2498,7 @@ __metadata:
24982498
cachified: "npm:^3.5.4"
24992499
chrome-types: "npm:^0.1.240"
25002500
clsx: "npm:^2.0.0"
2501+
compare-versions: "npm:^6.1.0"
25012502
cookie: "npm:^0.6.0"
25022503
dayjs: "npm:^1.11.10"
25032504
eslint: "npm:^8.53.0"
@@ -2717,6 +2718,13 @@ __metadata:
27172718
languageName: node
27182719
linkType: hard
27192720

2721+
"compare-versions@npm:^6.1.0":
2722+
version: 6.1.0
2723+
resolution: "compare-versions@npm:6.1.0"
2724+
checksum: 5378edc8a53ac98ed907da463e1d6c26f1ed2664006d6a0d54bbdf7f046a36c43e244740854fc0edfc1e09253b9a0b7c98d1282dfee9f6f1a87199599f611218
2725+
languageName: node
2726+
linkType: hard
2727+
27202728
"concat-map@npm:0.0.1":
27212729
version: 0.0.1
27222730
resolution: "concat-map@npm:0.0.1"

0 commit comments

Comments
 (0)