()
| 19 | } |
| 20 | |
| 21 | export async function fetchLatestVersion(): Promise<{ |
| 22 | text: string; |
| 23 | isNew: boolean; |
| 24 | } | null> { |
| 25 | if (isDevEnvironment()) return null; |
| 26 | |
| 27 | const { data: currentVersion, error } = await tryCatch( |
| 28 | getLatestReleaseFromGitHub(), |
| 29 | ); |
| 30 | |
| 31 | if (error) { |
| 32 | const msg = createErrorMessage( |
| 33 | error, |
| 34 | "Failed to fetch version number from GitHub", |
| 35 | ); |
| 36 | console.error(msg); |
| 37 | return null; |
| 38 | } |
| 39 | |
| 40 | const memoryVersion = memoryLS.get(); |
| 41 | const isNew = memoryVersion === "" ? false : memoryVersion !== currentVersion; |
| 42 | |
| 43 | if (isNew || memoryVersion === "") { |
| 44 | memoryLS.set(currentVersion); |
| 45 | purgeCaches(); |
| 46 | } |
| 47 | |
| 48 | return { |
| 49 | text: currentVersion, |
| 50 | isNew, |
| 51 | }; |
| 52 | } |
no test coverage detected