Skip to content

Instantly share code, notes, and snippets.

@marcusramberg
Created July 6, 2011 09:45
Show Gist options
  • Save marcusramberg/1066926 to your computer and use it in GitHub Desktop.
Save marcusramberg/1066926 to your computer and use it in GitHub Desktop.
diff --git i/lib/MeeTV/Web5.pm w/lib/MeeTV/Web5.pm
index 0dc51b7..ab2f91e 100644
--- i/lib/MeeTV/Web5.pm
+++ w/lib/MeeTV/Web5.pm
@@ -100,13 +100,7 @@ sub set_attributes {
api_key => $cfg->{web_service}{api_key},
);
});
- $self->attr( default_channels => sub {
- my ($c) = @_;
- my $channels = [map { $_->textid } @{$c->ws->bagged_channels->items}];
- my %site_default_channels = ( $c->ws->site => $channels);
- return \%site_default_channels;
- } );
-
+ $self->attr( default_channels => sub { return {} } );
}
@@ -129,21 +123,15 @@ sub set_helpers{
$self->helper('site_has_facebook' => sub { shift->app->site_has_facebook });
$self->helper('current_channels' => sub {
my $c=shift;
- my $channels;
- if ($c->session('current_channels')) {
- $channels = $c->session('current_channels');
- }
- else {
- my $site = $c->ws->{site};
- if ($self->default_channels->{$site}){
- $channels = $self->default_channels->{$site};
- }
- else {
- $channels = [map { $_->textid } @{$c->ws->bagged_channels->items}];
- $self->default_channels->{$site} = $channels;
- }
- }
- return $channels;
+ return $c->session('current_channels')
+ if ($c->session('current_channels'));
+ my $site = $c->ws->{site};
+ return $self->default_channels->{$site}
+ if ($self->default_channels->{$site});
+ return $self->default_channels->{$site} = [
+ map { $_->textid }
+ @{$c->ws->bagged_channels->items}
+ ];
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment