Skip to content

Commit a053536

Browse files
committed
change new instead of the bell when a new version is published
1 parent f524e4d commit a053536

2 files changed

Lines changed: 32 additions & 14 deletions

File tree

src/App.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -717,6 +717,10 @@ Producthunt item
717717
color: white;
718718
}
719719
.changelogButton.active {
720+
width: auto;
721+
font-size: 12px;
722+
padding:0 4px;
723+
text-transform: lowercase;
720724
background-color: var(--tooltip-accent-color);
721725
}
722726

src/features/changelog/components/Changelog.tsx

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,35 +7,47 @@ import BeatLoader from 'react-spinners/BeatLoader'
77
import {useGetVersions} from "../api/getVersions";
88
import {useChangelogStore} from "../stores/changelog";
99
import {getAppVersion} from "src/utils/Os";
10+
import { trackChangeLogOpen } from 'src/lib/analytics'
1011

11-
export const Changelog = () => {
12+
export const Changelog = () => {
1213
const tooltipId = 'tl-1'
13-
const [tooltipOpen, setTooltipShown] = useState(false);
14-
const {isLoading, isError, data: versions} = useGetVersions({
14+
const [tooltipShown, setTooltipShown] = useState(false)
15+
const {
16+
isLoading,
17+
isError,
18+
data: versions,
19+
} = useGetVersions({
1520
config: {
16-
enabled: tooltipOpen
17-
}
18-
});
21+
enabled: tooltipShown,
22+
},
23+
})
1924

20-
const {lastReadVersion, setVersionAsRead} = useChangelogStore();
25+
const { lastReadVersion, setVersionAsRead } = useChangelogStore()
2126

2227
const isChangelogRead = (): boolean => {
23-
return lastReadVersion === getAppVersion();
28+
return lastReadVersion === getAppVersion()
2429
}
2530

2631
useEffect(() => {
27-
if (tooltipOpen) {
28-
setVersionAsRead(getAppVersion())
32+
const currentVersion = getAppVersion()
33+
if (tooltipShown) {
34+
trackChangeLogOpen()
35+
36+
if (currentVersion) {
37+
setVersionAsRead(currentVersion)
38+
}
2939
}
30-
}, [tooltipOpen, setVersionAsRead])
40+
}, [tooltipShown, setVersionAsRead])
3141

3242
return (
3343
<>
3444
<ReactTooltip
3545
id={tooltipId}
3646
event="click"
3747
scrollHide={false}
38-
afterShow={() => {setTooltipShown(true)}}
48+
afterShow={() => {
49+
setTooltipShown(true)
50+
}}
3951
place="bottom"
4052
className="changelogTooltip scrollable"
4153
globalEventOff="click">
@@ -50,7 +62,9 @@ export const Changelog = () => {
5062
return (
5163
<div key={item.name}>
5264
<div className="tooltipHeader">
53-
<a className="tooltipVersion" onClick={() => window.open(item.html_url, '_blank')}>
65+
<a
66+
className="tooltipVersion"
67+
onClick={() => window.open(item.html_url, '_blank')}>
5468
{item.name}
5569
</a>
5670
<span className="tooltipDate">{format(new Date(item.published_at))}</span>
@@ -67,7 +81,7 @@ export const Changelog = () => {
6781
data-tip
6882
data-for={tooltipId}
6983
className={'changelogButton' + (!isChangelogRead() ? ' active' : '')}>
70-
<HiBell style={{ width: 14 }} />
84+
{isChangelogRead() ? <HiBell style={{ width: 14 }} /> : `New`}
7185
</span>
7286
</>
7387
)

0 commit comments

Comments
 (0)