Feature / Add working notifications with only twitter for now (#102)

* Add working notifications with only twitter for now

* feat(notification-bar): I didnt copy from NP

* Make default browser visibility true

* feat(notifications): Collapse when no more notifications after closing one
This commit is contained in:
J Francisco Rader authored and GitHub committed 2021-02-18 19:21:07 -05:00
1 parent 11af8bfb5a
commit 40ec19a349
19 files changed
+497 -153

No files matched your search

@@ -33,6 +33,30 @@ InjectDebugData([
avatar_url: 'https://i.tasoagc.dev/i9Ig',
},
},
{
app: 'TWITTER',
method: 'createTweetBroadcast',
data: {
id: 111,
profile_id: 111,
profile_name: 'Kidz',
isMine: false,
isReported: false,
message: 'I have tweeted this because Im badass'
}
},
{
app: 'TWITTER',
method: 'createTweetBroadcast',
data: {
id: 111,
profile_id: 111,
profile_name: 'ItsChip',
isMine: false,
isReported: false,
message: 'I have tweeted this because Im even more badass'
}
},
{
app: 'TWITTER',
method: 'fetchTweets',
@@ -5,6 +5,10 @@ import { useNuiEvent } from '../../../os/nui-events/hooks/useNuiEvent';
import { IMAGE_DELIMITER } from '../utils/images';
import { APP_TWITTER } from '../utils/constants';
import { twitterState } from './state';
import { useNotifications } from '../../../os/notifications/hooks/useNotifications';
import { useApp } from '../../../os/apps/hooks/useApps';
import { useTranslation } from 'react-i18next';
import { useCallback } from 'react';
/**
* Perform all necessary processing/transforms from the raw database
@@ -28,6 +32,23 @@ function processTweet(tweet) {
* there and have moved that logic here instead.
*/
export const useTwitterService = () => {
const { t } = useTranslation();
const { addNotification } = useNotifications();
const { icon, notificationIcon } = useApp('TWITTER');
const setNotification = useCallback(
({ profile_name, message }) =>
addNotification({
app: 'TWITTER',
title: t('APPS_TWITTER_NEW_BROADCAST', { profile_name }),
href: '/twitter',
content: message,
icon,
notificationIcon,
}),
[addNotification, icon, notificationIcon, t]
);
const setProfile = useSetRecoilState(twitterState.profile);
const setUpdateProfileLoading = useSetRecoilState(
twitterState.updateProfileLoading
@@ -41,7 +62,6 @@ export const useTwitterService = () => {
const setCreateSuccess = useSetRecoilState(
twitterState.createTweetSuccessful
);
const setNotification = useSetRecoilState(twitterState.notification);
const _setUpdateProfileSuccess = (isSuccessful) => {
setUpdateProfileSuccess(isSuccessful);