Album browsing works.

master
Sander Vocke 6 years ago
parent c0a37bfada
commit fde1c94bc9
  1. 3
      src/browser.js
  2. 6
      src/main.js
  3. 14
      src/queries.js

@ -96,7 +96,6 @@ export function AlbumListItem(props) {
const handleClick = () => {
if (onNewQuery) {
var query = user_query_from_album_path(album.relative_path);
console.log(query);
onNewQuery(query);
}
}
@ -150,7 +149,7 @@ export function Browser(props) {
Albums
</ListSubheader>
}
classname={classes.root}
className={classes.root}
>
{
tree.children.map(elem => {

@ -53,7 +53,7 @@ export function LoadedMainPage(props) {
});
}, []);
function performGalleryQuery() {
useEffect(() => {
var sql_image_query = maybe_image_query(gallery_user_query);
setPhotos(false);
do_image_query(sql_image_query, props.database, props.photos_dir, props.thumbs_dir)
@ -68,17 +68,15 @@ export function LoadedMainPage(props) {
setPhotos(got_photos);
});
});
}
}, [gallery_user_query]);
function onSearch(q) {
var query = user_query_from_search_string(q);
setGalleryUserQuery(query);
performGalleryQuery();
}
function onBrowser(q) {
setGalleryUserQuery(q);
performGalleryQuery();
}
return (

@ -1,9 +1,9 @@
import { create_photo, create_album } from './media.js';
export function escape_regex(string) {
return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
}
export function escape_regex(s) {
return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
};
export function do_image_query(query, database, collection_path, collection_thumbs_path) {
return new Promise(function (resolve, reject) {
@ -173,12 +173,12 @@ function filter_from_text_segment(result_type, segment) {
if (result_type == ResultTypeEnum.IMAGE) {
match_type = MatchTypeEnum.MATCH_EQUALS;
match_text = "\"" + segment['text'] + "\"";
match_text = '"' + segment['text'] + '"';
match_against = "Images.name";
} else if (result_type == ResultTypeEnum.ALBUM) {
// Match against the album "name", which is the basename of its relative path.
match_type = MatchTypeEnum.MATCH_REGEXP;
match_text = "\"" + '\/(.*\/)*' + escape_regex(segment['text']) + "\"";
match_text = '"' + '\/(.*\/)*' + escape_regex(segment['text']) + '"';
match_against = "Albums.relativePath";
}
@ -207,8 +207,8 @@ export function user_query_from_search_string(search_string) {
export function user_query_from_album_path(album_path) {
var r = new UserQuery();
var match_type = MatchTypeEnum.MATCH_EQUALS;
var match_text = "\"" + album_path + "\"";
var match_type = MatchTypeEnum.MATCH_REGEXP;
var match_text = '"' + escape_regex(album_path) + '(\/[^\/]+)*' + '"';
var match_against = "Albums.relativePath";
r.image_filter = new MatchingFilter(ResultTypeEnum.ALBUM, match_against, match_text, match_type, false);
r.album_filter = new ConstFilter(ResultTypeEnum.ALBUM, false);

Loading…
Cancel
Save