( updatedVersion: string | null | undefined, initialVersion: string = MACRO.VERSION, )
| 14 | } |
| 15 | |
| 16 | export function useUpdateNotification( |
| 17 | updatedVersion: string | null | undefined, |
| 18 | initialVersion: string = MACRO.VERSION, |
| 19 | ): string | null { |
| 20 | const [lastNotifiedSemver, setLastNotifiedSemver] = useState<string | null>( |
| 21 | () => getSemverPart(initialVersion), |
| 22 | ) |
| 23 | |
| 24 | if (!updatedVersion) { |
| 25 | return null |
| 26 | } |
| 27 | |
| 28 | const updatedSemver = getSemverPart(updatedVersion) |
| 29 | if (updatedSemver !== lastNotifiedSemver) { |
| 30 | setLastNotifiedSemver(updatedSemver) |
| 31 | return updatedSemver |
| 32 | } |
| 33 | return null |
| 34 | } |
| 35 |
no test coverage detected