Bladeren bron

1.2.9, fix change password and checkversion logic

Ian Fung 1 jaar geleden
bovenliggende
commit
f61722647e

+ 1 - 1
app/(auth)/(tabs)/(account)/changePasswordPage.tsx

@@ -5,7 +5,7 @@ import ChangePasswordPageComponent from '../../../../component/accountPages/chan
 const ChangePasswordPage = () => {
     return (
         <View className="flex-1">
-       <ChangePasswordPageComponent />
+            <ChangePasswordPageComponent />
         </View>
     );
 };

+ 1 - 1
component/accountPages/changePasswordPageComponent.tsx

@@ -41,7 +41,7 @@ const changePasswordPageComponent = () => {
             }
             console.log('user', user);
 
-            const success = await authenticationService.login(user.phone, currentPassword);
+            const success = await authenticationService.phoneLogin(user.phone, currentPassword);
             if (success) {
                 setIsPasswordVerified(true);
                 setError('');

+ 14 - 2
component/checkVersion.tsx

@@ -31,8 +31,20 @@ export function checkVersion(fetchedVersion: { version: string; isActive: boolea
         // Prevent any further code execution
         throw new Error('MAINTENANCE_MODE');
     }
-    // if (currentVersion && currentVersion !== '1.2.9') {
-    if (currentVersion && currentVersion !== fetchedVersion.version) {
+
+    function compareVersions(v1: string, v2: string): boolean {
+        const v1Parts = v1.split('.').map(Number);
+        const v2Parts = v2.split('.').map(Number);
+
+        for (let i = 0; i < v1Parts.length; i++) {
+            if (v1Parts[i] < v2Parts[i]) return true;
+            if (v1Parts[i] > v2Parts[i]) return false;
+        }
+        return false;
+    }
+
+    // if (currentVersion && currentVersion < fetchedVersion.version) {
+    if (currentVersion && compareVersions(currentVersion, fetchedVersion.version)) {
         Alert.alert(
             '請更新到最新版本',
             'Please update to the latest version of the app to continue.',