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

+2 -2
View File
@@ -5,11 +5,11 @@ import { GridMenu } from '../../../ui/components/GridMenu';
import { useApps } from '../../../os/apps/hooks/useApps';
export const HomeApp = () => {
const { apps } = useApps();
const { allApps } = useApps();
return (
<AppWrapper>
<Box width='100%' mt={6} px={1}>
{apps && <GridMenu items={apps.preinstalled} />}
{allApps && <GridMenu items={allApps} />}
</Box>
</AppWrapper>
);
+10 -2
View File
@@ -22,7 +22,15 @@ export const settingsState = atom({
effects_UNSTABLE: [localStorageEffect('settings')],
});
interface IPhoneSettings {
wallpaper: string;
frame: string;
theme: string;
zoom: number;
ringtone: string;
ringtoneVol: number;
}
export const useSettings = () => {
const [settings, setSettings] = useRecoilState(settingsState);
return [settings, setSettings];
return useRecoilState<IPhoneSettings>(settingsState);
};
@@ -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);