Skip to content

Commit

Permalink
clear votes for your browse as well
Browse files Browse the repository at this point in the history
  • Loading branch information
lachlan-00 committed Mar 23, 2024
1 parent f55f9ab commit 40d30f3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
3 changes: 2 additions & 1 deletion public/templates/show_democratic.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
use Ampache\Module\Util\Ui;
use Ampache\Repository\Model\Democratic;

/** @var Ampache\Repository\Model\Browse $browse */
/** @var Democratic $democratic */

/* HINT: Democratic Playlist Name */
Expand All @@ -53,7 +54,7 @@
<?php echo Ajax::button_with_text('?page=democratic&action=send_playlist&democratic_id=' . $democratic->id, 'all', T_('Play'), 'play_democratic'); ?>
</li>
<li>
<?php echo Ajax::button_with_text('?page=democratic&action=clear_playlist&democratic_id=' . $democratic->id, 'delete', T_('Clear Playlist'), 'clear_democratic'); ?>
<?php echo Ajax::button_with_text('?page=democratic&action=clear_playlist&democratic_id=' . $democratic->id . '&browse_id=' . $browse->getId(), 'delete', T_('Clear Playlist'), 'clear_democratic'); ?>
</li>
<?php } ?>
<?php } ?>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

use Ampache\Config\ConfigContainerInterface;
use Ampache\Config\ConfigurationKeyEnum;
use Ampache\Module\Util\RequestParserInterface;
use Ampache\Repository\Model\Democratic;
use Ampache\Repository\Model\ModelFactoryInterface;
use Ampache\Repository\Model\Song;
Expand All @@ -42,17 +43,21 @@ final class ShowPlaylistAction implements ApplicationActionInterface
{
public const REQUEST_KEY = 'show_playlist';

private RequestParserInterface $requestParser;

private UiInterface $ui;

private ConfigContainerInterface $configContainer;

private ModelFactoryInterface $modelFactory;

public function __construct(
RequestParserInterface $requestParser,
UiInterface $ui,
ConfigContainerInterface $configContainer,
ModelFactoryInterface $modelFactory
) {
$this->requestParser = $requestParser;
$this->ui = $ui;
$this->configContainer = $configContainer;
$this->modelFactory = $modelFactory;
Expand All @@ -79,13 +84,14 @@ public function run(ServerRequestInterface $request, GuiGatekeeperInterface $gat
$democratic->set_parent();
$democratic->format();

$browse = $this->modelFactory->createBrowse((int)$this->requestParser->getFromRequest('browse_id'));

require_once Ui::find_template('show_democratic.inc.php');

$objects = $democratic->get_items();
Song::build_cache($democratic->object_ids);
Democratic::build_vote_cache($democratic->vote_ids);

$browse = $this->modelFactory->createBrowse();
$browse->set_type('democratic');
$browse->set_static_content(false);
$browse->save_objects($objects);
Expand Down

0 comments on commit 40d30f3

Please sign in to comment.