kareila: (Default)
kareila ([personal profile] kareila) wrote in [site community profile] changelog2010-04-02 04:27 pm

[dw-free] Default View/Default filters should be default when adding from hover menu

[commit: http://hg.dwscoalition.org/dw-free/rev/9988329bc67f]

http://bugs.dwscoalition.org/show_bug.cgi?id=2344

Always add new subscriptions to default filters.

Patch by [personal profile] afuna.

Files modified:
  • cgi-bin/DW/User/ContentFilters/Filter.pm
  • htdocs/manage/circle/add.bml
  • htdocs/tools/endpoints/changerelation.bml
--------------------------------------------------------------------------------
diff -r 9c1befb01566 -r 9988329bc67f cgi-bin/DW/User/ContentFilters/Filter.pm
--- a/cgi-bin/DW/User/ContentFilters/Filter.pm	Fri Apr 02 03:46:01 2010 +0000
+++ b/cgi-bin/DW/User/ContentFilters/Filter.pm	Fri Apr 02 11:27:37 2010 -0500
@@ -186,6 +186,13 @@ sub contains_userid {
     return 0;
 }
 
+# check whether this filter qualifies as a default filter. Case-insensitive.
+# e.g., Default, Default View, etc
+sub is_default {
+    my $name = lc( $_[0]->{name} );
+    return 1 if $name eq "default" || $name eq "default view";
+    return 0;
+}
 
 # called with an item hashref or LJ::Entry object, determines whether or not this
 # filter allows this entry to be shown
diff -r 9c1befb01566 -r 9988329bc67f htdocs/manage/circle/add.bml
--- a/htdocs/manage/circle/add.bml	Fri Apr 02 03:46:01 2010 +0000
+++ b/htdocs/manage/circle/add.bml	Fri Apr 02 11:27:37 2010 -0500
@@ -272,7 +272,8 @@ _c?>
         $body .= "$ML{'.groups.reading'} p?>\n";
         my @sorted_content_filters = sort { $a->{sortorder} <=> $b->{sortorder} } @content_filters;
         foreach my $filter ( @sorted_content_filters ) {
-            my $ck = ( $filter->contains_userid( $u->userid ) );
+            my $ck = ( $filter->contains_userid( $u->userid ) )
+                || ( $action eq "subscribe" && ! $watched && $filter->is_default() );
             my $fid = $filter->id;
             $body .= LJ::html_check( { name     => "content_$fid",
                                        id       => "content_$fid",
diff -r 9c1befb01566 -r 9988329bc67f htdocs/tools/endpoints/changerelation.bml
--- a/htdocs/tools/endpoints/changerelation.bml	Fri Apr 02 03:46:01 2010 +0000
+++ b/htdocs/tools/endpoints/changerelation.bml	Fri Apr 02 11:27:37 2010 -0500
@@ -58,6 +58,16 @@ _c?>
             unless $remote->can_watch( $targetu, errref => \$error );
 
         $success = $remote->add_edge( $targetu, watch => {} );
+
+        if ( $success ) {
+            my @content_filters = $remote->content_filters;
+            foreach my $filter ( @content_filters ) {
+                next unless $filter->is_default();
+                next if $filter->contains_userid( $targetu->userid );
+    
+                $success = $filter->add_row( userid => $targetu->userid ) && $success;
+            }
+        }
     } elsif ( $action eq 'removeTrust' ) {
         $success = $remote->remove_edge( $targetu, trust => {} );
     } elsif ( $action eq 'removeWatch' ) {
--------------------------------------------------------------------------------

Post a comment in response:

This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

If you are unable to use this captcha for any reason, please contact us by email at support@dreamwidth.org