浏览代码

[RN] Only ask for calendar permission on user interaction

master
Bettenbuk Zoltan 6 年前
父节点
当前提交
961e1d611f

+ 6
- 4
react/features/base/react/components/native/AbstractPagedList.js 查看文件

@@ -82,7 +82,7 @@ export default class AbstractPagedList extends Component<Props, State> {
82 82
      * @inheritdoc
83 83
      */
84 84
     componentDidMount() {
85
-        this._maybeRefreshSelectedPage();
85
+        this._maybeRefreshSelectedPage(false);
86 86
     }
87 87
 
88 88
     /**
@@ -118,7 +118,7 @@ export default class AbstractPagedList extends Component<Props, State> {
118 118
         );
119 119
     }
120 120
 
121
-    _maybeRefreshSelectedPage: () => void;
121
+    _maybeRefreshSelectedPage: ?boolean => void;
122 122
 
123 123
     /**
124 124
      * Components that this PagedList displays may have a refresh function to
@@ -126,9 +126,11 @@ export default class AbstractPagedList extends Component<Props, State> {
126 126
      * function invokes this logic if it's present.
127 127
      *
128 128
      * @private
129
+     * @param {boolean} isInteractive - If true this refresh was caused by
130
+     * direct user interaction, false otherwise.
129 131
      * @returns {void}
130 132
      */
131
-    _maybeRefreshSelectedPage() {
133
+    _maybeRefreshSelectedPage(isInteractive: boolean = true) {
132 134
         const selectedPage = this.props.pages[this.state.pageIndex];
133 135
         let component;
134 136
 
@@ -136,7 +138,7 @@ export default class AbstractPagedList extends Component<Props, State> {
136 138
             const { refresh } = component;
137 139
 
138 140
             typeof refresh === 'function'
139
-                && refresh.call(component, this.props.dispatch);
141
+                && refresh.call(component, this.props.dispatch, isInteractive);
140 142
         }
141 143
     }
142 144
 

+ 2
- 1
react/features/calendar-sync/actionTypes.js 查看文件

@@ -5,7 +5,8 @@
5 5
  *
6 6
  * {
7 7
  *     type: REFRESH_CALENDAR,
8
- *     forcePermission: boolean
8
+ *     forcePermission: boolean,
9
+ *     isInteractive: boolean
9 10
  * }
10 11
  */
11 12
 export const REFRESH_CALENDAR = Symbol('REFRESH_CALENDAR');

+ 9
- 4
react/features/calendar-sync/actions.js 查看文件

@@ -9,17 +9,22 @@ import {
9 9
 /**
10 10
  * Sends an action to refresh the entry list (fetches new data).
11 11
  *
12
- * @param {boolean|undefined} forcePermission - Whether to force to re-ask for
12
+ * @param {boolean} forcePermission - Whether to force to re-ask for
13 13
  * the permission or not.
14
+ * @param {boolean} isInteractive - If true this refresh was caused by
15
+ * direct user interaction, false otherwise.
14 16
  * @returns {{
15 17
  *     type: REFRESH_CALENDAR,
16
- *     forcePermission: boolean
18
+ *     forcePermission: boolean,
19
+ *     isInteractive: boolean
17 20
  * }}
18 21
  */
19
-export function refreshCalendar(forcePermission: boolean = false) {
22
+export function refreshCalendar(
23
+        forcePermission: boolean = false, isInteractive: boolean = true) {
20 24
     return {
21 25
         type: REFRESH_CALENDAR,
22
-        forcePermission
26
+        forcePermission,
27
+        isInteractive
23 28
     };
24 29
 }
25 30
 

+ 4
- 2
react/features/calendar-sync/components/MeetingList.native.js 查看文件

@@ -65,11 +65,13 @@ class MeetingList extends Component<Props> {
65 65
      * change).
66 66
      *
67 67
      * @param {Function} dispatch - The Redux dispatch function.
68
+     * @param {boolean} isInteractive - If true this refresh was caused by
69
+     * direct user interaction, false otherwise.
68 70
      * @public
69 71
      * @returns {void}
70 72
      */
71
-    static refresh(dispatch) {
72
-        dispatch(refreshCalendar());
73
+    static refresh(dispatch, isInteractive) {
74
+        dispatch(refreshCalendar(false, isInteractive));
73 75
     }
74 76
 
75 77
     /**

+ 2
- 1
react/features/calendar-sync/middleware.js 查看文件

@@ -75,7 +75,8 @@ CALENDAR_ENABLED
75 75
         case REFRESH_CALENDAR: {
76 76
             const result = next(action);
77 77
 
78
-            _fetchCalendarEntries(store, true, action.forcePermission);
78
+            _fetchCalendarEntries(
79
+                store, action.isInteractive, action.forcePermission);
79 80
 
80 81
             return result;
81 82
         }

正在加载...
取消
保存