fix: update app version retrieval to use GitHub releases API

This commit is contained in:
4gray committed 2025-03-10 19:19:01 +01:00
1 parent a3a8f96eaa
commit 8345c1f44f
1 file changed
+19 -12
+19 -12
View File
@@ -5,15 +5,10 @@ import { catchError, map, Observable } from 'rxjs';
import { STORE_KEY } from '../shared/enums/store-keys.enum';
import { Theme } from './../settings/theme.enum';
/** Url of the package.json file in the app repository, required to get the version of the released app */
const PACKAGE_JSON_URL =
'https://raw.githubusercontent.com/4gray/iptvnator/master/package.json';
@Injectable({
providedIn: 'root',
})
export class SettingsService {
/** Creates an instance of SettingsService */
constructor(
private http: HttpClient,
private storage: StorageMap
@@ -62,12 +57,24 @@ export class SettingsService {
* Returns the version of the released app
*/
getAppVersion() {
return this.http.get<{ version: string }>(PACKAGE_JSON_URL).pipe(
map((response) => response.version),
catchError((err) => {
console.error(err);
throw new Error(err);
})
);
return this.http
.get<
{ created_at: string; name: string }[]
>('https://api.github.com/repos/4gray/iptvnator/releases')
.pipe(
map(
(response) =>
response.sort(
(a, b) =>
new Date(b.created_at).getTime() -
new Date(a.created_at).getTime()
)[0]
),
map((response) => response.name),
catchError((err) => {
console.error(err);
throw new Error(err);
})
);
}
}