Browse Source

fix planex initial group

Arnaud Vergnet 2 years ago
parent
commit
92eedda98b
1 changed files with 10 additions and 7 deletions
  1. 10
    7
      src/screens/Planex/PlanexScreen.tsx

+ 10
- 7
src/screens/Planex/PlanexScreen.tsx View File

@@ -46,7 +46,6 @@ import MascotPopup from '../../components/Mascot/MascotPopup';
46 46
 import { getPrettierPlanexGroupName } from '../../utils/Utils';
47 47
 import GENERAL_STYLES from '../../constants/Styles';
48 48
 import Urls from '../../constants/Urls';
49
-import { useMountEffect } from '../../utils/customHooks';
50 49
 
51 50
 // // JS + JQuery functions used to remove alpha from events. Copy paste in browser console for quick testing
52 51
 // // Remove alpha from given Jquery node
@@ -164,11 +163,8 @@ function PlanexScreen(props: Props) {
164 163
       }
165 164
   >();
166 165
   const [injectJS, setInjectJS] = useState('');
167
-  const [currentGroup, setCurrentGroup] = useState<
168
-    PlanexGroupType | undefined
169
-  >();
170 166
 
171
-  useMountEffect(() => {
167
+  const getCurrentGroup = (): PlanexGroupType | undefined => {
172 168
     let currentGroupString = AsyncStorageManager.getString(
173 169
       AsyncStorageManager.PREFERENCES.planexCurrentGroup.key
174 170
     );
@@ -178,9 +174,14 @@ function PlanexScreen(props: Props) {
178 174
       navigation.setOptions({
179 175
         title: getPrettierPlanexGroupName(group.name),
180 176
       });
181
-      setCurrentGroup(group);
177
+      return group;
182 178
     }
183
-  });
179
+    return undefined;
180
+  };
181
+
182
+  const [currentGroup, setCurrentGroup] = useState<PlanexGroupType | undefined>(
183
+    getCurrentGroup()
184
+  );
184 185
 
185 186
   useFocusEffect(
186 187
     useCallback(() => {
@@ -328,6 +329,8 @@ function PlanexScreen(props: Props) {
328 329
    * @param groupID The current group selected
329 330
    */
330 331
   const generateInjectedJS = (group: PlanexGroupType | undefined) => {
332
+    console.log(group);
333
+
331 334
     let customInjectedJS = `$(document).ready(function() {
332 335
       ${OBSERVE_MUTATIONS_INJECTED}
333 336
       ${INJECT_STYLE}

Loading…
Cancel
Save