mirror of
https://github.com/4gray/iptvnator.git
synced 2026-10-08 17:06:15 -08:00
fix: update app version retrieval to use GitHub releases API
This commit is contained in:
1 parent
a3a8f96eaa
commit
8345c1f44f
1 file changed
+19
-12
@@ -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);
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user