mirror of
https://github.com/pawelmalak/flame.git
synced 2025-07-19 11:39:36 +02:00
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';
|
import { createNotification, updateConfig, sortApps, sortCategories } from '../../../store/actions';
|
||||||
|
|
||||||
// Typescript
|
// Typescript
|
||||||
import { GlobalState, NewNotification, SettingsForm } from '../../../interfaces';
|
import { GlobalState, NewNotification, Query, SettingsForm } from '../../../interfaces';
|
||||||
|
|
||||||
// UI
|
// UI
|
||||||
import InputGroup from '../../UI/Forms/InputGroup/InputGroup';
|
import InputGroup from '../../UI/Forms/InputGroup/InputGroup';
|
||||||
|
@ -16,6 +16,7 @@ import classes from './OtherSettings.module.css';
|
||||||
|
|
||||||
// Utils
|
// Utils
|
||||||
import { searchConfig } from '../../../utility';
|
import { searchConfig } from '../../../utility';
|
||||||
|
import { queries } from '../../../utility/searchQueries.json';
|
||||||
|
|
||||||
interface ComponentProps {
|
interface ComponentProps {
|
||||||
createNotification: (notification: NewNotification) => void;
|
createNotification: (notification: NewNotification) => void;
|
||||||
|
@ -180,6 +181,7 @@ const OtherSettings = (props: ComponentProps): JSX.Element => {
|
||||||
<option value={0}>False</option>
|
<option value={0}>False</option>
|
||||||
</select>
|
</select>
|
||||||
</InputGroup>
|
</InputGroup>
|
||||||
|
|
||||||
{/* MODULES OPTIONS */}
|
{/* MODULES OPTIONS */}
|
||||||
<h2 className={classes.SettingsSection}>Modules</h2>
|
<h2 className={classes.SettingsSection}>Modules</h2>
|
||||||
<InputGroup>
|
<InputGroup>
|
||||||
|
@ -202,14 +204,7 @@ const OtherSettings = (props: ComponentProps): JSX.Element => {
|
||||||
value={formData.defaultSearchProvider}
|
value={formData.defaultSearchProvider}
|
||||||
onChange={(e) => inputChangeHandler(e)}
|
onChange={(e) => inputChangeHandler(e)}
|
||||||
>
|
>
|
||||||
<option value='d'>DuckDuckGo</option>
|
{queries.map((query: Query) => (<option value={query.prefix}>{query.name}</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>
|
|
||||||
</select>
|
</select>
|
||||||
</InputGroup>
|
</InputGroup>
|
||||||
<InputGroup>
|
<InputGroup>
|
||||||
|
@ -266,4 +261,4 @@ const actions = {
|
||||||
sortCategories
|
sortCategories
|
||||||
}
|
}
|
||||||
|
|
||||||
export default connect(mapStateToProps, actions)(OtherSettings);
|
export default connect(mapStateToProps, actions)(OtherSettings);
|
|
@ -10,7 +10,6 @@ export const searchParser = (searchQuery: string): boolean => {
|
||||||
|
|
||||||
const query = queries.find((q: Query) => q.prefix === prefix);
|
const query = queries.find((q: Query) => q.prefix === prefix);
|
||||||
|
|
||||||
console.log("QUERY IS " + query);
|
|
||||||
if (query) {
|
if (query) {
|
||||||
const sameTab = searchConfig('searchSameTab', false);
|
const sameTab = searchConfig('searchSameTab', false);
|
||||||
|
|
||||||
|
@ -24,4 +23,4 @@ export const searchParser = (searchQuery: string): boolean => {
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
|
@ -2,8 +2,8 @@ export const urlParser = (url: string): string[] => {
|
||||||
let parsedUrl: string;
|
let parsedUrl: string;
|
||||||
let displayUrl: string;
|
let displayUrl: string;
|
||||||
|
|
||||||
if (/https?:\/\//.test(url)) {
|
if (/(https?|steam):\/\//.test(url)) {
|
||||||
// Url starts with http[s]:// -> leave it as it is
|
// Url starts with http[s]:// or steam:// -> leave it as it is
|
||||||
parsedUrl = url;
|
parsedUrl = url;
|
||||||
} else {
|
} else {
|
||||||
// No protocol -> apply http:// prefix
|
// No protocol -> apply http:// prefix
|
||||||
|
@ -11,10 +11,14 @@ export const urlParser = (url: string): string[] => {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create simplified url to display as text
|
// Create simplified url to display as text
|
||||||
displayUrl = url
|
if (/steam:\/\//.test(url)) {
|
||||||
|
displayUrl = 'Run Steam App';
|
||||||
|
} else {
|
||||||
|
displayUrl = url
|
||||||
.replace(/https?:\/\//, '')
|
.replace(/https?:\/\//, '')
|
||||||
.replace('www.', '')
|
.replace('www.', '')
|
||||||
.replace(/\/$/, '');
|
.replace(/\/$/, '');
|
||||||
|
}
|
||||||
|
|
||||||
return [displayUrl, parsedUrl]
|
return [displayUrl, parsedUrl]
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue