Skip to content

Commit

Permalink
Visibility (#326)
Browse files Browse the repository at this point in the history
* Start with visibility: hidden on load
* Add new has_albums field for the front end

Reduce the recursion level in get_albums().
Optimize eager loading in search.

* Remove a forgotten return
  • Loading branch information
kamil4 authored and ildyria committed Sep 3, 2019
1 parent f7f1020 commit fb2d66c
Show file tree
Hide file tree
Showing 12 changed files with 524 additions and 2,912 deletions.
8 changes: 3 additions & 5 deletions app/Http/Controllers/AlbumController.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,9 @@ public function get(Request $request)
}

$full_photo = $album->full_photo_visible();
// To speed things up, we limit subalbum data to at most two
// levels down. The second level is needed only for the
// displaying of the subalbum_badge for the subalbums in the
// front end.
$return['albums'] = $this->albumFunctions->get_albums($album, $username, 2);
// To speed things up, we limit subalbum data to at most one
// level down.
$return['albums'] = $this->albumFunctions->get_albums($album, $username, 1);
$photos_sql = Photo::set_order(Photo::where('album_id', '=', $request['albumID']));
foreach ($return['albums'] as &$alb) {
unset($alb['thumbIDs']);
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/DemoController.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public function js()
$return_album_json['owner'] = $username = $album->owner->username;
}
$full_photo = $album->full_photo_visible();
$return_album_json['albums'] = $albumFunctions->get_albums($album, $username, 2);
$return_album_json['albums'] = $albumFunctions->get_albums($album, $username, 1);
$photos_sql = Photo::set_order(Photo::where('album_id', '=', $album->id));
foreach ($return_album_json['albums'] as &$alb) {
unset($alb['thumbIDs']);
Expand Down
17 changes: 9 additions & 8 deletions app/Http/Controllers/SearchController.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,16 +158,17 @@ function (Builder $query) use ($escaped_term) {
$i = 0;
foreach ($albums as $album_model) {
$album = $album_model->prepareData();
$username = null;
if ($this->sessionFunctions->is_logged_in()) {
$album['owner'] = $username = $album_model->owner->username;
$album['owner'] = $album_model->owner->username;
}
if ($this->readAccessFunctions->album($album_model) === 1) {
// We need 'albums' just for the displaying of the
// subalbum_badge in the front end, and for that we don't
// need more than one level down.
$album['albums'] = $this->albumFunctions->get_albums($album_model, $username, 1);
$this->albumFunctions->gen_thumbs($album, [$album_model->id]);
// We don't need 'albums' but we do need to come up with
// all the subalbums in order to get accurate thumbs info
// and to let the front end know if there are any.
$subAlbums = [$album_model->id];
$this->albumFunctions->get_sub_albums($subAlbums, $album_model);
$this->albumFunctions->gen_thumbs($album, $subAlbums);
$album['has_albums'] = count($subAlbums) > 1 ? '1' : '0';
}
unset($album['thumbIDs']);
$return['albums'][$i] = $album;
Expand All @@ -189,7 +190,7 @@ function (Builder $query) use ($escaped_term) {
$i++;
}
}
$query = Photo::where(
$query = Photo::with('album')->where(
function (Builder $query) use ($albumIDs) {
$query->whereIn('album_id', $albumIDs);
// Add the 'Unsorted' album.
Expand Down
3 changes: 1 addition & 2 deletions app/ModelFunctions/AlbumFunctions.php
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,7 @@ public function get_albums(Album $album, $username, $recursionLimit = 0): array
$subSubAlbums = [$subAlbum->id];
$this->get_sub_albums($subSubAlbums, $subAlbum);
$this->gen_thumbs($subAlbumData, $subSubAlbums);
$subAlbumData['has_albums'] = count($subSubAlbums) > 1 ? '1' : '0';
}
}

Expand Down Expand Up @@ -568,8 +569,6 @@ public function get_sub_albums(array &$return, Album $parentAlbum, $includePassP
}
}
}

return $return;
}

/**
Expand Down
722 changes: 2 additions & 720 deletions public/dist/frame.js

Large diffs are not rendered by default.

722 changes: 2 additions & 720 deletions public/dist/landing.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/dist/main.css
100755 → 100644

Large diffs are not rendered by default.

981 changes: 251 additions & 730 deletions public/dist/main.js

Large diffs are not rendered by default.

966 changes: 243 additions & 723 deletions public/dist/view.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion resources/views/gallery.blade.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@extends('layouts.simple')
@extends('layouts.gallery')

@section('head-js')
@endsection
Expand Down
9 changes: 9 additions & 0 deletions resources/views/layouts/gallery.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!DOCTYPE HTML>
<html lang="{{ $locale['language'] }}" style="visibility: hidden;">
<head>
@include('includes.head')
</head>
<body>
@yield('content')
</body>
</html>

0 comments on commit fb2d66c

Please sign in to comment.