...
 
Commits (2)
......@@ -31,6 +31,7 @@ import {
Clipboard,
} from 'react-native';
import FlashMessage from "react-native-flash-message";
import CookieManager from 'react-native-cookies';
import KeychainModalScreen from './src/keychain/KeychainModalScreen';
......@@ -55,6 +56,7 @@ import ErrorBoundary from './src/common/components/ErrorBoundary';
import { CommonStyle as CS } from './src/styles/Common';
import logService from './src/common/services/log.service';
import settingsStore from './src/settings/SettingsStore';
import Notification from './src/notifications/notification/Notification';
let deepLinkUrl = '';
......@@ -292,6 +294,7 @@ export default class App extends Component<Props, State> {
NavigationService.setTopLevelNavigator(navigatorRef);
}}
/>
<FlashMessage renderCustomContent={() => <Notification entity={stores.notifications.last} navigation={NavigationService} />} />
</ErrorBoundary>
</Provider>
);
......
......@@ -24,13 +24,16 @@ export default class NotificationsService {
throw "Ooops";
}
}
}
export function getCount() {
return api.get('api/v1/notifications/count');
}
export function getSingle(guid) {
return api.get(`api/v1/notifications/single/${guid}`);
}
export function getSettings() {
return api.get('api/v1/notifications/settings');
}
......
......@@ -2,14 +2,18 @@ import {
observable,
action,
computed,
} from 'mobx'
} from 'mobx';
import NotificationsService, { getFeed, getCount } from './NotificationsService';
import { showMessage, hideMessage } from "react-native-flash-message";
import NotificationsService, { getFeed, getCount, getSingle } from './NotificationsService';
import OffsetListStore from '../common/stores/OffsetListStore';
import session from '../common/services/session.service';
import badge from '../common/services/badge.service';
import logService from '../common/services/log.service';
import socketService from '../common/services/socket.service';
import { Alert } from 'react-native';
/**
* Notifications Store
......@@ -21,6 +25,8 @@ class NotificationsStore {
*/
list = new OffsetListStore('shallow');
last = null;
service = new NotificationsService;
/**
......@@ -53,7 +59,10 @@ class NotificationsStore {
this.loadCount();
// start polling for count every 10 seconds
this.startPollCount();
this.listen();
} else {
this.unlisten();
this.stopPollCount();
}
});
......@@ -67,6 +76,31 @@ class NotificationsStore {
}
}
onSocket = async(guid) => {
this.increment();
// TODO: enable live notifications
// const response = await getSingle(guid);
// if (response.notification) {
// // hideMessage();
// this.last = response.notification;
// showMessage({
// type: "default",
// position: 'top',
// backgroundColor: "#EEF5F9",
// message: ""
// });
// }
}
listen() {
socketService.subscribe('notification', this.onSocket);
}
unlisten() {
socketService.unsubscribe('notification', this.onSocket);
}
/**
* Load notification list
*/
......@@ -129,8 +163,8 @@ class NotificationsStore {
*/
startPollCount() {
this.pollInterval = setInterval(() => {
this.loadCount();
}, 10000);
this.loadCount();
}, 30000);
}
/**
......@@ -155,6 +189,12 @@ class NotificationsStore {
badge.setUnreadNotifications(count);
}
@action
increment() {
this.unread++;
badge.setUnreadNotifications(this.unread);
}
@action
reset() {
this.list = new OffsetListStore('shallow');
......
......@@ -5272,7 +5272,7 @@ lodash@^3.5.0:
resolved "https://registry.yarnpkg.com/lodash/-/lodash-3.10.1.tgz#5bf45e8e49ba4189e17d482789dfd15bd140b7b6"
integrity sha1-W/Rejkm6QYnhfUgnid/RW9FAt7Y=
loose-envify@^1.0.0, loose-envify@^1.1.0, loose-envify@^1.3.1:
loose-envify@^1.0.0, loose-envify@^1.1.0, loose-envify@^1.3.1, loose-envify@^1.4.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.4.0.tgz#71ee51fa7be4caec1a63839f7e682d8132d30caf"
dependencies:
......@@ -6812,6 +6812,15 @@ prop-types@15.6.2, prop-types@^15.5.10, prop-types@^15.5.8, prop-types@^15.6.0,
loose-envify "^1.3.1"
object-assign "^4.1.1"
prop-types@^15.7.2:
version "15.7.2"
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.7.2.tgz#52c41e75b8c87e72b9d9360e0206b99dcbffa6c5"
integrity sha512-8QQikdH7//R2vurIJSutZ1smHYTcLpRWEOlHnzcWHmBYrOGUysKwSsrC89BCiFj3CbrfJ/nXFdJepOVrY1GCHQ==
dependencies:
loose-envify "^1.4.0"
object-assign "^4.1.1"
react-is "^16.8.1"
proxy-addr@~2.0.3:
version "2.0.4"
resolved "https://registry.yarnpkg.com/proxy-addr/-/proxy-addr-2.0.4.tgz#ecfc733bf22ff8c6f407fa275327b9ab67e48b93"
......@@ -7060,7 +7069,7 @@ react-is@^16.7.0:
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.7.0.tgz#c1bd21c64f1f1364c6f70695ec02d69392f41bfa"
integrity sha512-Z0VRQdF4NPDoI0tsXVMLkJLiwEBa+RP66g0xDHxgxysxSoCUccSten4RTF/UFvZF1dZvZ9Zu1sx+MDXwcOR34g==
react-is@^16.8.6:
react-is@^16.8.1, react-is@^16.8.6:
version "16.8.6"
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.8.6.tgz#5bbc1e2d29141c9fbdfed456343fe2bc430a6a16"
integrity sha512-aUk3bHfZ2bRSVFFbbeVS4i+lNPZr3/WM5jT2J5omUVV1zzcs1nAaf3l51ctA5FFvCRbhrH0bdAsRRQddFJZPtA==
......@@ -7166,6 +7175,14 @@ react-native-fast-image@^5.4.2:
resolved "https://registry.yarnpkg.com/react-native-fast-image/-/react-native-fast-image-5.4.2.tgz#d761cb9dddc0473b537544617e511a11c9e18413"
integrity sha512-S4E96Lwmx6z6QD3MaAuP7cNcXRLfgEUYU2GB694TbGEoOjk/FO1OnfbxfFp0vUs/klr4HJwACcwihPPxrFTt8w==
react-native-flash-message@^0.1.13:
version "0.1.13"
resolved "https://registry.yarnpkg.com/react-native-flash-message/-/react-native-flash-message-0.1.13.tgz#3ebf9cf17d5aabc61b923dc6dc37ce97a1ad4dd2"
integrity sha512-7P0cOyF7dRJL6tgwIhKs3V9QXRFa1qXDymCx1BmQLzdWyc3qyD5HMv2L5EbYk3wj1BirLjaL7tkYyEETg2jSNQ==
dependencies:
prop-types "^15.7.2"
react-native-iphone-x-helper "^1.2.0"
react-native-fs@^2.13.3:
version "2.13.3"
resolved "https://registry.yarnpkg.com/react-native-fs/-/react-native-fs-2.13.3.tgz#a422f0ecd8a093a7e99d8d51ff51440e090a18a8"
......@@ -7211,6 +7228,11 @@ react-native-invertible-scroll-view@^1.1.1:
react-clone-referenced-element "^1.0.1"
react-native-scrollable-mixin "^1.0.1"
react-native-iphone-x-helper@^1.2.0:
version "1.2.1"
resolved "https://registry.yarnpkg.com/react-native-iphone-x-helper/-/react-native-iphone-x-helper-1.2.1.tgz#645e2ffbbb49e80844bb4cbbe34a126fda1e6772"
integrity sha512-/VbpIEp8tSNNHIvstuA3Swx610whci1Zpc9mqNkqn14DkMbw+ORviln2u0XyHG1kPvvwTNGZY6QpeFwxYaSdbQ==
react-native-jitsi-meet@Minds/react-native-jitsi-meet#5f009f523c2f7aa114d25b7a7827300a393df47f:
version "1.0.7"
resolved "https://codeload.github.com/Minds/react-native-jitsi-meet/tar.gz/5f009f523c2f7aa114d25b7a7827300a393df47f"
......