Skip to content

Commit

Permalink
Update core
Browse files Browse the repository at this point in the history
  • Loading branch information
ziulev committed Dec 12, 2021
1 parent 530a6a4 commit 801e2db
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 15 deletions.
10 changes: 7 additions & 3 deletions apps/spotter/src/components/queryPanel/options.queryPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ export const Option = ({
return () => subscriptions.forEach(s => s.unsubscribe());
}, []);

const subtitle = option.subtitle
? `${option.subtitle.slice(0, 45)} ${option.subtitle.length > 44 ? '...' : ''}`
: null;

return <View
style={{
display: 'flex',
Expand Down Expand Up @@ -117,12 +121,12 @@ export const Option = ({
fontSize: 14,
}}>{option.title}</Text>

{option.subtitle &&
{subtitle &&
<Text style={{
opacity: 0.3,
color: active ? colors?.hoveredOptionText : colors?.text,
fontSize: 14,
}}>{option.subtitle.slice(0, 45)}{option.subtitle.length > 44 ? '...' : ''}</Text>
}}>{subtitle}</Text>
}
</View>
{active &&
Expand All @@ -146,7 +150,7 @@ export const OptionIcon = ({ style, icon }: { style: ViewStyle & ImageStyle, ico
}}>
{icon.endsWith('.app') || icon.endsWith('.prefPane')
? <IconImage style={{ width: 25, height: 25 }} source={icon}></IconImage>
: uriRegExp.test(icon)
: uriRegExp.test(icon) || icon.startsWith('https://') || icon.startsWith('http://')
? <Image style={{ width: 22, height: 22 }} source={{ uri: icon }}></Image>
: <Text style={{ margin: 'auto' }}>{icon}</Text>
}
Expand Down
6 changes: 3 additions & 3 deletions apps/spotter/src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ export const sortOptions = (
});
};

export const hideOptions = (
export const replaceOptions = (
options: Array<PluginRegistryOption | PluginOnQueryOption>
): Array<PluginRegistryOption | PluginOnQueryOption> => {
const optionsToHide: string[] = options.reduce<string[]>((acc, curr) => {
return [...acc, ...(curr?.hideOptions ? curr.hideOptions : [])];
return [...acc, ...(curr?.replaceOptions ? curr.replaceOptions : [])];
}, []);

if (!optionsToHide.length) {
Expand All @@ -44,7 +44,7 @@ export const hideOptions = (

return options.filter(o => {
const optionToHide = optionsToHide.find(opt => opt === o.title);
const shouldHide = optionToHide && !o.hideOptions?.find(opt => opt === optionToHide);
const shouldHide = optionToHide && !o.replaceOptions?.find(opt => opt === optionToHide);
return !shouldHide;
});
};
Expand Down
4 changes: 2 additions & 2 deletions apps/spotter/src/providers/events.provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { ALT_QUERY_KEY_MAP, SPOTTER_HOTKEY_IDENTIFIER } from '../constants';
import { isPluginOnQueryOption, PluginRegistryOption, SpotterHotkeyEvent } from '../interfaces';
import { useApi } from './api.provider';
import { useSettings } from './settings.provider';
import { hideOptions, getHistoryPath, sortOptions } from '../helpers';
import { replaceOptions, getHistoryPath, sortOptions } from '../helpers';
import { useHistory } from './history.provider';
import { useSpotterState } from './state.provider';
import { usePlugins } from './plugins.provider';
Expand Down Expand Up @@ -268,7 +268,7 @@ export const EventsProvider: FC<{}> = (props) => {
);

const history = await getHistory();
const prioritizedOptions = hideOptions(filteredRegisteredOptions);
const prioritizedOptions = replaceOptions(filteredRegisteredOptions);
const sortedOptions = sortOptions(
prioritizedOptions ,
selectedOption$.value,
Expand Down
4 changes: 2 additions & 2 deletions apps/spotter/src/providers/plugins.provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import React, { FC, useEffect } from 'react';
import { Alert } from 'react-native';
import { Subject, Subscription, BehaviorSubject } from 'rxjs';
import {
hideOptions,
replaceOptions,
InternalPluginChannel,
sortOptions,
ExternalPluginChannel,
Expand Down Expand Up @@ -203,7 +203,7 @@ export const PluginsProvider: FC<{}> = (props) => {
command: (PluginCommand & {type: CommandType.setOnQueryOptions})
) => {
const history = await getHistory();
const options = hideOptions(
const options = replaceOptions(
command.value.map(o => ({...o, pluginName: command.pluginName}))
);
const sortedOptions = sortOptions(
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"@react-native-community/cli-platform-android": "6.1.0",
"@react-native-community/cli-platform-ios": "6.1.0",
"@react-native-community/eslint-config": "^3.0.1",
"@spotter-app/core": "2.0.0-beta.12",
"@spotter-app/core": "2.0.0-beta.15",
"@testing-library/jest-dom": "5.15.0",
"@testing-library/jest-native": "4.0.4",
"@testing-library/react-native": "8.0.0",
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2231,10 +2231,10 @@
dependencies:
"@sinonjs/commons" "^1.7.0"

"@spotter-app/[email protected].12":
version "2.0.0-beta.12"
resolved "https://registry.yarnpkg.com/@spotter-app/core/-/core-2.0.0-beta.12.tgz#01fdc434c1978cf4e4d9c965db7f3e9b0c9d7847"
integrity sha512-nPvYoL9fxS+yHTrtdDb4yh1MsiK5S7nwdcqcQF0r6AiNj456rRGhSix8H0m5mV0mhcOomwmC+xGd77/XHmj+6g==
"@spotter-app/[email protected].15":
version "2.0.0-beta.15"
resolved "https://registry.yarnpkg.com/@spotter-app/core/-/core-2.0.0-beta.15.tgz#2b127dc1f08c981f0e8f49637b7e5e9c5effe576"
integrity sha512-SwURGGEwlHgWA+k3B3sbkYcT6GRZ3d/GzGKgkeu0RhTlOkQFzDi8M1Kl1Z6NLns7veEbeneqaKxAnfz7pXieOw==

"@storybook/[email protected]":
version "6.1.20"
Expand Down

0 comments on commit 801e2db

Please sign in to comment.