diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 64e4839..b69b408 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -31,6 +31,8 @@ jobs:
run: yarn --frozen-lockfile
- name: Run Enzyme Tests
run: yarn test
+ - name: Check build status
+ run: yarn build
env:
CI: true
@@ -52,9 +54,12 @@ jobs:
run: yarn --frozen-lockfile
- name: Run Jest Tests
run: yarn test
+ - name: Check build status
+ run: yarn build
env:
CI: true
+
lint:
name: Lint Lua scripts
runs-on: ubuntu-latest
diff --git a/.github/workflows/prerelease.yml b/.github/workflows/prerelease.yml
new file mode 100644
index 0000000..750437c
--- /dev/null
+++ b/.github/workflows/prerelease.yml
@@ -0,0 +1,51 @@
+name: Prerelease Publisher
+on:
+ push:
+ branches:
+ - master
+jobs:
+ tagged-release:
+ runs-on: ubuntu-latest
+
+ outputs:
+ VERSION_TAG: ${{ steps.get_vars.outputs.VERSION_TAG }}
+ steps:
+ - name: Install archive tools
+ run: sudo apt-get install zip gzip tar
+ - name: Checkout source code
+ uses: actions/checkout@v2
+ with:
+ fetch-depth: 0
+ ref: ${{ github.ref }}
+ - name: Get variables
+ run: echo ::set-output name=VERSION_TAG::${GITHUB_REF/refs\/tags\//}
+ id: get_vars
+ - name: Get yarn cache directory path
+ id: yarn-cache-dir-path
+ run: echo "::set-output name=dir::$(yarn config get cacheFolder)"
+ - uses: actions/cache@v2
+ id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
+ with:
+ path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
+ key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
+ restore-keys: |
+ ${{ runner.os }}-yarn-
+ - name: Use Node.js
+ uses: actions/setup-node@v2
+ with:
+ node-version: '14.x'
+ - name: Install dependencies
+ run: yarn --frozen-lockfile
+ - name: Run build
+ run: npm run build
+ - name: Create Release
+ uses: "marvinpinto/action-automatic-releases@latest"
+ with:
+ repo_token: "${{ secrets.GITHUB_TOKEN }}"
+ prerelease: true
+ files: |
+
+ id: auto_release
+
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
\ No newline at end of file
diff --git a/.github/workflows/tagged-releases.yml b/.github/workflows/tagged-releases.yml
new file mode 100644
index 0000000..d5991e1
--- /dev/null
+++ b/.github/workflows/tagged-releases.yml
@@ -0,0 +1,70 @@
+name: Tagged Release Publisher
+on:
+ push:
+ tags:
+ - "v*"
+jobs:
+ create-tagged-release:
+ runs-on: ubuntu-latest
+
+ outputs:
+ VERSION_TAG: ${{ steps.get_vars.outputs.VERSION_TAG }}
+ steps:
+ - name: Install archive tools
+ run: sudo apt-get install zip gzip tar
+ - name: Checkout source code
+ uses: actions/checkout@v2
+ with:
+ fetch-depth: 0
+ ref: ${{ github.ref }}
+ - name: Get variables
+ run: echo ::set-output name=VERSION_TAG::${GITHUB_REF/refs\/tags\//}
+ id: get_vars
+ - name: Get yarn cache directory path
+ id: yarn-cache-dir-path
+ run: echo "::set-output name=dir::$(yarn config get cacheFolder)"
+ - uses: actions/cache@v2
+ id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
+ with:
+ path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
+ key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
+ restore-keys: |
+ ${{ runner.os }}-yarn-
+ - name: Use Node.js
+ uses: actions/setup-node@v2
+ with:
+ node-version: '14.x'
+ - name: Install dependencies
+ run: yarn --frozen-lockfile
+ - name: Run build
+ run: npm run build
+ - name: Create Sentry Release
+ uses: tclindner/sentry-releases-action@v1.2.0
+ env:
+ SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
+ SENTRY_ORG: ${{ secrets.SENTRY_ORG }}
+ SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }}
+ SENTRY_URL: https://sentry.projecterror.dev/
+ with:
+ environment: production
+ tagName: ${{ steps.get_vars.outputs.VERSION_TAG }}
+ sourceMapOptions: './resources/html/static/js'
+ - name: Bundle built files
+ run: |
+ mkdir npwd_temp
+ mkdir npwd_temp/resources
+ cp -t npwd_temp/resources -r resources/dist resources/html
+ cp -t npwd_temp fxmanifest.lua config.json LICENSE README.md
+ zip -r npwd-${{ steps.get_vars.outputs.VERSION_TAG }} npwd_temp
+ rm -rf npwd_temp
+ echo "Cleaned up"
+ - name: Create Release
+ uses: "marvinpinto/action-automatic-releases@latest"
+ with:
+ repo_token: "${{ secrets.GITHUB_TOKEN }}"
+ prerelease: false
+ files: |
+ "npwd-${{ steps.get_vars.outputs.VERSION_TAG }}"
+ id: auto_release
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
index 2d7d59a..c0795ad 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,9 +1,12 @@
# No IDE Folders
.idea
+npwd_temp
+
resources/html
phone/.eslintcache
+phone/.env
# Node Modules and Built Folders
node_modules
@@ -22,4 +25,5 @@ yarn-error.log*
sv_npwd.log
# FXServer Yarn
-.yarn.installed
\ No newline at end of file
+.yarn.installed
+phone/.env
diff --git a/config.json b/config.json
index f38e291..376c608 100644
--- a/config.json
+++ b/config.json
@@ -1,15 +1,9 @@
{
"Locale": "en",
- "KeyTogglePhone": 288,
- "KeyTakeCall": 38,
- "PhoneAsItem": false,
- "SwimDestroy": false,
- "RunRate": 10,
- "DestroyChance": 100,
- "DestroyPhoneReCheck": 3,
- "notificationPosition": {
- "horizontal": "right",
- "vertical": "top"
+ "PhoneAsItem": {
+ "enabled": false,
+ "exportResource": "my-core-resource",
+ "exportName": "myCheckerFunction"
},
"general": {
"useDashNumber": true,
@@ -42,6 +36,7 @@
},
"debug": {
"level": "silly",
- "enabled": true
+ "enabled": true,
+ "sentryEnabled": true
}
}
diff --git a/package.json b/package.json
index 212d75a..3e93e67 100644
--- a/package.json
+++ b/package.json
@@ -14,7 +14,7 @@
"pretty-quick": "^3.1.0"
},
"scripts": {
- "build": "lerna run build",
+ "build": "lerna run test && CI=false lerna run build",
"prepare": "husky install",
"bootstrap": "lerna bootstrap",
"format:staged": "pretty-quick --staged",
diff --git a/phone/package.json b/phone/package.json
index 98cd222..7fa837c 100644
--- a/phone/package.json
+++ b/phone/package.json
@@ -28,6 +28,8 @@
},
"devDependencies": {
"@craco/craco": "^6.1.1",
+ "@sentry/integrations": "^6.10.0",
+ "@sentry/webpack-plugin": "^1.16.0",
"@sentry/react": "^5.29.2",
"@sentry/tracing": "^5.29.2",
"@types/enzyme": "^3.10.7",
@@ -40,6 +42,7 @@
"@welldone-software/why-did-you-render": "^6.1.1",
"@wojtekmaj/enzyme-adapter-react-17": "^0.6.1",
"cross-env": "^7.0.3",
+ "dotenv": "^10.0.0",
"ts-loader": "^8.3.0",
"typescript": "^4.3.2"
},
@@ -47,6 +50,7 @@
"i18n:missing": "node --experimental-json-modules i18n.missingKeys.js",
"start": "cross-env PUBLIC_URL=/ craco start",
"watch": "cross-env REACT_APP_IN_GAME=1 craco start",
+ "build:release": "cross-env SENTRY_RELEASE=true craco build",
"build": "craco build",
"test": "craco test --watchAll=false --testMatch **/src/**/*.test.{ts,js,tsx}"
},
diff --git a/phone/public/iframe.webcomp.js b/phone/public/iframe.webcomp.js
new file mode 100644
index 0000000..f26f1d2
--- /dev/null
+++ b/phone/public/iframe.webcomp.js
@@ -0,0 +1,96 @@
+customElements.define(
+ 'x-frame-bypass',
+ class extends HTMLIFrameElement {
+ static get observedAttributes() {
+ return ['src'];
+ }
+ constructor() {
+ super();
+ }
+ attributeChangedCallback() {
+ this.load(this.src);
+ }
+ connectedCallback() {
+ this.sandbox =
+ '' + this.sandbox ||
+ 'allow-forms allow-modals allow-pointer-lock allow-same-origin allow-scripts allow-top-navigation-by-user-activation'; // all except allow-top-navigation
+ }
+ load(url, options) {
+ if (!url || !url.startsWith('http'))
+ throw new Error(`Unable to load src ${url} does not start with http(s)://`);
+ this.srcdoc = `
+
+
+
+
+
+
+`;
+ this.fetchProxy(url, options, 0)
+ .then((res) => res.text())
+ .then((data) => {
+ if (data)
+ this.srcdoc = data.replace(
+ /]*)>/i,
+ `
+
+ `,
+ );
+ })
+ .catch((e) => console.error('Unable to load proxy iframe service', e));
+ }
+ fetchProxy(url, options, i) {
+ const proxies = (options || {}).proxies || [
+ 'https://cors-anywhere.herokuapp.com/',
+ 'https://api.codetabs.com/v1/proxy/?quest=',
+ ];
+ return fetch(proxies[i] + url, options)
+ .then((res) => {
+ if (!res.ok) throw new Error(`${res.status} ${res.statusText}`);
+ return res;
+ })
+ .catch((error) => {
+ if (i === proxies.length - 1) throw error;
+ return this.fetchProxy(url, options, i + 1);
+ });
+ }
+ },
+ { extends: 'iframe' },
+);
diff --git a/phone/public/index.html b/phone/public/index.html
index 8e9020a..f82138b 100644
--- a/phone/public/index.html
+++ b/phone/public/index.html
@@ -8,6 +8,8 @@
/>
+
+
Project Error - New Phone Who Dis
diff --git a/phone/public/media/misc/Outgoing-Dial-Effect.ogg b/phone/public/media/misc/Outgoing-Dial-Effect.ogg
new file mode 100644
index 0000000..52a1720
Binary files /dev/null and b/phone/public/media/misc/Outgoing-Dial-Effect.ogg differ
diff --git a/phone/src/Phone.tsx b/phone/src/Phone.tsx
index a0a9a88..ec6cb71 100644
--- a/phone/src/Phone.tsx
+++ b/phone/src/Phone.tsx
@@ -9,13 +9,10 @@ import { Navigation } from './os/navigation-bar/components/Navigation';
import { useSimcardService } from './os/simcard/hooks/useSimcardService';
import { usePhoneService } from './os/phone/hooks/usePhoneService';
import { useApps } from './os/apps/hooks/useApps';
-import { useNuiRequest } from 'fivem-nui-react-lib';
import { useTwitterService } from './apps/twitter/hooks/useTwitterService';
-import { useMatchService } from './apps/match/hooks/useMatchService';
import { useMarketplaceService } from './apps/marketplace/hooks/useMarketplaceService';
import { useBankService } from './apps/bank/hooks/useBankService';
import { useMessagesService } from './apps/messages/hooks/useMessageService';
-import { usePhotoService } from './apps/camera/hooks/usePhotoService';
import { isSettingsSchemaValid, useSettings } from './apps/settings/hooks/useSettings';
import { useCallService } from './os/call/hooks/useCallService';
import { useDialService } from './apps/dialer/hooks/useDialService';
@@ -32,6 +29,8 @@ import PhoneWrapper from './PhoneWrapper';
import dayjs from 'dayjs';
import DefaultConfig from '../../config.json';
+import { TopLevelErrorComponent } from './ui/components/TopLevelErrorComponent';
+import { useConfig } from './os/phone/hooks/useConfig';
function Phone() {
const { t, i18n } = useTranslation();
@@ -42,8 +41,6 @@ function Phone() {
const { addAlert } = useSnackbar();
- const Nui = useNuiRequest();
-
// Set language from local storage
// This will only trigger on first mount & settings changes
useEffect(() => {
@@ -62,15 +59,16 @@ function Phone() {
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
+ useConfig();
+
useKeyboardService();
usePhoneService();
useSimcardService();
useTwitterService();
- useMatchService();
useMarketplaceService();
useBankService();
useMessagesService();
- usePhotoService();
+ /*usePhotoService();*/
useCallService();
useDialService();
@@ -78,22 +76,24 @@ function Phone() {
return (
-
-
-
-
- <>
-
- {callModal &&
}
- {apps.map((App) => (
-
- ))}
- >
-
-
-
-
-
+
+
+
+
+
+ <>
+
+ {callModal &&
}
+ {apps.map((App) => (
+
+ ))}
+ >
+
+
+
+
+
+
);
}
diff --git a/phone/src/apps/bank/components/transactions/TransactionList.tsx b/phone/src/apps/bank/components/transactions/TransactionList.tsx
index 55fa842..12ecaac 100644
--- a/phone/src/apps/bank/components/transactions/TransactionList.tsx
+++ b/phone/src/apps/bank/components/transactions/TransactionList.tsx
@@ -49,16 +49,6 @@ export const TransactionList = () => {
))}
-
);
diff --git a/phone/src/apps/browser/components/BrowserApp.tsx b/phone/src/apps/browser/components/BrowserApp.tsx
new file mode 100644
index 0000000..f4bc5ad
--- /dev/null
+++ b/phone/src/apps/browser/components/BrowserApp.tsx
@@ -0,0 +1,108 @@
+import { AppWrapper } from '../../../ui/components';
+import React, { Reducer, useReducer, useRef } from 'react';
+import { AppContent } from '../../../ui/components/AppContent';
+import { Box, makeStyles } from '@material-ui/core';
+import { BrowserURLBar } from './BrowserURLBar';
+import { promiseTimeout } from '../../../utils/promiseTimeout';
+import { usePhoneConfig } from '../../../config/hooks/usePhoneConfig';
+
+const useStyles = makeStyles(() => ({
+ iframe: {
+ height: '100%',
+ width: '100%',
+ zoom: 0.5,
+ border: 'none',
+ },
+ root: {
+ height: '100%',
+ display: 'flex',
+ flexDirection: 'column',
+ },
+}));
+
+interface BrowserState {
+ browserUrl: string;
+ browserHistory: string[];
+}
+
+interface ReducerAction {
+ payload: any;
+ type: ReducerActionsType;
+}
+
+enum ReducerActionsType {
+ SET_URL,
+ ADD_HISTORY,
+ RELOAD,
+}
+
+const browserReducer: Reducer = (state, action) => {
+ switch (action.type) {
+ case ReducerActionsType.ADD_HISTORY:
+ if (action.payload === 'about:blank') return state;
+ return { ...state, browserHistory: state.browserHistory.concat(action.payload) };
+ case ReducerActionsType.SET_URL:
+ return { ...state, browserUrl: action.payload };
+ default:
+ throw new Error('Invalid reducer action type');
+ }
+};
+
+export const BrowserApp: React.FC = () => {
+ const classes = useStyles();
+ const [{ appSettings }] = usePhoneConfig();
+ const [browserState, dispatch] = useReducer(browserReducer, {
+ browserUrl: appSettings.browserHomePage,
+ browserHistory: [appSettings.browserHomePage],
+ });
+
+ const { browserHistory, browserUrl } = browserState;
+
+ const iframeRef = useRef(null);
+ const _setBrowserUrl = (newUrl: string) => {
+ const formattedUrl = newUrl.match(/^(http|https):\/\//) ? newUrl : 'https://' + newUrl;
+ dispatch({ payload: browserUrl, type: ReducerActionsType.ADD_HISTORY });
+ dispatch({ payload: formattedUrl, type: ReducerActionsType.SET_URL });
+ };
+
+ const handleGoBack = () => {
+ if (browserHistory.length <= 1) return;
+ // Get last page from history
+ const lastPage = browserHistory[browserHistory.length - 1];
+
+ // Bail if last page is same as current
+ if (lastPage === browserUrl) return;
+ _setBrowserUrl(lastPage);
+ };
+
+ const reloadPage = async () => {
+ const strCopy = browserUrl.slice();
+ dispatch({ payload: 'about:blank', type: ReducerActionsType.SET_URL });
+ await promiseTimeout(100);
+ dispatch({ payload: strCopy, type: ReducerActionsType.SET_URL });
+ };
+
+ return (
+
+
+ 1}
+ setBrowser={_setBrowserUrl}
+ goBack={handleGoBack}
+ reloadPage={reloadPage}
+ />
+
+
+
+
+
+ );
+};
diff --git a/phone/src/apps/browser/components/BrowserURLBar.tsx b/phone/src/apps/browser/components/BrowserURLBar.tsx
new file mode 100644
index 0000000..4cd4783
--- /dev/null
+++ b/phone/src/apps/browser/components/BrowserURLBar.tsx
@@ -0,0 +1,92 @@
+import React, { FocusEventHandler, useRef, useState } from 'react';
+import { makeStyles, Theme, Box, IconButton } from '@material-ui/core';
+import { Cached, KeyboardArrowLeft } from '@material-ui/icons';
+import { InputBase } from '../../../ui/components/Input';
+
+const useStyles = makeStyles((theme: Theme) => ({
+ urlInput: {
+ borderRadius: 18,
+ borderWidth: 1,
+ borderStyle: 'solid',
+ paddingRight: 10,
+ paddingLeft: 10,
+ marginLeft: 5,
+ borderColor: '#787878FF',
+ color: '#909090',
+ transition: 'color 0.1s ease',
+ },
+ urlInputFocused: {
+ color: '#fff',
+ },
+ root: {},
+}));
+
+interface BrowserControlsProps {
+ setBrowser: (url: string) => void;
+ browserUrl: string;
+ reloadPage: () => void;
+ browserHasHistory: boolean;
+ goBack: () => void;
+}
+
+export const BrowserURLBar: React.FC = ({
+ goBack,
+ reloadPage,
+ browserHasHistory,
+ browserUrl,
+ setBrowser,
+}) => {
+ const classes = useStyles();
+ const inputRef = useRef(null);
+ const [inputState, setInputState] = useState('');
+ const [isFocused, setFocus] = useState(false);
+
+ const handleFocus: FocusEventHandler = (e) => {
+ setInputState(browserUrl);
+ setFocus(true);
+ };
+
+ const handleFocusOut: FocusEventHandler = (e) => {
+ setFocus(false);
+ setInputState(browserUrl);
+ };
+
+ const handleChange: React.ChangeEventHandler = (e) => {
+ setInputState(e.target.value);
+ };
+
+ const onEnter: React.KeyboardEventHandler = (e) => {
+ if ((e as any).code !== 'Enter') return;
+ setBrowser(inputState);
+ e.currentTarget.blur();
+ };
+
+ const styledUrl = browserUrl.replace(/(^\w+:|^)\/\//, '');
+
+ const transformedUrl = isFocused ? inputState : styledUrl;
+
+ return (
+
+ reloadPage()}>
+
+
+ {browserHasHistory && (
+ goBack()}>
+
+
+ )}
+
+
+ );
+};
diff --git a/phone/src/apps/camera/components/CameraApp.tsx b/phone/src/apps/camera/components/CameraApp.tsx
index 2e70a3d..7370a0c 100644
--- a/phone/src/apps/camera/components/CameraApp.tsx
+++ b/phone/src/apps/camera/components/CameraApp.tsx
@@ -3,38 +3,20 @@ import { AppWrapper } from '../../../ui/components';
import { AppContent } from '../../../ui/components/AppContent';
import { GalleryGrid } from './grid/GalleryGrid';
import { GalleryModal } from './modal/GalleryModal';
-import InjectDebugData from '../../../os/debug/InjectDebugData';
import { Route, Switch } from 'react-router-dom';
-import { PhotoEvents } from '../../../../../typings/photo';
+import { LoadingSpinner } from '../../../ui/components/LoadingSpinner';
-InjectDebugData([
- {
- app: 'CAMERA',
- method: PhotoEvents.SEND_PHOTOS,
- data: [
- {
- id: 1,
- image: 'https://i.file.glass/noDcb.jpeg',
- },
- {
- id: 2,
- image: 'https://i.file.glass/teUcY.jpeg',
- },
- ],
- },
-]);
-
-const CameraApp = () => {
- return (
-
-
-
+const CameraApp: React.FC = () => (
+
+
+
+ }>
-
-
-
- );
-};
+
+
+
+
+);
export default CameraApp;
diff --git a/phone/src/apps/camera/components/grid/GalleryGrid.tsx b/phone/src/apps/camera/components/grid/GalleryGrid.tsx
index 79e573a..1d3f97e 100644
--- a/phone/src/apps/camera/components/grid/GalleryGrid.tsx
+++ b/phone/src/apps/camera/components/grid/GalleryGrid.tsx
@@ -1,26 +1,50 @@
-import React from 'react';
+import React, { useState } from 'react';
import { Box, Button, CircularProgress } from '@material-ui/core';
import useStyles from './grid.styles';
-import { useCamera } from '../../hooks/useCamera';
import AddIcon from '@material-ui/icons/Add';
import { useHistory } from 'react-router-dom';
import { useQueryParams } from '../../../../common/hooks/useQueryParams';
import { addQueryToLocation } from '../../../../common/utils/addQueryToLocation';
import { getLocationFromUrl } from '../../../../common/utils/getLocationFromUrl';
+import { fetchNui } from '../../../../utils/fetchNui';
+import { ServerPromiseResp } from '../../../../../../typings/common';
+import { GalleryPhoto, PhotoEvents } from '../../../../../../typings/photo';
+import { usePhotoActions } from '../../hooks/usePhotoActions';
+import { usePhotosValue } from '../../hooks/state';
+import { useSnackbar } from '../../../../ui/hooks/useSnackbar';
+import { useTranslation } from 'react-i18next';
export const GalleryGrid = () => {
const classes = useStyles();
const history = useHistory();
const query = useQueryParams();
+ const { addAlert } = useSnackbar();
+ const { t } = useTranslation();
+ const photos = usePhotosValue();
+ const { takePhoto } = usePhotoActions();
+ const [isLoading, setIsLoading] = useState(false);
const referal = query.referal ? decodeURIComponent(query.referal) : '/camera/image';
- const { photos, isLoading, takePhoto } = useCamera();
-
const handlePhotoOpen = (photo) => {
history.push(addQueryToLocation(getLocationFromUrl(referal), 'image', photo.image));
};
+ const handleTakePhoto = () => {
+ setIsLoading(true);
+ fetchNui>(PhotoEvents.TAKE_PHOTO).then((serverResp) => {
+ if (serverResp.status !== 'ok') {
+ return addAlert({
+ message: t('APPS_CAMERA_FAILED_TO_TAKE_PHOTO'),
+ type: 'error',
+ });
+ }
+
+ takePhoto(serverResp.data);
+ setIsLoading(false);
+ });
+ };
+
if (!photos)
return (
@@ -38,11 +62,11 @@ export const GalleryGrid = () => {
{photos.map((photo) => (
diff --git a/phone/src/apps/camera/components/modal/GalleryModal.tsx b/phone/src/apps/camera/components/modal/GalleryModal.tsx
index 144450f..c84e0f6 100644
--- a/phone/src/apps/camera/components/modal/GalleryModal.tsx
+++ b/phone/src/apps/camera/components/modal/GalleryModal.tsx
@@ -8,16 +8,23 @@ import { useHistory } from 'react-router-dom';
import { useQueryParams } from '../../../../common/hooks/useQueryParams';
import { ShareModal } from './ShareModal';
import { GalleryPhoto, PhotoEvents } from '../../../../../../typings/photo';
-import { useNuiRequest } from 'fivem-nui-react-lib';
+import { usePhotoActions } from '../../hooks/usePhotoActions';
+import { fetchNui } from '../../../../utils/fetchNui';
+import { ServerPromiseResp } from '../../../../../../typings/common';
+import { useTranslation } from 'react-i18next';
+import { useSnackbar } from '../../../../ui/hooks/useSnackbar';
export const GalleryModal = () => {
- const Nui = useNuiRequest();
+ const [shareOpen, setShareOpen] = useState(null);
+
const classes = useStyles();
const history = useHistory();
const query = useQueryParams();
- const referal = query.referal || '/camera';
+ const { deletePhoto } = usePhotoActions();
+ const { addAlert } = useSnackbar();
+ const { t } = useTranslation();
- const [shareOpen, setShareOpen] = useState(null);
+ const referal = query.referal || '/camera';
const meta: GalleryPhoto = useMemo(
() => ({ id: parseInt(query.id), image: query.image as string }),
@@ -29,10 +36,17 @@ export const GalleryModal = () => {
};
const handleDeletePhoto = () => {
- Nui.send(PhotoEvents.DELETE_PHOTO, {
+ fetchNui>(PhotoEvents.DELETE_PHOTO, {
image: meta.image,
+ }).then((serverResp) => {
+ if (serverResp.status !== 'ok') {
+ return addAlert({ message: t('APPS_CAMERA_FAILED_TO_DELETE_PHOTO'), type: 'error' });
+ }
+
+ deletePhoto(meta.image);
+
+ history.push(referal);
});
- history.push(referal);
};
const handleSharePhoto = useCallback(() => {
diff --git a/phone/src/apps/camera/hooks/state.ts b/phone/src/apps/camera/hooks/state.ts
index a4a8c3b..8276d1a 100644
--- a/phone/src/apps/camera/hooks/state.ts
+++ b/phone/src/apps/camera/hooks/state.ts
@@ -1,9 +1,33 @@
-import { atom } from 'recoil';
-import { GalleryPhoto } from '../../../../../typings/photo';
+import { atom, selector, useRecoilState, useRecoilValue, useSetRecoilState } from 'recoil';
+import { ServerPromiseResp } from '../../../../../typings/common';
+import { GalleryPhoto, PhotoEvents } from '../../../../../typings/photo';
+import { fetchNui } from '../../../utils/fetchNui';
+import LogDebugEvent from '../../../os/debug/LogDebugEvents';
+import { isEnvBrowser } from '../../../utils/misc';
+import { MockPhotoData } from '../utils/constants';
export const photoState = {
photos: atom({
key: 'galleryPhotos',
- default: [],
+ default: selector({
+ key: 'defaultGalleryPhotos',
+ get: async () => {
+ try {
+ const resp = await fetchNui>(PhotoEvents.FETCH_PHOTOS);
+ LogDebugEvent({ action: 'PhotosFetched', data: resp.data });
+ return resp.data;
+ } catch (e) {
+ if (isEnvBrowser()) {
+ return MockPhotoData;
+ }
+ console.error(e);
+ return [];
+ }
+ },
+ }),
}),
};
+
+export const useSetPhotos = () => useSetRecoilState(photoState.photos);
+export const usePhotos = () => useRecoilState(photoState.photos);
+export const usePhotosValue = () => useRecoilValue(photoState.photos);
diff --git a/phone/src/apps/camera/hooks/usePhotoActions.ts b/phone/src/apps/camera/hooks/usePhotoActions.ts
index c02d84f..e384cdb 100644
--- a/phone/src/apps/camera/hooks/usePhotoActions.ts
+++ b/phone/src/apps/camera/hooks/usePhotoActions.ts
@@ -1,50 +1,22 @@
-import { useTranslation } from 'react-i18next';
-import { useSnackbar } from '../../../ui/hooks/useSnackbar';
-import { photoState } from './state';
-import { useCallback, useState } from 'react';
-import { useNuiCallback } from 'fivem-nui-react-lib';
-import { GalleryPhoto, PhotoEvents } from '../../../../../typings/photo';
-import { usePhotoService } from './usePhotoService';
+import { useSetPhotos } from './state';
+import { useCallback } from 'react';
-/*
export const usePhotoActions = () => {
- const { t } = useTranslation();
- const { addAlert } = useSnackbar();
+ const setPhotos = useSetPhotos();
- const [photos, setPhotos] = usePhotoService();
- const [isUploading, setUploading] = useState(false);
+ const takePhoto = useCallback(
+ (photo) => {
+ setPhotos((curPhotos) => [photo, ...curPhotos]);
+ },
+ [setPhotos],
+ );
- const onPhotoSuccess = useCallback((photo) => {
- setUploading(false);
- if (!photo?.image) return;
- setPhotos((curr) => [photo, ...curr]);
- }, [setPhotos])
+ const deletePhoto = useCallback(
+ (image: string) => {
+ setPhotos((curPhotos) => [...curPhotos].filter((meta) => meta.image !== image));
+ },
+ [setPhotos],
+ );
- const onPhotoError = useCallback(
- (i18nKey) => {
- setUploading(false);
- addAlert({ type: 'error', message: t(i18nKey) });
- },
- [addAlert, t],
- );
-
- const [_takePhoto] = useNuiCallback(
- 'CAMERA',
- PhotoEvents.TAKE_PHOTO,
- onPhotoSuccess,
- onPhotoError,
- );
-
- const takePhoto = () => {
- _takePhoto(undefined, { timeout: 60000 });
- };
-
-
- return {
- photos,
- setPhotos,
- takePhoto,
- isLoading: isUploading
- }
-
-}*/
+ return { takePhoto, deletePhoto };
+};
diff --git a/phone/src/apps/camera/hooks/usePhotoService.ts b/phone/src/apps/camera/hooks/usePhotoService.ts
deleted file mode 100644
index ff07afe..0000000
--- a/phone/src/apps/camera/hooks/usePhotoService.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-import { useSetRecoilState } from 'recoil';
-import { useNuiEvent } from 'fivem-nui-react-lib';
-import { photoState } from './state';
-import { PhotoEvents } from '../../../../../typings/photo';
-
-export const usePhotoService = () => {
- const setPhotos = useSetRecoilState(photoState.photos);
- useNuiEvent('CAMERA', PhotoEvents.SEND_PHOTOS, setPhotos);
-};
diff --git a/phone/src/apps/camera/utils/constants.ts b/phone/src/apps/camera/utils/constants.ts
new file mode 100644
index 0000000..a327499
--- /dev/null
+++ b/phone/src/apps/camera/utils/constants.ts
@@ -0,0 +1,10 @@
+export const MockPhotoData = [
+ {
+ id: 1,
+ image: 'https://beta.iodine.gg/noDcb.jpeg',
+ },
+ {
+ id: 2,
+ image: 'https://beta.iodine.gg/teUcY.jpeg',
+ },
+];
diff --git a/phone/src/apps/contacts/components/ContactsApp.tsx b/phone/src/apps/contacts/components/ContactsApp.tsx
index b953ffb..783d93e 100644
--- a/phone/src/apps/contacts/components/ContactsApp.tsx
+++ b/phone/src/apps/contacts/components/ContactsApp.tsx
@@ -7,7 +7,6 @@ import { Route } from 'react-router-dom';
import ContactsInfoPage from './views/ContactInfo';
import { ContactPage } from './views/ContactsPage';
import { ContactsThemeProvider } from '../providers/ContactsThemeProvider';
-import { ContactEvents } from '../../../../../typings/contact';
import PersonAddIcon from '@material-ui/icons/PersonAdd';
import Fab from '@material-ui/core/Fab';
import { useHistory } from 'react-router';
diff --git a/phone/src/apps/contacts/components/List/ContactList.tsx b/phone/src/apps/contacts/components/List/ContactList.tsx
index d250c2c..3e44f6d 100644
--- a/phone/src/apps/contacts/components/List/ContactList.tsx
+++ b/phone/src/apps/contacts/components/List/ContactList.tsx
@@ -7,14 +7,13 @@ import MoreVertIcon from '@material-ui/icons/MoreVert';
import { SearchContacts } from './SearchContacts';
import { useHistory } from 'react-router-dom';
import LogDebugEvent from '../../../../os/debug/LogDebugEvents';
-import { CallEvents } from '../../../../../../typings/call';
-import { useNuiRequest } from 'fivem-nui-react-lib';
import { useFilteredContacts } from '../../hooks/state';
+import { useCall } from '../../../../os/call/hooks/useCall';
export const ContactList = () => {
const filteredContacts = useFilteredContacts();
const history = useHistory();
- const Nui = useNuiRequest();
+ const { initializeCall } = useCall();
const openContactInfo = (contactId: number) => {
history.push(`/contacts/${contactId}`);
@@ -26,9 +25,7 @@ export const ContactList = () => {
level: 2,
data: true,
});
- Nui.send(CallEvents.INITIALIZE_CALL, {
- number,
- });
+ initializeCall(number);
};
const handleMessage = (phoneNumber: string) => {
diff --git a/phone/src/apps/contacts/components/views/ContactInfo.tsx b/phone/src/apps/contacts/components/views/ContactInfo.tsx
index 2b30cd0..e01c4a1 100644
--- a/phone/src/apps/contacts/components/views/ContactInfo.tsx
+++ b/phone/src/apps/contacts/components/views/ContactInfo.tsx
@@ -7,7 +7,7 @@ import { useContactActions } from '../../hooks/useContactActions';
import ArrowBackIcon from '@material-ui/icons/ArrowBack';
import LogDebugEvent from '../../../../os/debug/LogDebugEvents';
import { useQueryParams } from '../../../../common/hooks/useQueryParams';
-import { Contact, ContactEvents } from '../../../../../../typings/contact';
+import { Contact, ContactEvents, ContactsDatabaseLimits } from '../../../../../../typings/contact';
import { TextField } from '../../../../ui/components/Input';
import { fetchNui } from '../../../../utils/fetchNui';
import { ServerPromiseResp } from '../../../../../../typings/common';
@@ -72,6 +72,24 @@ const ContactsInfoPage = () => {
const { t } = useTranslation();
+ const handleNumberChange: React.ChangeEventHandler = (e) => {
+ const inputVal = e.target.value;
+ if (inputVal.length === ContactsDatabaseLimits.number) return;
+ setNumber(e.target.value);
+ };
+
+ const handleDisplayChange: React.ChangeEventHandler = (e) => {
+ const inputVal = e.target.value;
+ if (inputVal.length === ContactsDatabaseLimits.display) return;
+ setName(e.target.value);
+ };
+
+ const handleAvatarChange: React.ChangeEventHandler = (e) => {
+ const inputVal = e.target.value;
+ if (inputVal.length === ContactsDatabaseLimits.avatar) return;
+ setAvatar(e.target.value);
+ };
+
useEffect(() => {
if (addNumber) {
setNumber(addNumber);
@@ -173,9 +191,10 @@ const ContactsInfoPage = () => {
setName(e.target.value)}
+ onChange={handleDisplayChange}
label={t('APPS_CONTACT_FORM_NAME')}
fullWidth
inputProps={{
@@ -184,8 +203,9 @@ const ContactsInfoPage = () => {
/>
setNumber(e.target.value)}
+ onChange={handleNumberChange}
label={t('APPS_CONTACT_FORM_NUMBER')}
fullWidth
inputProps={{
@@ -193,11 +213,12 @@ const ContactsInfoPage = () => {
}}
/>
setAvatar(e.target.value)}
+ onChange={handleAvatarChange}
inputProps={{
className: classes.inputProps,
}}
diff --git a/phone/src/apps/dialer/components/DialerApp.tsx b/phone/src/apps/dialer/components/DialerApp.tsx
index 86649e2..f9d0966 100644
--- a/phone/src/apps/dialer/components/DialerApp.tsx
+++ b/phone/src/apps/dialer/components/DialerApp.tsx
@@ -7,11 +7,8 @@ import { useApp } from '../../../os/apps/hooks/useApps';
import { Switch, Route } from 'react-router-dom';
import DialPage from './views/DialPage';
import DialerNavBar from './DialerNavBar';
-import { useDialHistory } from '../hooks/useDialHistory';
-import InjectDebugData from '../../../os/debug/InjectDebugData';
import { ContactList } from '../../contacts/components/List/ContactList';
import { DialerThemeProvider } from '../providers/DialerThemeProvider';
-import { CallEvents } from '../../../../../typings/call';
import { Box, CircularProgress } from '@material-ui/core';
const LoadingSpinner: React.FC = () => (
@@ -21,8 +18,6 @@ const LoadingSpinner: React.FC = () => (
);
export const DialerApp = () => {
- const history = useDialHistory();
-
const dialer = useApp('DIALER');
return (
@@ -35,7 +30,7 @@ export const DialerApp = () => {
}>
-
+
@@ -46,22 +41,3 @@ export const DialerApp = () => {
);
};
-
-InjectDebugData([
- {
- app: 'DIALER',
- method: CallEvents.SET_CALL_HISTORY,
- data: [
- {
- id: 1,
- transmitter: '636-6496',
- start: 1615946292,
- },
- {
- id: 2,
- transmitter: '777-7777',
- start: 1615946292,
- },
- ],
- },
-]);
diff --git a/phone/src/apps/dialer/components/DialerInput.tsx b/phone/src/apps/dialer/components/DialerInput.tsx
index 8b1a080..bba4228 100644
--- a/phone/src/apps/dialer/components/DialerInput.tsx
+++ b/phone/src/apps/dialer/components/DialerInput.tsx
@@ -4,11 +4,10 @@ import { makeStyles, Theme } from '@material-ui/core/styles';
import PhoneIcon from '@material-ui/icons/Phone';
import PersonAddIcon from '@material-ui/icons/PersonAdd';
import { DialInputCtx, IDialInputCtx } from '../context/InputContext';
-import { useNuiRequest } from 'fivem-nui-react-lib';
import { useHistory } from 'react-router-dom';
-import { CallEvents } from '../../../../../typings/call';
import { useTranslation } from 'react-i18next';
import { InputBase } from '../../../ui/components/Input';
+import { useCall } from '../../../os/call/hooks/useCall';
const useStyles = makeStyles((theme: Theme) => ({
root: {
@@ -30,17 +29,15 @@ const useStyles = makeStyles((theme: Theme) => ({
}));
export const DialerInput = () => {
- const Nui = useNuiRequest();
const classes = useStyles();
const history = useHistory();
const { t } = useTranslation();
+ const { initializeCall } = useCall();
const { inputVal, set } = useContext(DialInputCtx);
const handleCall = (number: string) => {
- Nui.send(CallEvents.INITIALIZE_CALL, {
- number,
- });
+ initializeCall(number);
};
const handleNewContact = (number: string) => {
diff --git a/phone/src/apps/dialer/components/views/DialerHistory.tsx b/phone/src/apps/dialer/components/views/DialerHistory.tsx
index 42547a1..14f1b08 100644
--- a/phone/src/apps/dialer/components/views/DialerHistory.tsx
+++ b/phone/src/apps/dialer/components/views/DialerHistory.tsx
@@ -5,15 +5,16 @@ import PhoneIcon from '@material-ui/icons/Phone';
import PersonAddIcon from '@material-ui/icons/PersonAdd';
import { List } from '../../../../ui/components/List';
import { ListItem } from '../../../../ui/components/ListItem';
-import { useNuiRequest } from 'fivem-nui-react-lib';
-import { useSimcard } from '../../../../os/simcard/hooks/useSimcard';
import { useContactActions } from '../../../contacts/hooks/useContactActions';
-import { CallEvents, CallHistoryItem } from '../../../../../../typings/call';
+import { CallHistoryItem } from '../../../../../../typings/call';
import { useTranslation } from 'react-i18next';
import { Box, IconButton, ListItemIcon, ListItemText } from '@material-ui/core';
import { useHistory } from 'react-router-dom';
import { makeStyles, Theme } from '@material-ui/core/styles';
import dayjs from 'dayjs';
+import { useMyPhoneNumber } from '../../../../os/simcard/hooks/useMyPhoneNumber';
+import { useDialHistory } from '../../hooks/useDialHistory';
+import { useCall } from '../../../../os/call/hooks/useCall';
const useStyles = makeStyles((theme: Theme) => ({
callForward: {
@@ -24,21 +25,17 @@ const useStyles = makeStyles((theme: Theme) => ({
},
}));
-export const DialerHistory = ({ calls }) => {
- const Nui = useNuiRequest();
- const { number: myNumber } = useSimcard();
+export const DialerHistory: React.FC = () => {
+ const myNumber = useMyPhoneNumber();
const { getDisplayByNumber } = useContactActions();
-
+ const { initializeCall } = useCall();
+ const calls = useDialHistory();
const classes = useStyles();
-
const history = useHistory();
-
const { t } = useTranslation();
const handleCall = (phoneNumber) => {
- Nui.send(CallEvents.INITIALIZE_CALL, {
- number: phoneNumber,
- });
+ initializeCall(phoneNumber);
};
if (!calls?.length) {
diff --git a/phone/src/apps/dialer/hooks/state.ts b/phone/src/apps/dialer/hooks/state.ts
index d3f3748..af090ad 100644
--- a/phone/src/apps/dialer/hooks/state.ts
+++ b/phone/src/apps/dialer/hooks/state.ts
@@ -1,9 +1,29 @@
-import { atom } from 'recoil';
-import { CallHistoryItem } from '../../../../../typings/call';
+import { atom, selector } from 'recoil';
+import { CallEvents, CallHistoryItem } from '../../../../../typings/call';
+import { fetchNui } from '../../../utils/fetchNui';
+import { ServerPromiseResp } from '../../../../../typings/common';
+import LogDebugEvent from '../../../os/debug/LogDebugEvents';
+import { isEnvBrowser } from '../../../utils/misc';
+import { MockHistoryData } from '../utils/constants';
export const dialState = {
history: atom({
key: 'dialHistory',
- default: [],
+ default: selector({
+ key: 'dialHistoryDefault',
+ get: async () => {
+ try {
+ const resp = await fetchNui>(CallEvents.FETCH_CALLS);
+ LogDebugEvent({ action: 'ContactsFetched', data: resp.data });
+ return resp.data;
+ } catch (e) {
+ if (isEnvBrowser()) {
+ return MockHistoryData;
+ }
+ console.error(e);
+ return [];
+ }
+ },
+ }),
}),
};
diff --git a/phone/src/apps/dialer/hooks/useDialHistory.ts b/phone/src/apps/dialer/hooks/useDialHistory.ts
index d7d07f8..1bcf8a2 100644
--- a/phone/src/apps/dialer/hooks/useDialHistory.ts
+++ b/phone/src/apps/dialer/hooks/useDialHistory.ts
@@ -1,6 +1,4 @@
import { useRecoilValue } from 'recoil';
import { dialState } from './state';
-export const useDialHistory = () => {
- return useRecoilValue(dialState.history);
-};
+export const useDialHistory = () => useRecoilValue(dialState.history);
diff --git a/phone/src/apps/dialer/hooks/useDialService.ts b/phone/src/apps/dialer/hooks/useDialService.ts
index 4a3eb03..2e02675 100644
--- a/phone/src/apps/dialer/hooks/useDialService.ts
+++ b/phone/src/apps/dialer/hooks/useDialService.ts
@@ -1,6 +1,4 @@
-import { useSetRecoilState } from 'recoil';
import { useNuiEvent } from 'fivem-nui-react-lib';
-import { dialState } from './state';
import { CallEvents } from '../../../../../typings/call';
import { IAlert, useSnackbar } from '../../../ui/hooks/useSnackbar';
import { useTranslation } from 'react-i18next';
@@ -16,7 +14,5 @@ export const useDialService = () => {
});
};
- const setHistory = useSetRecoilState(dialState.history);
- useNuiEvent('DIALER', CallEvents.SET_CALL_HISTORY, setHistory);
useNuiEvent('DIALER', CallEvents.SEND_ALERT, handleAddAlert);
};
diff --git a/phone/src/apps/dialer/utils/constants.ts b/phone/src/apps/dialer/utils/constants.ts
new file mode 100644
index 0000000..5d131bb
--- /dev/null
+++ b/phone/src/apps/dialer/utils/constants.ts
@@ -0,0 +1,22 @@
+import { CallHistoryItem } from '../../../../../typings/call';
+
+export const MockHistoryData: CallHistoryItem[] = [
+ {
+ id: 1,
+ identifier: 'ca839e8c-ef9d-40bd-b6a3-d531ee58149f',
+ transmitter: '704-1549',
+ receiver: '704-1549',
+ is_accepted: true,
+ start: '1615939174',
+ end: null,
+ },
+ {
+ id: 2,
+ identifier: 'b8080a50-ad30-4ee9-84cb-00688e2bf167',
+ transmitter: '704-1549',
+ receiver: '704-1549',
+ is_accepted: false,
+ start: '1615939850',
+ end: null,
+ },
+];
diff --git a/phone/src/apps/marketplace/components/MarketplaceApp.tsx b/phone/src/apps/marketplace/components/MarketplaceApp.tsx
index 3fcce5c..1be2c6e 100644
--- a/phone/src/apps/marketplace/components/MarketplaceApp.tsx
+++ b/phone/src/apps/marketplace/components/MarketplaceApp.tsx
@@ -14,7 +14,7 @@ export const MarketplaceApp = () => {
return (
-
+
diff --git a/phone/src/apps/marketplace/components/MarketplaceList/ListingActions.tsx b/phone/src/apps/marketplace/components/MarketplaceList/ListingActions.tsx
index ef2058e..b214279 100644
--- a/phone/src/apps/marketplace/components/MarketplaceList/ListingActions.tsx
+++ b/phone/src/apps/marketplace/components/MarketplaceList/ListingActions.tsx
@@ -2,18 +2,17 @@ import { Box, Tooltip, Button } from '@material-ui/core';
import { makeStyles, Theme } from '@material-ui/core/styles';
import React from 'react';
import { MarketplaceEvents, MarketplaceListing } from '../../../../../../typings/marketplace';
-import { useSimcard } from '../../../../os/simcard/hooks/useSimcard';
import DeleteIcon from '@material-ui/icons/Delete';
import ReportIcon from '@material-ui/icons/Report';
import ChatIcon from '@material-ui/icons/Chat';
import PhoneIcon from '@material-ui/icons/Phone';
-import { useNuiRequest } from 'fivem-nui-react-lib';
import { useTranslation } from 'react-i18next';
import { useHistory } from 'react-router';
-import { CallEvents } from '../../../../../../typings/call';
import { fetchNui } from '../../../../utils/fetchNui';
import { useSnackbar } from '../../../../ui/hooks/useSnackbar';
import { ServerPromiseResp } from '../../../../../../typings/common';
+import { useMyPhoneNumber } from '../../../../os/simcard/hooks/useMyPhoneNumber';
+import { useCall } from '../../../../os/call/hooks/useCall';
const useStyles = makeStyles((theme: Theme) => ({
icon: {
@@ -22,11 +21,11 @@ const useStyles = makeStyles((theme: Theme) => ({
}));
export const ListingActions: React.FC = ({ children, ...listing }) => {
- const Nui = useNuiRequest();
const classes = useStyles();
- const { number: myNumber } = useSimcard();
+ const myNumber = useMyPhoneNumber();
const { t } = useTranslation();
const history = useHistory();
+ const { initializeCall } = useCall();
const { addAlert } = useSnackbar();
const handleDeleteListing = () => {
@@ -66,9 +65,7 @@ export const ListingActions: React.FC = ({ children, ...list
};
const handleCall = () => {
- Nui.send(CallEvents.INITIALIZE_CALL, {
- number: listing.number,
- });
+ initializeCall(listing.number);
};
const handleMessage = () => {
diff --git a/phone/src/apps/marketplace/hooks/state.ts b/phone/src/apps/marketplace/hooks/state.ts
index f45fb03..f123ef5 100644
--- a/phone/src/apps/marketplace/hooks/state.ts
+++ b/phone/src/apps/marketplace/hooks/state.ts
@@ -26,7 +26,7 @@ const defaultData: MarketplaceListing[] = [
},
];
-const listingState = atom({
+export const listingState = atom({
key: 'listings',
default: selector({
key: 'defaultListings',
diff --git a/phone/src/apps/marketplace/hooks/useMarketplaceActions.ts b/phone/src/apps/marketplace/hooks/useMarketplaceActions.ts
index 762c100..16e5a2a 100644
--- a/phone/src/apps/marketplace/hooks/useMarketplaceActions.ts
+++ b/phone/src/apps/marketplace/hooks/useMarketplaceActions.ts
@@ -1,6 +1,7 @@
import { useCallback } from 'react';
-import { useSetListings } from './state';
+import { listingState, useSetListings } from './state';
import { MarketplaceListing } from '../../../../../typings/marketplace';
+import { useRecoilValueLoadable } from 'recoil';
interface MarketplaceActionValues {
deleteListing: (id: number) => void;
@@ -8,20 +9,29 @@ interface MarketplaceActionValues {
}
export const useMarketplaceActions = (): MarketplaceActionValues => {
+ const { state: valueLoading, contents } = useRecoilValueLoadable(listingState);
const setListings = useSetListings();
const deleteListing = useCallback(
(id: number) => {
+ // Make sure our atom is actually loaded before we attempt a dispatch
+ if (valueLoading !== 'hasValue') return;
+ // Tts possible for the init fetch to fail and empty array is passed. In that case
+ // block dispatch
+ if (!contents.length) return;
+
setListings((curListings) => [...curListings].filter((listing) => listing.id !== id));
},
- [setListings],
+ [setListings, valueLoading, contents],
);
const addListing = useCallback(
(listing: MarketplaceListing) => {
+ // Make sure our atom is actually loaded before we attempt a dispatch
+ if (valueLoading !== 'hasValue') return;
setListings((curListings) => [...curListings, listing]);
},
- [setListings],
+ [setListings, valueLoading],
);
return { deleteListing, addListing };
diff --git a/phone/src/apps/marketplace/marketplace.theme.ts b/phone/src/apps/marketplace/marketplace.theme.ts
index 43d145b..6ee598b 100644
--- a/phone/src/apps/marketplace/marketplace.theme.ts
+++ b/phone/src/apps/marketplace/marketplace.theme.ts
@@ -1,16 +1,16 @@
import { common, red } from '@material-ui/core/colors';
-export const SELLOUT_APP_PRIMARY_COLOR = red[500];
-export const SELLOUT_APP_ICON_COLOR = common.white;
-export const SELLOUT_APP_TEXT_COLOR = common.black;
+export const MARKETPLACE_APP_PRIMARY_COLOR = red[500];
+export const MARKETPLACE_APP_ICON_COLOR = common.white;
+export const MARKETPLACE_APP_TEXT_COLOR = common.black;
const theme = {
palette: {
primary: {
- main: SELLOUT_APP_PRIMARY_COLOR,
+ main: MARKETPLACE_APP_PRIMARY_COLOR,
dark: red[700],
light: red[200],
- contrastText: SELLOUT_APP_TEXT_COLOR,
+ contrastText: MARKETPLACE_APP_TEXT_COLOR,
},
},
};
diff --git a/phone/src/apps/marketplace/providers/MarketplaceThemeProvider.tsx b/phone/src/apps/marketplace/providers/MarketplaceThemeProvider.tsx
index e9a9cd9..92674c6 100644
--- a/phone/src/apps/marketplace/providers/MarketplaceThemeProvider.tsx
+++ b/phone/src/apps/marketplace/providers/MarketplaceThemeProvider.tsx
@@ -1,5 +1,5 @@
import { createAppThemeProvider } from '../../../os/apps/utils/createAppThemeProvider';
-import selloutTheme from '../marketplace.theme';
+import marketplaceTheme from '../marketplace.theme';
-export const MarketplaceThemeProvider = createAppThemeProvider(selloutTheme);
+export const MarketplaceThemeProvider = createAppThemeProvider(marketplaceTheme);
diff --git a/phone/src/apps/match/components/MatchApp.tsx b/phone/src/apps/match/components/MatchApp.tsx
index 63385c9..6588575 100644
--- a/phone/src/apps/match/components/MatchApp.tsx
+++ b/phone/src/apps/match/components/MatchApp.tsx
@@ -1,29 +1,17 @@
-import React, { useState, useEffect } from 'react';
-import { Route } from 'react-router-dom';
+import React, { useState } from 'react';
import { AppWrapper } from '../../../ui/components';
import { AppTitle } from '../../../ui/components/AppTitle';
import { AppContent } from '../../../ui/components/AppContent';
import { useApp } from '../../../os/apps/hooks/useApps';
-import InjectDebugData from '../../../os/debug/InjectDebugData';
import { MatchThemeProvider } from '../providers/MatchThemeProvider';
-import { useNuiRequest } from 'fivem-nui-react-lib';
import MatchBottomNavigation from '../components/BottomNavigation';
-import MatchPage from './views/MatchPage';
-import ProfileEditor from './views/ProfileEditor';
-import MatchList from './views/MatchList';
-import { MatchEvents } from '../../../../../typings/match';
-import { useProfile } from '../hooks/useProfile';
+import MatchContainer from './MatchContainer';
+import { LoadingSpinner } from '../../../ui/components/LoadingSpinner';
export const MatchApp = () => {
- const Nui = useNuiRequest();
const match = useApp('MATCH');
const [activePage, setActivePage] = useState(0);
- const { noProfileExists } = useProfile();
-
- useEffect(() => {
- Nui.send(MatchEvents.INITIALIZE);
- }, [Nui]);
const handlePageChange = (e, page) => setActivePage(page);
@@ -31,128 +19,13 @@ export const MatchApp = () => {
- {noProfileExists ? (
-
-
-
- ) : (
- <>
-
-
-
-
-
-
- >
- )}
+
+ }>
+
+
+
+
);
};
-
-InjectDebugData(
- [
- {
- app: 'MATCH',
- method: MatchEvents.GET_PROFILES_SUCCESS,
- data: [
- {
- id: 1,
- image:
- 'https://cdn.vox-cdn.com/thumbor/9xCALlkm2Mc0HQk8kMr1Ui3YNbc=/0x0:5464x3070/920x613/filters:focal(2295x1098:3169x1972):format(webp)/cdn.vox-cdn.com/uploads/chorus_image/image/67031748/shutterstock_1450403549.0.jpg',
- name: 'Person Alpha',
- bio:
- 'Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo.',
- createdAt: 1615932985,
- updatedAt: 1615932985,
- lastActive: 1616004986,
- job: 'Gardener',
- location: 'Grapeseed',
- tags: 'gardening',
- phoneNumber: '987-6543',
- },
- {
- id: 2,
- image:
- 'https://media.cntraveler.com/photos/5f8f09c3a078e9112956774d/16:9/w_1600%2Cc_limit/Chicago-GettyImages-1065188752.jpg',
- name: 'Person Beta',
- bio: 'l impedit quo minus id quod maxime placeat facere possimus',
- createdAt: 1615846585,
- updatedAt: 1615846585,
- lastActive: 1615850185,
- job: 'Mechanic',
- location: 'Harmony',
- tags: 'tinkering,robotics',
- phoneNumber: '654-3219',
- },
- {
- id: 3,
- image: 'https://www.langan.com/wp-content/uploads/2019/02/Boston-996x554.jpg',
- name: 'Person Charlie',
- bio: 'ut aut reiciendis voluptatibus',
- createdAt: 1615850185,
- updatedAt: 1615850185,
- lastActive: 1613607385,
- job: 'Lawyer',
- location: 'Los Santos',
- tags: 'reading,coolstuff, coffee',
- phoneNumber: '123-4567',
- },
- ],
- },
- {
- app: 'MATCH',
- method: MatchEvents.GET_MY_PROFILE_SUCCESS,
- data: {
- id: 4,
- image:
- 'https://www.middlebury.edu/institute/sites/www.middlebury.edu.institute/files/styles/1040x585/public/2018-10/Nashville-skyline.jpg?fv=mS11EKrT&itok=HNhHqYUX',
- name: 'Kire Says',
- bio: "Kire's cool profile that has many cool things. And others.",
- createdAt: 1615932985,
- updatedAt: 1615932985,
- lastActive: 1616004986,
- job: 'Engineer',
- location: 'Boston',
- tags: 'code,books',
- phoneNumber: '999-9999',
- },
- },
- {
- app: 'MATCH',
- method: MatchEvents.GET_MATCHES_SUCCESS,
- data: [
- {
- id: 5,
- image:
- 'https://media.cntraveler.com/photos/5f8f09c3a078e9112956774d/16:9/w_1600%2Cc_limit/Chicago-GettyImages-1065188752.jpg',
- name: 'Person Delta',
- bio: 'l impedit quo minus id quod maxime placeat facere possimus',
- createdAt: 1615846585,
- updatedAt: 1615846585,
- lastActive: 1615850185,
- matchedAt: 1613607385,
- job: 'Mechanic',
- location: 'Harmony',
- tags: 'tinkering,robotics',
- phoneNumber: '654-3219',
- },
- {
- id: 6,
- image: 'https://www.langan.com/wp-content/uploads/2019/02/Boston-996x554.jpg',
- name: 'Person Echo',
- bio: 'ut aut reiciendis voluptatibus',
- createdAt: 1615850185,
- updatedAt: 1615850185,
- lastActive: 1613607385,
- job: 'Lawyer',
- location: 'Los Santos',
- tags: 'reading,coolstuff, coffee',
- phoneNumber: '123-4567',
- matchedAt: 1613607385,
- },
- ],
- },
- ],
- 200,
-);
diff --git a/phone/src/apps/match/components/MatchContainer.tsx b/phone/src/apps/match/components/MatchContainer.tsx
new file mode 100644
index 0000000..e5fb50e
--- /dev/null
+++ b/phone/src/apps/match/components/MatchContainer.tsx
@@ -0,0 +1,35 @@
+import React, { useEffect } from 'react';
+import { LoadingSpinner } from '../../../ui/components/LoadingSpinner';
+import ProfileEditor from './views/ProfileEditor';
+import { Route } from 'react-router-dom';
+import MatchPage from './views/MatchPage';
+import MatchList from './views/MatchList';
+import { useProfile } from '../hooks/useProfile';
+
+const MatchContainer: React.FC = () => {
+ const { profile, noProfileExists, setNoProfileExists } = useProfile();
+
+ useEffect(() => {
+ if (!profile) {
+ setNoProfileExists(true);
+ } else {
+ setNoProfileExists(false);
+ }
+ }, [setNoProfileExists, profile]);
+
+ return (
+ }>
+ {noProfileExists ? (
+
+ ) : (
+ <>
+
+
+
+ >
+ )}
+
+ );
+};
+
+export default MatchContainer;
diff --git a/phone/src/apps/match/components/profile/Profile.tsx b/phone/src/apps/match/components/profile/Profile.tsx
index 60454b8..a4e21f4 100644
--- a/phone/src/apps/match/components/profile/Profile.tsx
+++ b/phone/src/apps/match/components/profile/Profile.tsx
@@ -6,7 +6,6 @@ import { useTranslation } from 'react-i18next';
import { FormattedProfile, FormattedMatch } from '../../../../../../typings/match';
const useStyles = makeStyles({
- root: {},
tags: {
position: 'absolute',
bottom: '40%',
diff --git a/phone/src/apps/match/components/profile/ProfileForm.tsx b/phone/src/apps/match/components/profile/ProfileForm.tsx
index c07b5f4..b47ec26 100644
--- a/phone/src/apps/match/components/profile/ProfileForm.tsx
+++ b/phone/src/apps/match/components/profile/ProfileForm.tsx
@@ -1,7 +1,6 @@
import React, { useState } from 'react';
import { makeStyles } from '@material-ui/core/styles';
import { useTranslation } from 'react-i18next';
-import { useNuiRequest } from 'fivem-nui-react-lib';
import {
Profile as IProfile,
FormattedProfile,
@@ -13,6 +12,10 @@ import { Card } from '@material-ui/core';
import Profile from './Profile';
import { usePhone } from '../../../../os/phone/hooks/usePhone';
import PageText from '../PageText';
+import { fetchNui } from '../../../../utils/fetchNui';
+import { ServerPromiseResp } from '../../../../../../typings/common';
+import { useSnackbar } from '../../../../ui/hooks/useSnackbar';
+import { useSetMyProfile } from '../../hooks/state';
const useStyles = makeStyles({
root: {
@@ -39,10 +42,11 @@ interface IProps {
}
export function ProfileForm({ profile, showPreview }: IProps) {
- const Nui = useNuiRequest();
const classes = useStyles();
const { t } = useTranslation();
const { ResourceConfig } = usePhone();
+ const { addAlert } = useSnackbar();
+ const setMyProfile = useSetMyProfile();
// note that this assumes we are defensively checking
// that profile is not null in a parent above this component.
@@ -74,10 +78,24 @@ export function ProfileForm({ profile, showPreview }: IProps) {
tags: update.tagList.join(','),
};
const event = profile ? MatchEvents.UPDATE_MY_PROFILE : MatchEvents.CREATE_MY_PROFILE;
- Nui.send(event, updatedProfile);
+ fetchNui>(event, updatedProfile).then((resp) => {
+ if (resp.status !== 'ok') {
+ return addAlert({
+ message: 'APPS_MATCH_UPDATE_PROFILE_FAILED',
+ type: 'error',
+ });
+ }
+
+ setMyProfile(resp.data);
+
+ addAlert({
+ message: 'APPS_MATCH_UPDATE_PROFILE_SUCCEEDED',
+ type: 'success',
+ });
+ });
};
- if (!profile && !ResourceConfig.match.allowEditableProfileName) {
+ if (!profile /* && !ResourceConfig.match.allowEditableProfileName*/) {
return ;
}
@@ -108,6 +126,7 @@ export function ProfileForm({ profile, showPreview }: IProps) {
value={update.bio}
handleChange={setBio}
multiline
+ maxLength={250}
/>
diff --git a/phone/src/apps/match/components/views/MatchList.tsx b/phone/src/apps/match/components/views/MatchList.tsx
index b56f92f..eb4ea48 100644
--- a/phone/src/apps/match/components/views/MatchList.tsx
+++ b/phone/src/apps/match/components/views/MatchList.tsx
@@ -1,13 +1,11 @@
-import React, { useEffect, useState } from 'react';
+import React from 'react';
import { useTranslation } from 'react-i18next';
import { Box, makeStyles } from '@material-ui/core';
-import { useMatches } from '../../hooks/useMatches';
import Loader from '../Loader';
import PageText from '../PageText';
import Match from '../matches/Match';
-import { useNuiRequest } from 'fivem-nui-react-lib';
-import { MatchEvents } from '../../../../../../typings/match';
+import { useMatches } from '../../hooks/useMatches';
const useStyles = makeStyles({
root: {
@@ -15,30 +13,13 @@ const useStyles = makeStyles({
},
});
-const MINIMUM_LOAD_TIME = 1500;
-
function MatchList() {
- const Nui = useNuiRequest();
const classes = useStyles();
const { t } = useTranslation();
const { matches, error } = useMatches();
- const [loaded, setLoaded] = useState(false);
-
- // We make the conscious descion here to fetch matches everytime
- // a user loads this page because this list is dependent on
- // other player's database interactions (i.e. their likes/dislikes)
- // not just the current players.
- // This is less performant but means that we will always have the
- // correct state when the player views this page
- useEffect(() => {
- Nui.send(MatchEvents.GET_MATCHES);
- window.setTimeout(() => {
- setLoaded(true);
- }, MINIMUM_LOAD_TIME);
- }, [Nui]);
if (error) return ;
- if (!loaded || !matches) return ;
+ if (!matches) return ;
if (matches.length === 0) return ;
return (
diff --git a/phone/src/apps/match/components/views/MatchPage.tsx b/phone/src/apps/match/components/views/MatchPage.tsx
index 99d38c3..6ab2e25 100644
--- a/phone/src/apps/match/components/views/MatchPage.tsx
+++ b/phone/src/apps/match/components/views/MatchPage.tsx
@@ -7,6 +7,7 @@ import { useProfiles } from '../../hooks/useProfiles';
import Loader from '../Loader';
import PageText from '../PageText';
import ActiveProfile from '../ActiveProfile';
+import { useMatchActions } from '../../hooks/useMatchActions';
const useStyles = makeStyles({
root: {
@@ -23,7 +24,8 @@ const MINIMUM_LOAD_TIME = 1250;
const MatchPage = () => {
const classes = useStyles();
const { t } = useTranslation();
- const { profiles, error, activeProfile, setViewed } = useProfiles();
+ const { profiles, error, activeProfile } = useProfiles();
+ const { setViewed } = useMatchActions();
const [loaded, setLoaded] = useState(false);
useEffect(() => {
diff --git a/phone/src/apps/match/components/views/ProfileEditor.tsx b/phone/src/apps/match/components/views/ProfileEditor.tsx
index 17fc1ad..06ed999 100644
--- a/phone/src/apps/match/components/views/ProfileEditor.tsx
+++ b/phone/src/apps/match/components/views/ProfileEditor.tsx
@@ -2,10 +2,9 @@ import React, { useState } from 'react';
import { useTranslation } from 'react-i18next';
import { makeStyles } from '@material-ui/core/styles';
import { Box, FormControlLabel, Switch } from '@material-ui/core';
-
-import { useProfile } from '../../hooks/useProfile';
import Loader from '../Loader';
import ProfileForm from '../profile/ProfileForm';
+import { useProfile } from '../../hooks/useProfile';
const useStyles = makeStyles({
root: {
diff --git a/phone/src/apps/match/hooks/state.ts b/phone/src/apps/match/hooks/state.ts
index dd4c255..de6a286 100644
--- a/phone/src/apps/match/hooks/state.ts
+++ b/phone/src/apps/match/hooks/state.ts
@@ -1,18 +1,55 @@
-import { atom } from 'recoil';
-import { FormattedMatch, FormattedProfile } from '../../../../../typings/match';
+import { atom, selector, useRecoilState, useRecoilValue, useSetRecoilState } from 'recoil';
+import { FormattedMatch, FormattedProfile, MatchEvents } from '../../../../../typings/match';
+import { fetchNui } from '../../../utils/fetchNui';
+import { ServerPromiseResp } from '../../../../../typings/common';
+import LogDebugEvent from '../../../os/debug/LogDebugEvents';
+import { isEnvBrowser } from '../../../utils/misc';
+import { MockMatchesData, MockMyProfileData, MockProfilesData } from '../utils/constants';
export const matchState = {
profiles: atom({
key: 'profiles',
- default: null,
+ default: selector({
+ key: 'matchDefaultProfiles',
+ get: async () => {
+ try {
+ const resp = await fetchNui>(
+ MatchEvents.GET_PROFILES,
+ );
+ LogDebugEvent({ action: 'fetchProfiles', data: resp.data });
+ return resp.data;
+ } catch (e) {
+ if (isEnvBrowser()) {
+ return MockProfilesData;
+ }
+ console.error(e);
+ return [];
+ }
+ },
+ }),
}),
- errorLoadingProfiles: atom({
+ errorLoadingProfiles: atom({
key: 'errorLoadingProfiles',
default: false,
}),
matches: atom({
key: 'matches',
- default: null,
+ default: selector({
+ key: 'defaultMatches',
+ get: async () => {
+ try {
+ const resp = await fetchNui>(MatchEvents.GET_MATCHES);
+ LogDebugEvent({ action: 'fetchMatches', data: resp.data });
+ return resp.data;
+ } catch (e) {
+ if (isEnvBrowser()) {
+ return MockMatchesData;
+ }
+ console.log(e);
+ return [];
+ }
+ },
+ }),
}),
errorLoadingMatches: atom({
key: 'errorLoadingMatches',
@@ -20,10 +57,42 @@ export const matchState = {
}),
myProfile: atom({
key: 'myProfile',
- default: null,
+ default: selector({
+ key: 'myProfileDefault',
+ get: async () => {
+ try {
+ const resp = await fetchNui>(
+ MatchEvents.GET_MY_PROFILE,
+ );
+ LogDebugEvent({ action: 'fetchMyProfile', data: resp.data });
+ return resp.data;
+ } catch (e) {
+ if (isEnvBrowser()) {
+ return MockMyProfileData;
+ }
+ console.error(e);
+ return null;
+ }
+ },
+ }),
}),
noProfileExists: atom({
key: 'noProfileExists',
default: false,
}),
};
+
+export const useFormattedProfiles = () => useRecoilState(matchState.profiles);
+export const useFormattedProfilesValue = () => useRecoilValue(matchState.profiles);
+export const useSetFormattedProfiles = () => useSetRecoilState(matchState.profiles);
+
+export const useMyProfile = () => useRecoilState(matchState.myProfile);
+export const useMyProfileValue = () => useRecoilValue(matchState.myProfile);
+export const useSetMyProfile = () => useSetRecoilState(matchState.myProfile);
+
+export const useProfileExistsValue = () => useRecoilValue(matchState.noProfileExists);
+export const useProfileExists = () => useRecoilState(matchState.noProfileExists);
+
+export const useFormattedMatches = () => useRecoilState(matchState.matches);
+export const useMatchesValue = () => useRecoilValue(matchState.matches);
+export const useSetMatches = () => useSetRecoilState(matchState.matches);
diff --git a/phone/src/apps/match/hooks/useMatchActions.ts b/phone/src/apps/match/hooks/useMatchActions.ts
new file mode 100644
index 0000000..36dca0f
--- /dev/null
+++ b/phone/src/apps/match/hooks/useMatchActions.ts
@@ -0,0 +1,51 @@
+import { FormattedMatch, MatchEvents } from '../../../../../typings/match';
+import { fetchNui } from '../../../utils/fetchNui';
+import { ServerPromiseResp } from '../../../../../typings/common';
+import { useSetFormattedProfiles, useSetMatches } from './state';
+import { useSnackbar } from '../../../ui/hooks/useSnackbar';
+import { useCallback } from 'react';
+
+export const useMatchActions = () => {
+ const setProfiles = useSetFormattedProfiles();
+ const setMatches = useSetMatches();
+ const { addAlert } = useSnackbar();
+
+ const setViewed = useCallback(
+ (id: number, liked: boolean) => {
+ setProfiles((profiles) =>
+ profiles.map((profile) => {
+ if (id === profile.id) return { ...profile, viewed: true, liked };
+ return profile;
+ }),
+ );
+
+ fetchNui>(MatchEvents.SAVE_LIKES, [{ id, liked }]).then((resp) => {
+ if (resp.status !== 'ok') {
+ return addAlert({
+ message: 'APPS_MATCH_SAVE_LIKES_FAILED',
+ type: 'error',
+ });
+ }
+
+ // Instead of just fetching the matches again, we might want to first format the profile to a 'Match',then to a 'FormattedMatch'
+ // and then just mutate the already existing state of matches?
+ // I guess that's for another time :P
+
+ if (resp.data) {
+ addAlert({
+ message: 'APPS_MATCH_NEW_LIKE_FOUND',
+ type: 'info',
+ });
+ fetchNui>(MatchEvents.GET_MATCHES).then((resp) => {
+ setMatches(resp.data);
+ });
+ }
+ });
+ },
+ [setProfiles, addAlert, setMatches],
+ );
+
+ return {
+ setViewed,
+ };
+};
diff --git a/phone/src/apps/match/hooks/useMatchService.ts b/phone/src/apps/match/hooks/useMatchService.ts
deleted file mode 100644
index e89e269..0000000
--- a/phone/src/apps/match/hooks/useMatchService.ts
+++ /dev/null
@@ -1,86 +0,0 @@
-import { useSetRecoilState } from 'recoil';
-import { matchState } from './state';
-import { useTranslation } from 'react-i18next';
-import dayjs from 'dayjs';
-
-import { useNuiEvent } from 'fivem-nui-react-lib';
-import { Profile, FormattedProfile, Match, MatchEvents } from '../../../../../typings/match';
-import { IAlert, useSnackbar } from '../../../ui/hooks/useSnackbar';
-
-export const useMatchService = () => {
- const { addAlert } = useSnackbar();
- const { t } = useTranslation();
- const setNoProfileExists = useSetRecoilState(matchState.noProfileExists);
- const setProfiles = useSetRecoilState(matchState.profiles);
- const setProfile = useSetRecoilState(matchState.myProfile);
- const setMatches = useSetRecoilState(matchState.matches);
- const setErrorLoadingMatches = useSetRecoilState(matchState.errorLoadingMatches);
- const setErrorLoadingProfiles = useSetRecoilState(matchState.errorLoadingProfiles);
-
- const handleAddAlert = ({ message, type }: IAlert) => {
- addAlert({
- message: t(message),
- type,
- });
- };
-
- function formatProfile(profile: Profile): FormattedProfile | null {
- return {
- ...profile,
- tagList: profile.tags.split(',').filter((t) => t), // remove any empty tags
- lastActiveFormatted: dayjs.unix(profile.lastActive).format(t('DATE_TIME_FORMAT')),
- viewed: false,
- };
- }
-
- const _setProfiles = (profiles: Profile[]): void => {
- setProfiles(profiles.map(formatProfile));
- };
- const _setProfile = (profile: Profile) => {
- if (!profile) {
- setNoProfileExists(true);
- } else {
- setNoProfileExists(false);
- setProfile(formatProfile(profile));
- }
- };
- const _handleGetProfilesFailed = (alert: IAlert): void => {
- handleAddAlert(alert);
- setErrorLoadingProfiles(true);
- };
-
- const _setMatches = (matches: Match[]): void => {
- setMatches(
- matches.map((match) => ({
- ...match,
- tagList: match.tags.split(',').filter((t) => t), // remove any empty tags
- lastActiveFormatted: dayjs.unix(match.lastActive).format(t('DATE_TIME_FORMAT')),
- matchedAtFormatted: dayjs.unix(match.matchedAt).format(t('DATE_TIME_FORMAT')),
- })),
- );
- };
-
- const _handleGetMatchesFailed = (alert: IAlert): void => {
- handleAddAlert(alert);
- setErrorLoadingMatches(true);
- };
-
- const _handleUpdateProfile = (profile: Profile) => {
- _setProfile(profile);
- handleAddAlert({ message: 'APPS_MATCH_UPDATE_PROFILE_SUCCEEDED', type: 'info' });
- };
-
- useNuiEvent('MATCH', MatchEvents.GET_PROFILES_SUCCESS, _setProfiles);
- useNuiEvent('MATCH', MatchEvents.GET_PROFILES_FAILED, _handleGetProfilesFailed);
- useNuiEvent('MATCH', MatchEvents.GET_MY_PROFILE_SUCCESS, _setProfile);
- useNuiEvent('MATCH', MatchEvents.GET_MY_PROFILE_FAILED, handleAddAlert);
- useNuiEvent('MATCH', MatchEvents.GET_MATCHES_SUCCESS, _setMatches);
- useNuiEvent('MATCH', MatchEvents.GET_MATCHES_FAILED, _handleGetMatchesFailed);
- useNuiEvent('MATCH', MatchEvents.SAVE_LIKES_FAILED, handleAddAlert);
- useNuiEvent('MATCH', MatchEvents.NEW_MATCH, handleAddAlert);
- useNuiEvent('MATCH', MatchEvents.UPDATE_MY_PROFILE_SUCCESS, _handleUpdateProfile);
- useNuiEvent('MATCH', MatchEvents.UPDATE_MY_PROFILE_FAILED, handleAddAlert);
- useNuiEvent('MATCH', MatchEvents.CREATE_MY_PROFILE_SUCCESS, _handleUpdateProfile);
- useNuiEvent('MATCH', MatchEvents.CREATE_MY_PROFILE_FAILED, handleAddAlert);
- return {};
-};
diff --git a/phone/src/apps/match/hooks/useMatches.ts b/phone/src/apps/match/hooks/useMatches.ts
index 3c880da..240beed 100644
--- a/phone/src/apps/match/hooks/useMatches.ts
+++ b/phone/src/apps/match/hooks/useMatches.ts
@@ -1,15 +1,16 @@
+import { matchState, useFormattedMatches } from './state';
import { useRecoilValue } from 'recoil';
-import { matchState } from './state';
-
import { FormattedMatch } from '../../../../../typings/match';
-interface IUseMatches {
+interface UseMatchProps {
matches: FormattedMatch[];
+ setMatches: (matches: FormattedMatch[]) => void;
error: boolean;
}
-export const useMatches = (): IUseMatches => {
- const matches = useRecoilValue(matchState.matches);
+export const useMatches = (): UseMatchProps => {
+ const [matches, setMatches] = useFormattedMatches();
const error = useRecoilValue(matchState.errorLoadingMatches);
- return { matches, error };
+
+ return { matches, setMatches, error };
};
diff --git a/phone/src/apps/match/hooks/useProfile.ts b/phone/src/apps/match/hooks/useProfile.ts
index be95c80..4369762 100644
--- a/phone/src/apps/match/hooks/useProfile.ts
+++ b/phone/src/apps/match/hooks/useProfile.ts
@@ -1,16 +1,16 @@
-import { useRecoilState, useRecoilValue } from 'recoil';
-import { matchState } from './state';
-
+import { useMyProfile, useProfileExists } from './state';
import { FormattedProfile } from '../../../../../typings/match';
-interface IUseProfiles {
+interface UseProfileProps {
profile: FormattedProfile;
setProfile: (profile: FormattedProfile) => void;
noProfileExists: boolean;
+ setNoProfileExists: (exists: boolean) => void;
}
-export const useProfile = (): IUseProfiles => {
- const [profile, setProfile] = useRecoilState(matchState.myProfile);
- const noProfileExists = useRecoilValue(matchState.noProfileExists);
- return { profile, setProfile, noProfileExists };
+export const useProfile = (): UseProfileProps => {
+ const [profile, setProfile] = useMyProfile();
+ const [noProfileExists, setNoProfileExists] = useProfileExists();
+
+ return { profile, setProfile, noProfileExists, setNoProfileExists };
};
diff --git a/phone/src/apps/match/hooks/useProfiles.ts b/phone/src/apps/match/hooks/useProfiles.ts
index d0d7a2f..4d3050a 100644
--- a/phone/src/apps/match/hooks/useProfiles.ts
+++ b/phone/src/apps/match/hooks/useProfiles.ts
@@ -1,34 +1,20 @@
-import { useRecoilState, useRecoilValue } from 'recoil';
-import { matchState } from './state';
+import { useRecoilValue } from 'recoil';
+import { matchState, useFormattedProfiles } from './state';
-import { FormattedProfile, MatchEvents } from '../../../../../typings/match';
-import { useNuiRequest } from 'fivem-nui-react-lib';
+import { FormattedProfile } from '../../../../../typings/match';
-interface IUseProfiles {
+interface UseProfilesProps {
profiles: FormattedProfile[];
activeProfile: FormattedProfile | null;
- setViewed: (index: number, liked: boolean) => void;
error: boolean;
}
-export const useProfiles = (): IUseProfiles => {
- const Nui = useNuiRequest();
- const [profiles, setProfiles] = useRecoilState(matchState.profiles);
+export const useProfiles = (): UseProfilesProps => {
+ const [profiles] = useFormattedProfiles();
const error = useRecoilValue(matchState.errorLoadingProfiles);
- const setViewed = (id: number, liked: boolean) => {
- setProfiles((profiles) =>
- profiles.map((profile) => {
- if (id === profile.id) return { ...profile, viewed: true, liked };
- return profile;
- }),
- );
-
- Nui.send(MatchEvents.SAVE_LIKES, [{ id, liked }]);
- };
-
const filteredProfiles = profiles ? profiles.filter((profile) => !profile.viewed) : null;
const activeProfile = profiles ? filteredProfiles[0] : null;
- return { profiles, activeProfile, error, setViewed };
+ return { profiles, activeProfile, error };
};
diff --git a/phone/src/apps/match/utils/constants.ts b/phone/src/apps/match/utils/constants.ts
new file mode 100644
index 0000000..f141a62
--- /dev/null
+++ b/phone/src/apps/match/utils/constants.ts
@@ -0,0 +1,116 @@
+import { FormattedMatch, FormattedProfile } from '../../../../../typings/match';
+
+export const MockProfilesData: FormattedProfile[] = [
+ {
+ id: 1,
+ identifier: '3r523242',
+ viewed: false,
+ image:
+ 'https://cdn.vox-cdn.com/thumbor/9xCALlkm2Mc0HQk8kMr1Ui3YNbc=/0x0:5464x3070/920x613/filters:focal(2295x1098:3169x1972):format(webp)/cdn.vox-cdn.com/uploads/chorus_image/image/67031748/shutterstock_1450403549.0.jpg',
+ name: 'Evan You',
+ bio: 'Husband, father of two, independent open source developer. Creator / project lead of @vuejs, @vite_js and connoisseur of sushi.',
+ createdAt: 1615932985,
+ updatedAt: 1615932985,
+ lastActive: 1616004986,
+ job: 'Gardener',
+ location: 'Grapeseed',
+ tags: 'shit framework, vue sucks',
+ phoneNumber: '987-6543',
+ tagList: ['shitframework', 'vue sucks'],
+ lastActiveFormatted: '1616004986',
+ },
+ {
+ id: 2,
+ identifier: '3r523242',
+ viewed: false,
+ image:
+ 'https://media.cntraveler.com/photos/5f8f09c3a078e9112956774d/16:9/w_1600%2Cc_limit/Chicago-GettyImages-1065188752.jpg',
+ name: 'Person Beta',
+ bio: 'l impedit quo minus id quod maxime placeat facere possimus',
+ createdAt: 1615846585,
+ updatedAt: 1615846585,
+ lastActive: 1615850185,
+ job: 'Mechanic',
+ location: 'Harmony',
+ tags: 'tinkering,robotics',
+ phoneNumber: '654-3219',
+ tagList: ['tinkering', 'robotics'],
+ lastActiveFormatted: '12332425',
+ },
+ {
+ id: 3,
+ identifier: '3r523242',
+ viewed: false,
+ image: 'https://www.langan.com/wp-content/uploads/2019/02/Boston-996x554.jpg',
+ name: 'Person Charlie',
+ bio: 'ut aut reiciendis voluptatibus',
+ createdAt: 1615850185,
+ updatedAt: 1615850185,
+ lastActive: 1613607385,
+ job: 'Lawyer',
+ location: 'Los Santos',
+ tags: 'reading,coolstuff, coffee',
+ phoneNumber: '123-4567',
+ tagList: ['reading', 'coolstuff', 'coffee'],
+ lastActiveFormatted: '12332425',
+ },
+];
+
+export const MockMyProfileData: FormattedProfile = {
+ id: 4,
+ identifier: '4785656',
+ viewed: false,
+ image:
+ 'https://www.middlebury.edu/institute/sites/www.middlebury.edu.institute/files/styles/1040x585/public/2018-10/Nashville-skyline.jpg?fv=mS11EKrT&itok=HNhHqYUX',
+ name: 'Kire Says',
+ bio: "Kire's cool profile that has many cool things. And others.",
+ createdAt: 1615932985,
+ updatedAt: 1615932985,
+ lastActive: 1616004986,
+ job: 'Engineer',
+ location: 'Boston',
+ tags: 'code,javascript',
+ phoneNumber: '999-9999',
+ tagList: ['code', 'javascript'],
+ lastActiveFormatted: '12332425',
+};
+
+export const MockMatchesData: FormattedMatch[] = [
+ {
+ id: 5,
+ identifier: '4785656',
+ viewed: true,
+ image:
+ 'https://media.cntraveler.com/photos/5f8f09c3a078e9112956774d/16:9/w_1600%2Cc_limit/Chicago-GettyImages-1065188752.jpg',
+ name: 'Taso',
+ bio: 'l impedit quo minus id quod maxime placeat facere possimus',
+ createdAt: 1615846585,
+ updatedAt: 1615846585,
+ lastActive: 1615850185,
+ job: 'Mechanic',
+ location: 'Harmony',
+ tags: 'tinkering,robotics',
+ tagList: ['tinkering', 'robotics'],
+ lastActiveFormatted: '525343252',
+ matchedAtFormatted: '3452355',
+ phoneNumber: '654-3219',
+ },
+ {
+ id: 6,
+ identifier: '4785656',
+ viewed: true,
+ image: 'https://www.langan.com/wp-content/uploads/2019/02/Boston-996x554.jpg',
+ name: 'Chip',
+ bio: 'ut aut reiciendis voluptatibus',
+ createdAt: 1615850185,
+ updatedAt: 1615850185,
+ lastActive: 1613607385,
+ job: 'Lawyer',
+ location: 'Los Santos',
+ tags: 'reading,coolstuff, coffee',
+ tagList: ['reading', 'coolstuff', 'coffee'],
+ phoneNumber: '123-4567',
+ lastActiveFormatted: '525343252',
+ matchedAtFormatted: '3452355',
+ },
+];
diff --git a/phone/src/apps/messages/components/MessagesApp.tsx b/phone/src/apps/messages/components/MessagesApp.tsx
index f938b8c..af872f9 100644
--- a/phone/src/apps/messages/components/MessagesApp.tsx
+++ b/phone/src/apps/messages/components/MessagesApp.tsx
@@ -12,12 +12,13 @@ import NewMessageGroupButton from './form/NewMessageGroupButton';
import { useNuiRequest } from 'fivem-nui-react-lib';
import { MessagesThemeProvider } from '../providers/MessagesThemeProvider';
import { MessageEvents } from '../../../../../typings/messages';
+import { LoadingSpinner } from '../../../ui/components/LoadingSpinner';
export const MessagesApp = () => {
const Nui = useNuiRequest();
const messages = useApp('MESSAGES');
const history = useHistory();
-
+
useEffect(() => {
Nui.send(MessageEvents.FETCH_MESSAGE_GROUPS);
}, [Nui]);
@@ -27,21 +28,23 @@ export const MessagesApp = () => {
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ }>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
history.push('/messages/new')} />
diff --git a/phone/src/apps/messages/components/modal/MessageModal.tsx b/phone/src/apps/messages/components/modal/MessageModal.tsx
index 5765031..4207c1f 100644
--- a/phone/src/apps/messages/components/modal/MessageModal.tsx
+++ b/phone/src/apps/messages/components/modal/MessageModal.tsx
@@ -22,7 +22,7 @@ import { useHistory, useLocation, useParams } from 'react-router-dom';
import { useTranslation } from 'react-i18next';
import Modal from '../../../../ui/components/Modal';
import { useContactActions } from '../../../contacts/hooks/useContactActions';
-import { useSimcard } from '../../../../os/simcard/hooks/useSimcard';
+import { useMyPhoneNumber } from '../../../../os/simcard/hooks/useMyPhoneNumber';
import { MessageEvents } from '../../../../../../typings/messages';
const LARGE_HEADER_CHARS = 30;
@@ -51,7 +51,7 @@ export const MessageModal = () => {
const Nui = useNuiRequest();
const classes = useStyles();
const history = useHistory();
- const { number: myNumber } = useSimcard();
+ const myNumber = useMyPhoneNumber();
const { pathname } = useLocation();
const { t } = useTranslation();
const { groupId } = useParams<{ groupId: string }>();
diff --git a/phone/src/apps/notes/list/NoteList.tsx b/phone/src/apps/notes/list/NoteList.tsx
index 7daab1a..8a08930 100644
--- a/phone/src/apps/notes/list/NoteList.tsx
+++ b/phone/src/apps/notes/list/NoteList.tsx
@@ -4,7 +4,6 @@ import { useNotesValue } from '../hooks/state';
import { useSetSelectedNote } from '../hooks/state';
import { NoteItem } from '../../../../../typings/notes';
import { makeStyles, Theme } from '@material-ui/core/styles';
-import { Notes } from '@material-ui/icons';
const useStyles = makeStyles((theme: Theme) => ({
noNotes: {
diff --git a/phone/src/apps/settings/components/SettingsApp.tsx b/phone/src/apps/settings/components/SettingsApp.tsx
index 91e525f..eba4145 100644
--- a/phone/src/apps/settings/components/SettingsApp.tsx
+++ b/phone/src/apps/settings/components/SettingsApp.tsx
@@ -5,7 +5,7 @@ import { AppContent } from '../../../ui/components/AppContent';
import { useContextMenu, MapSettingItem, SettingOption } from '../../../ui/hooks/useContextMenu';
import { usePhoneConfig } from '../../../config/hooks/usePhoneConfig';
import { List } from '../../../ui/components/List';
-import { useSimcard } from '../../../os/simcard/hooks/useSimcard';
+import { useMyPhoneNumber } from '../../../os/simcard/hooks/useMyPhoneNumber';
import { IconSetObject, useApp } from '../../../os/apps/hooks/useApps';
import {
SettingItem,
@@ -59,7 +59,7 @@ const useStyles = makeStyles({
export const SettingsApp = () => {
const settingsApp = useApp('SETTINGS');
const [config] = usePhoneConfig();
- const simcard = useSimcard();
+ const myNumber = useMyPhoneNumber();
const [settings, setSettings] = useSettings();
const { t } = useTranslation();
const { customWallpaperModal, setCustomWallpaperModal } = useCustomWallpaperModal();
@@ -142,7 +142,7 @@ export const SettingsApp = () => {
};
const handleCopyPhoneNumber = () => {
- setClipboard(simcard.number);
+ setClipboard(myNumber);
addAlert({
message: t('GENERIC_WRITE_TO_CLIPBOARD_MESSAGE', {
content: 'number',
@@ -162,7 +162,7 @@ export const SettingsApp = () => {
}>
& IRouterLocation,
+ { pathname = '', search = '' }: IRouterLocation,
key = '',
value = '',
) => {
diff --git a/phone/src/common/utils/getLocationFromUrl.ts b/phone/src/common/utils/getLocationFromUrl.ts
index 476d5f6..0b5f77a 100644
--- a/phone/src/common/utils/getLocationFromUrl.ts
+++ b/phone/src/common/utils/getLocationFromUrl.ts
@@ -1,6 +1,11 @@
import parseUrl from 'parse-url';
-export const getLocationFromUrl = (url: String) => {
+interface GetLocationFromUrlValue {
+ pathname: string;
+ search: string;
+}
+
+export const getLocationFromUrl = (url: string): GetLocationFromUrlValue => {
const { pathname, search } = parseUrl(url);
const searchStr = '?' + (search || '');
return { pathname, search: searchStr };
diff --git a/phone/src/config/default.json b/phone/src/config/default.json
index 86bf40f..d14b27b 100644
--- a/phone/src/config/default.json
+++ b/phone/src/config/default.json
@@ -194,6 +194,9 @@
"TWITTER_notiSoundVol": 50,
"TWITTER_notifyNewFeedTweet": true
},
+ "appSettings": {
+ "browserHomePage": "https://docs.projecterror.dev"
+ },
"iconSet": [
{
"label": "NPWD Icons",
diff --git a/phone/src/index.tsx b/phone/src/index.tsx
index 13c2e79..a3a0e54 100644
--- a/phone/src/index.tsx
+++ b/phone/src/index.tsx
@@ -18,8 +18,9 @@ dayjs.extend(updateLocale);
// Enable Sentry when config setting is true and when in prod
if (PhoneConfig.SentryErrorMetrics && process.env.NODE_ENV !== 'development') {
Sentry.init({
- dsn: 'https://71fff4e8f11543fa8dbe7acd0f94fb5d@o478949.ingest.sentry.io/5581619',
+ dsn: 'https://0c8321c22b794dc7a648a571cc8c3c34@sentry.projecterror.dev/2',
autoSessionTracking: true,
+ release: process.env.REACT_APP_SENTRY_RELEASE || '0.0.0',
integrations: [new Integrations.BrowserTracing()],
// We recommend adjusting this value in production, or using tracesSampler
// for finer control
diff --git a/phone/src/locale/en.json b/phone/src/locale/en.json
index 828df51..a0bade0 100644
--- a/phone/src/locale/en.json
+++ b/phone/src/locale/en.json
@@ -1,5 +1,10 @@
{
"translation": {
+ "MISC": {
+ "TOP_LEVEL_ERR_TITLE": "Fatal Error",
+ "TOP_LEVEL_ERR_ACTION": "Reload",
+ "TOP_LEVEL_ERR_MSG": "NPWD has encountered an error it was unable to recover from. You will need to reload the NUI window. The error is shown below for developer reference."
+ },
"DATE_FORMAT": "MM/DD/YYYY",
"DATE_TIME_FORMAT": "MM/DD/YYYY hh:mm A",
"CALLS": {
@@ -7,8 +12,15 @@
"RINGING": "Ringing",
"OUTGOING": "Outgoing call",
"INCOMING": "Incoming call"
+ },
+ "FEEDBACK": {
+ "ERROR_MYSELF": "You cannot call your own phone number!",
+ "ERROR": "Error occurred while completing this call"
}
},
+ "BROWSER": {
+ "NAME": "Browser"
+ },
"SETTINGS": {
"CATEGORY": {
"APPEARANCE": "Appearance",
@@ -64,6 +76,7 @@
"APPS_CAMERA": "Camera",
"APPS_CAMERA_FAILED_TO_TAKE_PHOTO": "Photo could not be saved :(",
+ "APPS_CAMERA_FAILED_TO_DELETE_PHOTO": "Photo could not be deleted :(",
"APPS_DIALER_INCOMING_CALL_TITLE": "Incoming Phone Call",
"APPS_DIALER_CURRENT_CALL_TITLE": "Current Phone Call",
diff --git a/phone/src/locale/es.json b/phone/src/locale/es.json
index 088e1a4..4c04732 100644
--- a/phone/src/locale/es.json
+++ b/phone/src/locale/es.json
@@ -1,5 +1,10 @@
{
"translation": {
+ "MISC": {
+ "TOP_LEVEL_ERR_TITLE": "Error Fatal",
+ "TOP_LEVEL_ERR_ACTION": "Recarga",
+ "TOP_LEVEL_ERR_MSG": "NPWD ha encontrado un error y no se pudo recuperar. Tendras que recargar la pagina de NUI. El error se puede encontrar debajo de las referencias de developer."
+ },
"DATE_FORMAT": "MM/DD/YYYY",
"DATE_TIME_FORMAT": "MM/DD/YYYY hh:mm A",
"CALLS": {
@@ -16,6 +21,7 @@
"ACTIONS": "Acciones"
},
"OPTIONS": {
+ "ICONSET": "Set de Iconos",
"LANGUAGE": "Lenguaje",
"RESET_SETTINGS": "Restablecer configuraciones",
"RESET_SETTINGS_DESC": "Esto borrara tus datos almacenados localmente",
@@ -48,6 +54,7 @@
},
"COMING_SOON": "Próximamente...",
+ "INITIALIZING": "Inicializando",
"APPS_DIALER": "Celular",
"APPS_CONTACTS": "Contactos",
@@ -61,6 +68,9 @@
"APPS_MARKETPLACE": "Mercado",
"APPS_CAMERA": "Camara",
+ "APPS_CAMERA_FAILED_TO_TAKE_PHOTO": "No se pudo guardar la foto :(",
+ "APPS_CAMERA_FAILED_TO_DELETE_PHOTO": "No se pudo borrar la foto :(",
+
"APPS_DIALER_INCOMING_CALL_TITLE": "Llamada entrante",
"APPS_DIALER_CURRENT_CALL_TITLE": "Llamada actual",
"APPS_DIALER_CURRENT_CALL_WITH": "En llamada con {{ transmitter }}",
@@ -68,6 +78,13 @@
"APPS_DIALER_ACCEPT_CALL": "Aceptar",
"APPS_DIALER_REJECT_CALL": "Rechazar",
"APPS_DIALER_END_CALL": "Colgar",
+ "APPS_DIALER_INVALID_NUMBER": "Numero invalido",
+ "APPS_DIALER_INPUT_PLACEHOLDER": "Presiona un numero",
+ "APPS_DIALER_NO_HISTORY": "No tienes registro de llamadas",
+ "APPS_DIALER_NAVBAR_HISTORY": "Historial",
+ "APPS_DIALER_NAVBAR_DIAL": "Marcar",
+ "APPS_DIALER_NAVBAR_CONTACTS": "Contactos",
+ "APPS_DIALER_BUSY_LINE": "La linea se encuentra ocupada.",
"APPS_TWITTER_TWEET": "Tweet",
"APPS_TWITTER_TWEET_MESSAGE_PLACEHOLDER": "¿Qué esta pasando?",
@@ -78,6 +95,7 @@
"APPS_TWITTER_DELETE": "Borrar",
"APPS_TWITTER_REPORT": "Reportar",
"APPS_TWITTER_REPORTED": " Reportado",
+ "APPS_TWITTER_RETWEETED": "Retwiteado",
"APPS_TWITTER_JUST_NOW": "Justo ahora",
"APPS_TWITTER_SEARCH_TWEETS": "Buscar por tweets",
"APPS_TWITTER_SEARCH_TWEETS_PLACEHOLDER": "Search by profile name or message",
@@ -87,18 +105,53 @@
"APPS_TWITTER_CREATE_FAILED": "Error al enviar su tweet",
"APPS_TWITTER_EDIT_PROFILE_AVATAR": "Avatar URL",
"APPS_TWITTER_EDIT_PROFILE_NAME": "Nombre de perfil",
+ "APPS_TWITTER_EDIT_DEFAULT_PROFILE_NAME": "Escoge nombre de perfil",
"APPS_TWITTER_EDIT_PROFILE_BIO": "Bio",
"APPS_TWITTER_EDIT_PROFILE_LOCATION": "Localizacion",
"APPS_TWITTER_EDIT_PROFILE_JOB": "Trabajo",
+ "APPS_TWITTER_CREATE_PROFILE_SUCCESS": "Se ha creado su perfil",
+ "APPS_TWITTER_CREATE_PROFILE_FAILURE": "Error al crear su perfil",
"APPS_TWITTER_EDIT_PROFILE_SUCCESS": "Se ha actualizado su perfil",
"APPS_TWITTER_EDIT_PROFILE_FAILURE": "Error al actualizar su perfil",
+ "APPS_TWITTER_RETWEET_EXISTS": "Ya has retwiteado este tweet!",
"APPS_TWITTER_TIME_JUST_NOW": "Justo ahora",
"APPS_TWITTER_TIME_MINUTES": "m",
"APPS_TWITTER_TIME_HOURS": "h",
"APPS_TWITTER_TIME_DAYS": "d",
"APPS_TWITTER_NEW_BROADCAST": "Nuevo tweet de @{{ profile_name }}!",
+ "APPS_TWITTER_NEW_RETWEET_BROADCAST": "@{{ profile_name }} retwiteo alguien!",
"APPS_TWITTER_UNREAD_MESSAGES": "Tienes {{ count }} nuevos tweets en el historial!",
+ "APPS_MATCH": "EncuentraAmores",
+ "APPS_MATCH_LIKED": "ME GUSTA",
+ "APPS_MATCH_NOPE": "NOPE",
+ "APPS_MATCH_LIKE": "Me gusta",
+ "APPS_MATCH_DISLIKE": "No me gusta",
+ "APPS_MATCH_NO_PROFILES": "No Hay Perfiles Recientes",
+ "APPS_MATCH_NO_MATCHES": "No se emparejo con nadie",
+ "APPS_MATCH_PROFILES_ERROR": "Error cargando perfiles",
+ "APPS_MATCH_MATCHES_ERROR": "Error cargando matches",
+ "APPS_MATCH_PROFILE_CONFIGURATION": "La app esta mal configurada - no se puede crear un perfil. Por favor contacta un administrador.",
+ "APPS_MATCH_MY_PROFILE_ERROR": "Error cargando perfil",
+ "APPS_MATCH_PROFILE_LAST_ACTIVE": "Ultima vez activo: {{ lastActive }}",
+ "APPS_MATCH_PROFILE_MATCHED_AT": "Encontrado: {{ matchedAt }}",
+ "APPS_MATCH_EDIT_PROFILE_PREVIEW": "Mostrar preview",
+ "APPS_MATCH_EDIT_PROFILE_IMAGE": "Imagen URL",
+ "APPS_MATCH_EDIT_PROFILE_NAME": "Nombre de Perfil",
+ "APPS_MATCH_EDIT_PROFILE_BIO": "Bio",
+ "APPS_MATCH_EDIT_PROFILE_LOCATION": "Localizacion",
+ "APPS_MATCH_EDIT_PROFILE_JOB": "Trabajo",
+ "APPS_MATCH_EDIT_PROFILE_TAGS": "Tags",
+ "APPS_MATCH_GET_MY_PROFILE_FAILED": "Fallo al conseguir el perfil del jugador",
+ "APPS_MATCH_GET_PROFILES_FAILED": "Fallo al extraer perfiles",
+ "APPS_MATCH_GET_MATCHES_FAILED": "Fallo al extraer matches",
+ "APPS_MATCH_UPDATE_PROFILE_SUCCEEDED": "Perfil actualizado correctamente",
+ "APPS_MATCH_UPDATE_PROFILE_FAILED": "Fallo al actualizar el perfil",
+ "APPS_MATCH_CREATE_PROFILE_FAILED": "Fallo al crear perfil",
+ "APPS_MATCH_SAVE_LIKES_FAILED": "Fallo al cargar likes",
+ "APPS_MATCH_SAVE_LIKES_SUCCEDED": "Likes guardado correctamente",
+ "APPS_MATCH_NEW_LIKE_FOUND": "Nuevo match encontrado!",
+
"APPS_BANK_TRANSFER": "Transferir",
"APPS_BANK_HOME_TITLE": "Bienvenido",
"APPS_BANK_ACCOUNT_LINK": "Cuenta",
@@ -120,7 +173,13 @@
"APPS_MESSAGES_MESSAGE_GROUP_DUPLICATE": "Este grupo de mensajes ya existe",
"APPS_MESSAGES_MESSAGE_GROUP_CREATE_FAILED": "Hubo un error al crear grupo de mensajes",
"APPS_MESSAGES_MESSAGE_GROUP_CREATE_MINE": "No puedes agregarte a ti mismo!",
+ "APPS_MESSAGES_MESSAGE_GROUP_CREATE_ALL_NUMBERS_FAILED": "Ninguno de los numeros de telefono pudieron ser encontrados!",
+ "APPS_MESSAGES_MESSAGE_GROUP_CREATE_ONE_NUMBER_FAILED": "{{ number }} no es un numero registrado",
+ "APPS_MESSAGES_MESSAGE_GROUP_CREATE_SOME_NUMBERS_FAILED": "({{ numbers }}) no son numeros registrados.",
"APPS_MESSAGES_INPUT_NAME_OR_NUMBER": "Busca contactos o escribe un numero y presiona enter",
+ "APPS_MESSAGES_UNREAD_MESSAGES": "Tienes {{ count }} mensajes sin leer",
+ "APPS_MESSAGES_MEMBERS_TITLE": "Miembros",
+ "APPS_MESSAGES_ME": "Yo",
"APPS_CONTACT_FORM_NAME": "Nombre",
"APPS_CONTACT_FORM_NUMBER": "Numero",
@@ -147,26 +206,46 @@
"APPS_CALCULATOR_COPIED": "Se ha copiado el resultado!",
- "APPS_MARKETPLACE_CREATE_LISTING_SUCCESS": "Se ha creado un nuevo listado",
- "APPS_MARKETPALCE_CREATE_LISTING_FAILED": "Hubo un error al crear un nuevo listado",
-
"APPS_SETTINGS_PHONE_NUMBER": "Numero de telefono",
"APPS_SETTINGS_OPTION_WALLPAPER": "Fondo de pantalla",
+ "APPS_SETTINGS_OPTIONS_CUSTOM_WALLPAPER": "Fondo de pantalla Custom",
"APPS_SETTINGS_OPTION_FRAME": "Marco",
"APPS_SETTINGS_OPTION_THEME": "Tema",
"APPS_SETTINGS_OPTION_ZOOM": "Ampliar",
+ "APPS_SETTINGS_OPTION_STREAMER_MODE": "Modo Streamer",
"APPS_SETTINGS_OPTION_RINGTONE": "Tono de llamada",
"APPS_SETTINGS_OPTION_RINGTONEVOL": "Volumen del tono de llamada",
-
+ "APPS_SETTINGS_OPTION_NOTIFICATION_FILTER": "Filtros de notificacion",
"APPS_SETTINGS_OPTION_NOTIFICATION": "Notificacion",
"APPS_SETTINGS_OPTION_NOTIFICATIONVOL": "Notificacion de volumen",
+ "APPS_SETTING_STREAMER_MODE_DESC": "Esconder imagenes antes de que sean mostradas",
+ "APPS_MARKETPLACE_CREATE_LISTING_SUCCESS": "Se ha creado un nuevo listado",
+ "APPS_MARKETPALCE_CREATE_LISTING_FAILED": "Hubo un error al crear un nuevo listado",
+ "APPS_MARKETPLACE_DELETE_LISTING_SUCCESS": "Listado borrado correctamente",
+ "APPS_MARKETPLACE_DELETE_LISTING_FAILED": "Fallo al borrar listado",
+ "APPS_MARKETPLACE_REPORT_LISTING_FAILED": "Este listado ya ha sido reportado",
+ "APPS_MARKETPLACE_REPORT_LISTING_SUCCESS": "Listado reportado correctamente",
+ "APPS_MARKETPLACE_REQUIRED_FIELDS": "Todos los campos requeridos tienen que ser llenados!",
+ "APPS_MARKETPLACE_FORM_TITLE": "Titulo",
+ "APPS_MARKETPLACE_FORM_IMAGE": "Imagen o URL",
+ "APPS_MARKETPLACE_FORM_DESCRIPTION": "Descripcion",
+
+ "GENERIC_CLICK_TO_REVEAL": "Clickea para revelar",
+ "GENERIC_LOADING": "Cargando...",
+ "GENERIC_WAIT": "Por favor espera...",
"GENERIC_SAVE": "Guardar",
"GENERIC_UPDATE": "Actualizar",
+ "GENERIC_REQUIRED": "Requerido",
"GENERIC_DELETE": "Borrar",
+ "GENERIC_REPORT": "Reportar",
+ "GENERIC_CALL": "Llamar",
+ "GENERIC_MESSAGE": "Mensaje",
"GENERIC_CLOSE": "Cerrar",
"GENERIC_CANCEL": "Cancelar",
"GENERIC_TITLE": "Titulo",
- "GENERIC_CONTENT": "Contenido"
+ "GENERIC_CONTENT": "Contenido",
+ "GENERIC_WRITE_TO_CLIPBOARD_TOOLTIP": "Copiado {{ content }}",
+ "GENERIC_WRITE_TO_CLIPBOARD_MESSAGE": "Copiado {{content}} al portapapeles!"
}
}
diff --git a/phone/src/locale/fr.json b/phone/src/locale/fr.json
index 06e663b..8628fdb 100644
--- a/phone/src/locale/fr.json
+++ b/phone/src/locale/fr.json
@@ -16,6 +16,7 @@
"ACTIONS": "Actions"
},
"OPTIONS": {
+ "ICONSET": "Pack d'icones",
"LANGUAGE": "Langage",
"RESET_SETTINGS": "Réinitialiser",
"RESET_SETTINGS_DESC": "Cette action effacera toutes les données stockées",
@@ -61,6 +62,8 @@
"APPS_TWITTER": "Twitter",
"APPS_MARKETPLACE": "Marché",
"APPS_CAMERA": "Caméra",
+
+ "APPS_CAMERA_FAILED_TO_TAKE_PHOTO": "La photo n'a pas pu être sauvegardée :(",
"APPS_DIALER_INCOMING_CALL_TITLE": "Appel entrant",
"APPS_DIALER_CURRENT_CALL_TITLE": "Appel en cours",
@@ -69,11 +72,13 @@
"APPS_DIALER_ACCEPT_CALL": "Accepter",
"APPS_DIALER_REJECT_CALL": "Rejeter",
"APPS_DIALER_END_CALL": "Raccrocher",
+ "APPS_DIALER_INVALID_NUMBER": "Ce numéro n'est pas valide",
"APPS_DIALER_INPUT_PLACEHOLDER": "Entrer un numéro",
"APPS_DIALER_NO_HISTORY": "Aucun historique d'appel",
"APPS_DIALER_NAVBAR_HISTORY": "Historique",
"APPS_DIALER_NAVBAR_DIAL": "Composer",
"APPS_DIALER_NAVBAR_CONTACTS": "Contacts",
+ "APPS_DIALER_BUSY_LINE": "La ligne sonne occupée",
"APPS_TWITTER_TWEET": "Tweet",
"APPS_TWITTER_TWEET_MESSAGE_PLACEHOLDER": "Quoi de neuf ?",
@@ -221,6 +226,7 @@
"APPS_MARKETPLACE_FORM_DESCRIPTION": "Description",
"GENERIC_CLICK_TO_REVEAL": "Cliquer pour afficher",
+ "GENERIC_LOADING": "Chargement...",
"GENERIC_WAIT": "Veuillez patienter...",
"GENERIC_SAVE": "Sauvegarder",
"GENERIC_UPDATE": "Mettre à jour",
diff --git a/phone/src/os/apps/config/apps.tsx b/phone/src/os/apps/config/apps.tsx
index 5fae982..016b0e3 100644
--- a/phone/src/os/apps/config/apps.tsx
+++ b/phone/src/os/apps/config/apps.tsx
@@ -5,7 +5,6 @@ import { ContactsApp } from '../../../apps/contacts/components/ContactsApp';
import { CalculatorApp } from '../../../apps/calculator/components/CalculatorApp';
import { SettingsApp } from '../../../apps/settings/components/SettingsApp';
import { MessagesApp } from '../../../apps/messages/components/MessagesApp';
-import { MatchApp } from '../../../apps/match/components/MatchApp';
import { TwitterApp } from '../../../apps/twitter/components/TwitterApp';
import { ExampleApp } from '../../../apps/example/components/ExampleApp';
import { MarketplaceApp } from '../../../apps/marketplace/components/MarketplaceApp';
@@ -22,8 +21,8 @@ import {
CONTACTS_APP_TEXT_COLOR,
} from '../../../apps/contacts/contacts.theme';
import {
- SELLOUT_APP_PRIMARY_COLOR,
- SELLOUT_APP_ICON_COLOR,
+ MARKETPLACE_APP_PRIMARY_COLOR,
+ MARKETPLACE_APP_ICON_COLOR,
} from '../../../apps/marketplace/marketplace.theme';
import { NOTES_APP_ICON_COLOR, NOTES_APP_PRIMARY_COLOR } from '../../../apps/notes/notes.theme';
import { DIALER_APP_PRIMARY_COLOR, DIALER_APP_TEXT_COLOR } from '../../../apps/dialer/dialer.theme';
@@ -34,6 +33,8 @@ import {
import { MATCH_APP_PRIMARY_COLOR, MATCH_APP_TEXT_COLOR } from '../../../apps/match/match.theme';
import { SvgIconProps } from '@material-ui/core';
import { INotificationIcon } from '../../notifications/providers/NotificationsProvider';
+import { BrowserApp } from '../../../apps/browser/components/BrowserApp';
+import { MatchApp } from '../../../apps/match/components/MatchApp';
export interface IAppConfig {
id: string;
@@ -61,6 +62,16 @@ export const APPS: IAppConfig[] = [
path: '/phone',
Route: () => ,
},
+ {
+ id: 'BROWSER',
+ nameLocale: 'BROWSER.NAME',
+ backgroundColor: blue['300'],
+ path: '/browser',
+ color: common.white,
+ Route: () => (
+
+ ),
+ },
{
id: 'MESSAGES',
nameLocale: 'APPS_MESSAGES',
@@ -129,8 +140,8 @@ export const APPS: IAppConfig[] = [
{
id: 'MARKETPLACE',
nameLocale: 'APPS_MARKETPLACE',
- backgroundColor: SELLOUT_APP_PRIMARY_COLOR,
- color: SELLOUT_APP_ICON_COLOR,
+ backgroundColor: MARKETPLACE_APP_PRIMARY_COLOR,
+ color: MARKETPLACE_APP_ICON_COLOR,
path: '/marketplace',
Route: () => (
{
const apps: IApp[] = useMemo(() => {
return APPS.map((app) => {
- const SvgIcon = React.lazy(
- () => import(`${__dirname}/../icons/${curIconSet.name}/svg/${app.id}`),
+ const SvgIcon = React.lazy(() =>
+ import(`${__dirname}/../icons/${curIconSet.name}/svg/${app.id}`).catch(
+ () => 'Was not able to find a dynamic import for icon from this icon set',
+ ),
);
- const AppIcon = React.lazy(
- () => import(`${__dirname}/../icons/${curIconSet.name}/app/${app.id}`),
+ const AppIcon = React.lazy(() =>
+ import(`${__dirname}/../icons/${curIconSet.name}/app/${app.id}`).catch(
+ () => 'Was not able to find a dynamic import for icon from this icon set',
+ ),
);
const NotificationIcon = createLazyAppIcon(SvgIcon);
diff --git a/phone/src/os/apps/icons/material/app/BROWSER.tsx b/phone/src/os/apps/icons/material/app/BROWSER.tsx
new file mode 100644
index 0000000..5bd5896
--- /dev/null
+++ b/phone/src/os/apps/icons/material/app/BROWSER.tsx
@@ -0,0 +1,5 @@
+import { Language } from '@material-ui/icons';
+
+const BrowserIcon = () => ;
+
+export default BrowserIcon;
diff --git a/phone/src/os/apps/icons/material/svg/BROWSER.tsx b/phone/src/os/apps/icons/material/svg/BROWSER.tsx
new file mode 100644
index 0000000..5abd259
--- /dev/null
+++ b/phone/src/os/apps/icons/material/svg/BROWSER.tsx
@@ -0,0 +1,5 @@
+import { Language } from '@material-ui/icons';
+
+const BrowserIcon = () => ;
+
+export default BrowserIcon;
diff --git a/phone/src/os/apps/icons/npwd_icons/app/BROWSER.tsx b/phone/src/os/apps/icons/npwd_icons/app/BROWSER.tsx
new file mode 100644
index 0000000..5bd5896
--- /dev/null
+++ b/phone/src/os/apps/icons/npwd_icons/app/BROWSER.tsx
@@ -0,0 +1,5 @@
+import { Language } from '@material-ui/icons';
+
+const BrowserIcon = () => ;
+
+export default BrowserIcon;
diff --git a/phone/src/os/apps/icons/npwd_icons/app/MARKETPLACE.tsx b/phone/src/os/apps/icons/npwd_icons/app/MARKETPLACE.tsx
index 262df9e..94411b8 100644
--- a/phone/src/os/apps/icons/npwd_icons/app/MARKETPLACE.tsx
+++ b/phone/src/os/apps/icons/npwd_icons/app/MARKETPLACE.tsx
@@ -1,7 +1,7 @@
import React from 'react';
import SvgIcon, { SvgIconProps } from '@material-ui/core/SvgIcon';
-const SelloutAppIcon = (props: SvgIconProps) => {
+const MarketplaceAppIcon = (props: SvgIconProps) => {
return (