Przeglądaj źródła

impl applyOldIos method

Yuki Takei 5 lat temu
rodzic
commit
530c129720

+ 4 - 0
src/client/js/boot.js

@@ -1,5 +1,9 @@
 import {
   applyColorScheme,
 } from './util/color-scheme';
+import {
+  applyOldIos,
+} from './util/old-ios';
 
 applyColorScheme();
+applyOldIos();

+ 0 - 27
src/client/js/services/AppContainer.js

@@ -43,12 +43,6 @@ export default class AppContainer extends Container {
     const userAgent = window.navigator.userAgent.toLowerCase();
     this.isMobile = /iphone|ipad|android/.test(userAgent);
 
-    this.isIos = /iphone|ipad/.test(userAgent);
-    const appVersion = window.navigator.appVersion.toLowerCase(); // appVersion
-    if (appVersion <= 12.5) {
-      this.setState({ isOldIos: true });
-    }
-
     const currentUserElem = document.getElementById('growi-current-user');
     if (currentUserElem != null) {
       this.currentUser = JSON.parse(currentUserElem.textContent);
@@ -118,27 +112,6 @@ export default class AppContainer extends Container {
     this.injectToWindow();
   }
 
-
-  // ここから
-  // to check the client app ios version
-
-  isOldVerion(version) {
-    this.appVersion = this;
-    if (version <= this.appVersion.indexOf('12.5')) {
-      return true;
-    }
-  }
-
-  isOldIosVersion() {
-    if (this.isIos && this.isOldVerion()) {
-      this.setState({ isOldIos: true });
-      return true;
-    }
-  }
-
-  // ここまで
-
-
   async initMediaQueryForColorScheme() {
     const switchStateByMediaQuery = async(mql) => {
       const preferDarkMode = mql.matches;

+ 16 - 0
src/client/js/util/old-ios.js

@@ -0,0 +1,16 @@
+const userAgent = window.navigator.userAgent.toLowerCase();
+const isOldIos = /iphone os 12/.test(userAgent);
+
+/**
+ * Apply 'oldIos' attribute to <html></html>
+ */
+function applyOldIos() {
+  if (isOldIos) {
+    document.documentElement.setAttribute('old-ios', 'true');
+  }
+}
+
+export {
+  // eslint-disable-next-line import/prefer-default-export
+  applyOldIos,
+};