Skip to content

Commit 8345c1f

Browse files
committed
fix: update app version retrieval to use GitHub releases API
1 parent a3a8f96 commit 8345c1f

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

src/app/services/settings.service.ts

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,10 @@ import { catchError, map, Observable } from 'rxjs';
55
import { STORE_KEY } from '../shared/enums/store-keys.enum';
66
import { Theme } from './../settings/theme.enum';
77

8-
/** Url of the package.json file in the app repository, required to get the version of the released app */
9-
const PACKAGE_JSON_URL =
10-
'https://raw.githubusercontent.com/4gray/iptvnator/master/package.json';
11-
128
@Injectable({
139
providedIn: 'root',
1410
})
1511
export class SettingsService {
16-
/** Creates an instance of SettingsService */
1712
constructor(
1813
private http: HttpClient,
1914
private storage: StorageMap
@@ -62,12 +57,24 @@ export class SettingsService {
6257
* Returns the version of the released app
6358
*/
6459
getAppVersion() {
65-
return this.http.get<{ version: string }>(PACKAGE_JSON_URL).pipe(
66-
map((response) => response.version),
67-
catchError((err) => {
68-
console.error(err);
69-
throw new Error(err);
70-
})
71-
);
60+
return this.http
61+
.get<
62+
{ created_at: string; name: string }[]
63+
>('https://api.github.com/repos/4gray/iptvnator/releases')
64+
.pipe(
65+
map(
66+
(response) =>
67+
response.sort(
68+
(a, b) =>
69+
new Date(b.created_at).getTime() -
70+
new Date(a.created_at).getTime()
71+
)[0]
72+
),
73+
map((response) => response.name),
74+
catchError((err) => {
75+
console.error(err);
76+
throw new Error(err);
77+
})
78+
);
7279
}
7380
}

0 commit comments

Comments
 (0)