Added support for Steam URLs. Changed default prefix setting options to be dynamically rendered
This commit is contained in:
parent
f1c48e8a15
commit
4143ae8198
3 changed files with 14 additions and 16 deletions
|
@ -5,7 +5,7 @@ import { connect } from 'react-redux';
|
|||
import { createNotification, updateConfig, sortApps, sortCategories } from '../../../store/actions';
|
||||
|
||||
// Typescript
|
||||
import { GlobalState, NewNotification, SettingsForm } from '../../../interfaces';
|
||||
import { GlobalState, NewNotification, Query, SettingsForm } from '../../../interfaces';
|
||||
|
||||
// UI
|
||||
import InputGroup from '../../UI/Forms/InputGroup/InputGroup';
|
||||
|
@ -16,6 +16,7 @@ import classes from './OtherSettings.module.css';
|
|||
|
||||
// Utils
|
||||
import { searchConfig } from '../../../utility';
|
||||
import { queries } from '../../../utility/searchQueries.json';
|
||||
|
||||
interface ComponentProps {
|
||||
createNotification: (notification: NewNotification) => void;
|
||||
|
@ -180,6 +181,7 @@ const OtherSettings = (props: ComponentProps): JSX.Element => {
|
|||
<option value={0}>False</option>
|
||||
</select>
|
||||
</InputGroup>
|
||||
|
||||
{/* MODULES OPTIONS */}
|
||||
<h2 className={classes.SettingsSection}>Modules</h2>
|
||||
<InputGroup>
|
||||
|
@ -202,14 +204,7 @@ const OtherSettings = (props: ComponentProps): JSX.Element => {
|
|||
value={formData.defaultSearchProvider}
|
||||
onChange={(e) => inputChangeHandler(e)}
|
||||
>
|
||||
<option value='d'>DuckDuckGo</option>
|
||||
<option value='g'>Google</option>
|
||||
<option value='s'>Disroot</option>
|
||||
<option value='yt'>YouTube</option>
|
||||
<option value='r'>Reddit</option>
|
||||
<option value='im'>IMDb</option>
|
||||
<option value='mv'>The Movie Database</option>
|
||||
<option value='sp'>Spotify</option>
|
||||
{queries.map((query: Query) => (<option value={query.prefix}>{query.name}</option>))}
|
||||
</select>
|
||||
</InputGroup>
|
||||
<InputGroup>
|
||||
|
|
|
@ -10,7 +10,6 @@ export const searchParser = (searchQuery: string): boolean => {
|
|||
|
||||
const query = queries.find((q: Query) => q.prefix === prefix);
|
||||
|
||||
console.log("QUERY IS " + query);
|
||||
if (query) {
|
||||
const sameTab = searchConfig('searchSameTab', false);
|
||||
|
||||
|
|
|
@ -2,8 +2,8 @@ export const urlParser = (url: string): string[] => {
|
|||
let parsedUrl: string;
|
||||
let displayUrl: string;
|
||||
|
||||
if (/https?:\/\//.test(url)) {
|
||||
// Url starts with http[s]:// -> leave it as it is
|
||||
if (/(https?|steam):\/\//.test(url)) {
|
||||
// Url starts with http[s]:// or steam:// -> leave it as it is
|
||||
parsedUrl = url;
|
||||
} else {
|
||||
// No protocol -> apply http:// prefix
|
||||
|
@ -11,10 +11,14 @@ export const urlParser = (url: string): string[] => {
|
|||
}
|
||||
|
||||
// Create simplified url to display as text
|
||||
displayUrl = url
|
||||
if (/steam:\/\//.test(url)) {
|
||||
displayUrl = 'Run Steam App';
|
||||
} else {
|
||||
displayUrl = url
|
||||
.replace(/https?:\/\//, '')
|
||||
.replace('www.', '')
|
||||
.replace(/\/$/, '');
|
||||
}
|
||||
|
||||
return [displayUrl, parsedUrl]
|
||||
}
|
Loading…
Reference in a new issue