Skip to content

Commit

Permalink
feat(phone/browser): update url with config
Browse files Browse the repository at this point in the history
  • Loading branch information
itschip committed Dec 18, 2023
1 parent b0a2543 commit aa3f75e
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 6 deletions.
15 changes: 12 additions & 3 deletions apps/phone/src/apps/browser/components/BrowserApp.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { AppWrapper } from '@ui/components';
import { styled } from '@mui/material/styles';
import React, { Reducer, useReducer, useRef } from 'react';
import React, {Reducer, useEffect, useReducer, useRef} from 'react';
import { AppContent } from '@ui/components/AppContent';
import { Box } from '@mui/material';
import { BrowserURLBar } from './BrowserURLBar';
import { promiseTimeout } from '../../../utils/promiseTimeout';
import { usePhoneConfig } from '../../../config/hooks/usePhoneConfig';
import {useConfig, usePhone} from "@os/phone/hooks";

const PREFIX = 'BrowserApp';

Expand Down Expand Up @@ -59,9 +60,11 @@ const browserReducer: Reducer<BrowserState, ReducerAction> = (state, action) =>

export const BrowserApp: React.FC = () => {
const [{ appSettings }] = usePhoneConfig();
const { ResourceConfig } = usePhone();

const [browserState, dispatch] = useReducer(browserReducer, {
browserUrl: appSettings.browserHomePage,
browserHistory: [appSettings.browserHomePage],
browserUrl: ResourceConfig.browser.homepageUrl ?? "",
browserHistory: [ResourceConfig.browser.homepageUrl ?? ""],
});

const { browserHistory, browserUrl } = browserState;
Expand Down Expand Up @@ -90,6 +93,12 @@ export const BrowserApp: React.FC = () => {
dispatch({ payload: strCopy, type: ReducerActionsType.SET_URL });
};

useEffect(() => {
if (ResourceConfig.browser.homepageUrl) {
_setBrowserUrl(ResourceConfig.browser.homepageUrl)
}
}, [ResourceConfig.browser.homepageUrl]);

return (
<StyledAppWrapper id="browser">
<AppContent className={classes.root}>
Expand Down
3 changes: 3 additions & 0 deletions config.default.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@
"marketplace": {
"persistListings": false
},
"browser": {
"homepageUrl": "https://docs.projecterror.dev"
},
"debug": {
"level": "error",
"enabled": true,
Expand Down
9 changes: 6 additions & 3 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"exportFunction": "myCheckerFunction"
},
"general": {
"useResourceIntegration": false,
"useResourceIntegration": true,
"toggleKey": "f1",
"toggleCommand": "phone",
"defaultLanguage": "en"
Expand All @@ -21,8 +21,8 @@
},
"database": {
"useIdentifierPrefix": false,
"playerTable": "users",
"identifierColumn": "identifier",
"playerTable": "players",
"identifierColumn": "citizenid",
"identifierType": "license",
"profileQueries": true,
"phoneNumberColumn": "phone_number"
Expand All @@ -32,6 +32,9 @@
"enabled": true,
"sentryEnabled": true
},
"browser": {
"homepageUrl": "https://docs.fivemanage.com"
},
"defaultContacts": [],
"disabledApps": [],
"apps": [],
Expand Down
5 changes: 5 additions & 0 deletions typings/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ export interface DefaultContact {
avatar?: string;
}

export interface BrowserConfig {
homepageUrl: string;
}

export interface ResourceConfig {
database: DatabaseConfig;
Locale: string;
Expand All @@ -128,6 +132,7 @@ export interface ResourceConfig {
notificationPosition: NotificationConfig;
defaultContacts: DefaultContact[];
general: General;
browser: BrowserConfig;
debug: Debug;
images: ImageConfig;
imageSafety: ImageSafety;
Expand Down

0 comments on commit aa3f75e

Please sign in to comment.