feat(app): add version check system and enhance internationalization support
Add comprehensive app update checking functionality with: - New VersionCheckContext for managing update detection and notifications - VersionUpdateModal UI component for presenting update information - Version service API integration with platform-specific update URLs - Version check menu item in personal settings with manual/automatic checking Enhance internationalization across workout features: - Complete workout type translations for English and Chinese - Localized workout detail modal with proper date/time formatting - Locale-aware date formatting in fitness rings detail - Workout notification improvements with deep linking to specific workout details Improve UI/UX with better chart rendering, sizing fixes, and enhanced navigation flow. Update app version to 1.1.3 and include app version in API headers for better tracking.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { buildApiUrl } from '@/constants/Api';
|
||||
import AsyncStorage from '@/utils/kvStore';
|
||||
import Constants from 'expo-constants';
|
||||
import { Alert } from 'react-native';
|
||||
|
||||
type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
||||
@@ -128,6 +129,10 @@ export type ApiResponse<T> = {
|
||||
data: T;
|
||||
};
|
||||
|
||||
function getAppVersion(): string | undefined {
|
||||
return Constants.expoConfig?.version || Constants.nativeAppVersion || undefined;
|
||||
}
|
||||
|
||||
async function doFetch<T>(path: string, options: ApiRequestOptions = {}): Promise<T> {
|
||||
const url = buildApiUrl(path);
|
||||
const headers: Record<string, string> = {
|
||||
@@ -142,6 +147,11 @@ async function doFetch<T>(path: string, options: ApiRequestOptions = {}): Promis
|
||||
if (token) {
|
||||
headers['Authorization'] = `Bearer ${token}`;
|
||||
}
|
||||
const appVersion = getAppVersion();
|
||||
|
||||
if (appVersion) {
|
||||
headers['X-App-Version'] = appVersion;
|
||||
}
|
||||
|
||||
|
||||
const response = await fetch(url, {
|
||||
@@ -224,6 +234,10 @@ export async function postTextStream(path: string, body: any, callbacks: TextStr
|
||||
if (token) {
|
||||
requestHeaders['Authorization'] = `Bearer ${token}`;
|
||||
}
|
||||
const appVersion = getAppVersion();
|
||||
if (appVersion) {
|
||||
requestHeaders['X-App-Version'] = appVersion;
|
||||
}
|
||||
|
||||
const xhr = new XMLHttpRequest();
|
||||
let lastReadIndex = 0;
|
||||
|
||||
Reference in New Issue
Block a user