Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
jaedb committed Oct 13, 2023
2 parents 4cb578b + 3293fe8 commit e152f2a
Show file tree
Hide file tree
Showing 27 changed files with 176 additions and 186 deletions.
2 changes: 1 addition & 1 deletion IRIS_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.68.0
3.69.0
2 changes: 1 addition & 1 deletion mopidy_iris/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from mopidy import config, ext

__version__ = "3.68.0"
__version__ = "3.69.0"

logger = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion mopidy_iris/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def __init__(self, path):


class IrisSystemThread(Thread):
_USE_SUDO = True
_USE_SUDO = os.environ.get("IRIS_USE_SUDO", True)

def __init__(self, action, ioloop, callback):
Thread.__init__(self)
Expand Down
5 changes: 4 additions & 1 deletion mopidy_iris/system.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ elif [[ $1 = "restart" ]]; then
elif [[ $1 = "local_scan" ]]; then
START=$(date +%s)
if $IS_CONTAINER; then
SCAN=$(mopidy --config /config/mopidy.conf local scan)
if [ -n "$IRIS_CONFIG_LOCATION" ]; then
SCAN=$(mopidy --config $IRIS_CONFIG_LOCATION local scan)
else
SCAN=$(mopidy --config /config/mopidy.conf local scan)
else
SCAN=$(sudo mopidyctl local scan)
fi
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mopidy-iris",
"version": "3.68.0",
"version": "3.69.0",
"description": "Mopidy HTTP interface",
"repository": "https://github.com/jaedb/iris",
"author": "James Barnsley <[email protected]>",
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = Mopidy-Iris
version = 3.68.0
version = 3.69.0
url = https://github.com/jaedb/iris
author = James Barnsley
author_email = [email protected]
Expand Down
2 changes: 1 addition & 1 deletion src/js/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const Content = () => (
<Route path="settings/debug" element={<Debug />} />
<Route path="settings/*" element={<Settings />} />
<Route path="search" element={<Search />} />
<Route path="search/:type/:term" element={<Search />} />
<Route path="search/:type/:providers/:term" element={<Search />} />
<Route path="artist/:uri/*" element={<Artist />} />
<Route path="album/:uri/" element={<Album />} />
<Route path="album/:uri/:name" element={<Album />} />
Expand Down
18 changes: 10 additions & 8 deletions src/js/components/SearchResults.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,20 @@ import { Grid } from './Grid';
import { I18n } from '../locale';
import Button from './Button';
import { makeSearchResultsSelector, getSortSelector } from '../util/selectors';
import useSearchQuery from '../util/useSearchQuery';

const SORT_KEY = 'search_results';

const SearchResults = ({
type,
all,
}) => {
const { term } = useParams();
const { term, providers } = useSearchQuery();
const encodedProviders = providers.join(',').replace(/:/g,'');
const [sortField, sortReverse] = useSelector(
(state) => getSortSelector(state, SORT_KEY, 'name'),
);
const searchResultsSelector = makeSearchResultsSelector(term, type);
const searchResultsSelector = makeSearchResultsSelector(providers, term, type);
const rawResults = useSelector(searchResultsSelector);
const encodedTerm = encodeURIComponent(term);
let results = [...rawResults];
Expand All @@ -43,17 +45,17 @@ const SearchResults = ({
<h4>
{!all && (
<span>
<URILink uri={`iris:search:all:${encodedTerm}`} uriType="search" unencoded>
<URILink uri={`iris:search:all:${encodedProviders}:${encodedTerm}`} uriType="search" unencoded>
<I18n path="search.title" />
</URILink>
{' '}
<span style={{ display: 'inline-block', width: 10 }} />
<Icon type="fontawesome" name="angle-right" />
{' '}
<span style={{ display: 'inline-block', width: 10 }} />
<I18n path={`search.${type}.title`} />
</span>
)}
{all && (
<URILink uri={`iris:search:${type}:${encodedTerm}`} uriType="search" unencoded>
<URILink uri={`iris:search:${type}:${encodedProviders}:${encodedTerm}`} uriType="search" unencoded>
<I18n path={`search.${type}.title`} />
</URILink>
)}
Expand All @@ -66,7 +68,7 @@ const SearchResults = ({
{type === 'tracks' && (
<TrackList
source={{
uri: `iris:search:${type}:${encodedTerm}`,
uri: `iris:search:${type}:${encodedProviders}:${encodedTerm}`,
name: 'Search results',
type: 'search',
}}
Expand All @@ -77,7 +79,7 @@ const SearchResults = ({
{/* <LazyLoadListener enabled={this.props.artists_more && spotify_search_enabled} loadMore={loadMore} /> */}

{resultsCount > results.length && (
<Button uri={`iris:search:${type}:${encodedTerm}`} uriType="search" unencoded>
<Button uri={`iris:search:${type}:${encodedProviders}:${encodedTerm}`} uriType="search" unencoded>
<I18n path={`search.${type}.more`} count={resultsCount} />
</Button>
)}
Expand Down
2 changes: 1 addition & 1 deletion src/js/components/URILink.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export default memo(({

case 'search':
var exploded = uri.split(':');
to = `/search/${exploded[2]}/${exploded[3]}`;
to = `/search/${exploded[2]}/${exploded[3]}/${exploded[4]}`;
break;

default:
Expand Down
2 changes: 1 addition & 1 deletion src/js/locale/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ search:
title_window: 'Search: %{term}'
context_actions:
sort: Sort
source: 'Sources (%{count})'
source: Sources
placeholder: Search
all:
title: All
Expand Down
5 changes: 2 additions & 3 deletions src/js/services/core/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,10 @@ export function startSearch(query) {
};
}

export function searchResultsLoaded(query, resultType, results) {
export function searchResultsLoaded(key, results) {
return {
type: 'SEARCH_RESULTS_LOADED',
query,
resultType,
key,
results,
};
}
Expand Down
54 changes: 5 additions & 49 deletions src/js/services/core/middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,79 +177,36 @@ const CoreMiddleware = (function () {

case 'START_SEARCH': {
const { query } = action;
const { term = '', providers = [], type = 'all' } = query;
const {
ui: {
allow_reporting,
},
mopidy: {
uri_schemes = [],
} = {},
} = store.getState();

if (allow_reporting) {
ReactGA.event({
category: 'Search',
action: 'Started',
label: `${query.type}: ${query.term}`,
label: `${type}: ${term}`,
});
}

console.info(`Searching for ${query.type} matching "${query.term}"`);
console.info(`Searching ${providers.length} providers for ${type} matching "${term}"`);

// Trigger reducer immediately; this will hose out any previous results
next(action);

if (uri_schemes.includes('spotify:')) {
if (providers.includes('spotify')) {
store.dispatch(spotifyActions.getSearchResults(query));
}
store.dispatch(mopidyActions.getSearchResults(
query,
100,
uri_schemes.filter((i) => i !== 'spotify:'), // Omit Spotify; handled above
providers.filter((i) => i !== 'spotify'), // Omit Spotify; handled above
));
break;
}

case 'SEARCH_RESULTS_LOADED': {
const {
query: {
term,
type,
},
resultType,
results,
} = action;
const {
core: {
search_results: {
query: {
term: prevTerm,
type: prevType,
} = {},
...allResults
} = {},
} = {},
} = store.getState();

// Add to our existing results, so long as the search term is the same
const search_results = {
query: { term, type },
...(term === prevTerm && type === prevType ? allResults : {}),
};

// Merge our new results with the existing (if any)
search_results[resultType] = [
...(search_results[resultType] || []),
...results,
];

next({
...action,
search_results,
});
break;
}

case 'PLAYLIST_TRACKS_ADDED': {
const {
key,
Expand Down Expand Up @@ -546,7 +503,6 @@ const CoreMiddleware = (function () {

case 'LOAD_LIBRARY':
store.dispatch(uiActions.startLoading(action.uri, action.uri));
console.debug(action);
const fetchLibrary = () => {
switch (uriSource(action.uri)) {
case 'spotify':
Expand Down
17 changes: 4 additions & 13 deletions src/js/services/core/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,23 +176,14 @@ export default function reducer(core = {}, action) {
/**
* Search results
* */
case 'START_SEARCH':
return {
...core,
search_results: {
query: action.query,
artists: [],
albums: [],
playlists: [],
tracks: [],
},
};

case 'SEARCH_RESULTS_LOADED': {
const { search_results } = action;
return {
...core,
search_results,
search_results: {
...core?.search_results || {},
[action.key]: action.results,
},
};
}

Expand Down
4 changes: 2 additions & 2 deletions src/js/services/mopidy/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -591,12 +591,12 @@ export function clearSearchResults() {
};
}

export function getSearchResults(query, limit = 100, uri_schemes) {
export function getSearchResults(query, providers, limit = 100) {
return {
type: 'MOPIDY_GET_SEARCH_RESULTS',
query,
providers,
limit,
uri_schemes,
};
}

Expand Down
Loading

0 comments on commit e152f2a

Please sign in to comment.