|
|
@@ -22,10 +22,10 @@ MiddlewareRegistry.register(store => next => action => {
|
|
22
|
22
|
switch (action.type) {
|
|
23
|
23
|
case APP_WILL_MOUNT:
|
|
24
|
24
|
_ensureDefaultServer(store);
|
|
25
|
|
- _fetchCalendarEntries(store);
|
|
|
25
|
+ _fetchCalendarEntries(store, false);
|
|
26
|
26
|
break;
|
|
27
|
27
|
case REFRESH_CALENDAR_ENTRY_LIST:
|
|
28
|
|
- _fetchCalendarEntries(store);
|
|
|
28
|
+ _fetchCalendarEntries(store, true);
|
|
29
|
29
|
break;
|
|
30
|
30
|
case SET_ROOM:
|
|
31
|
31
|
_parseAndAddDomain(store);
|
|
|
@@ -38,15 +38,17 @@ MiddlewareRegistry.register(store => next => action => {
|
|
38
|
38
|
* Ensures calendar access if possible and resolves the promise if it's granted.
|
|
39
|
39
|
*
|
|
40
|
40
|
* @private
|
|
|
41
|
+ * @param {boolean} promptForPermission - Flag to tell the app if it should
|
|
|
42
|
+ * prompt for a calendar permission if it wasn't granted yet.
|
|
41
|
43
|
* @returns {Promise}
|
|
42
|
44
|
*/
|
|
43
|
|
-function _ensureCalendarAccess() {
|
|
|
45
|
+function _ensureCalendarAccess(promptForPermission) {
|
|
44
|
46
|
return new Promise((resolve, reject) => {
|
|
45
|
47
|
RNCalendarEvents.authorizationStatus()
|
|
46
|
48
|
.then(status => {
|
|
47
|
49
|
if (status === 'authorized') {
|
|
48
|
50
|
resolve();
|
|
49
|
|
- } else if (status === 'undetermined') {
|
|
|
51
|
+ } else if (promptForPermission) {
|
|
50
|
52
|
RNCalendarEvents.authorizeEventStore()
|
|
51
|
53
|
.then(result => {
|
|
52
|
54
|
if (result === 'authorized') {
|
|
|
@@ -89,10 +91,12 @@ function _ensureDefaultServer(store) {
|
|
89
|
91
|
*
|
|
90
|
92
|
* @private
|
|
91
|
93
|
* @param {Object} store - The redux store.
|
|
|
94
|
+ * @param {boolean} promptForPermission - Flag to tell the app if it should
|
|
|
95
|
+ * prompt for a calendar permission if it wasn't granted yet.
|
|
92
|
96
|
* @returns {void}
|
|
93
|
97
|
*/
|
|
94
|
|
-function _fetchCalendarEntries(store) {
|
|
95
|
|
- _ensureCalendarAccess()
|
|
|
98
|
+function _fetchCalendarEntries(store, promptForPermission) {
|
|
|
99
|
+ _ensureCalendarAccess(promptForPermission)
|
|
96
|
100
|
.then(() => {
|
|
97
|
101
|
const startDate = new Date();
|
|
98
|
102
|
const endDate = new Date();
|