Fixes NB#117408, message not removed from outbox when the account it belongs to is...
authorSergio Villar Senin <svillar@igalia.com>
Wed, 3 Jun 2009 18:41:14 +0000 (20:41 +0200)
committerSergio Villar Senin <svillar@igalia.com>
Wed, 3 Jun 2009 18:42:25 +0000 (20:42 +0200)
src/hildon2/modest-hildon2-window-mgr.c
src/widgets/modest-header-view.c

index b4035c2..b55ce9d 100644 (file)
@@ -937,7 +937,6 @@ on_account_removed (TnyAccountStore *acc_store,
 {
        HildonWindowStack *stack;
        ModestWindow *current_top;
-       gboolean has_accounts;
 
        /* Ignore transport account removals */
        if (TNY_IS_TRANSPORT_ACCOUNT (account))
@@ -945,7 +944,6 @@ on_account_removed (TnyAccountStore *acc_store,
 
        stack = hildon_window_stack_get_default ();
        current_top = (ModestWindow *) hildon_window_stack_peek (stack);
-       has_accounts = modest_account_mgr_has_accounts (modest_runtime_get_account_mgr (), TRUE);
 
        /* if we're showing the header view of the currently deleted
           account, or the outbox and we deleted the last account,
@@ -953,7 +951,6 @@ on_account_removed (TnyAccountStore *acc_store,
        if (current_top && MODEST_IS_HEADER_WINDOW (current_top)) {
                ModestHeaderView *header_view;
                TnyFolder *folder;
-               gboolean deleted = FALSE;
 
                header_view = modest_header_window_get_header_view (MODEST_HEADER_WINDOW (current_top));
                folder = modest_header_view_get_folder (header_view);
@@ -964,25 +961,18 @@ on_account_removed (TnyAccountStore *acc_store,
 
                                my_account = tny_folder_get_account (folder);
                                if (my_account) {
-                                       if (my_account == account) {
+                                       if (my_account == account)
                                                close_all_but_first (stack);
-                                               deleted = TRUE;
-                                       }
+
                                        g_object_unref (my_account);
                                }
                        }
 
                        /* Close if viewing outbox and no account left */
-                       if (tny_folder_get_folder_type (folder) == TNY_FOLDER_TYPE_OUTBOX) {
-                               if (!has_accounts) {
-                                       close_all_but_first (stack);
-                                       deleted = TRUE;
-                               }
-                       }
-                       g_object_unref (folder);
+                       if (tny_folder_get_folder_type (folder) == TNY_FOLDER_TYPE_OUTBOX)
+                               close_all_but_first (stack);
 
-                       if (deleted)
-                               current_top = (ModestWindow *) hildon_window_stack_peek (stack);
+                       g_object_unref (folder);
                }
        }
 }
index 9753537..4e1d1d3 100644 (file)
@@ -33,6 +33,7 @@
 #include <tny-folder-monitor.h>
 #include <tny-folder-change.h>
 #include <tny-error.h>
+#include <tny-merge-folder.h>
 #include <string.h>
 
 #include <modest-header-view.h>
@@ -2233,10 +2234,19 @@ on_account_removed (TnyAccountStore *self,
        if (priv->folder) {
                TnyAccount *my_account;
 
-               my_account = tny_folder_get_account (priv->folder);
-               if (my_account == account)
-                       modest_header_view_clear (MODEST_HEADER_VIEW (user_data));
-               g_object_unref (my_account);
+               if (TNY_IS_MERGE_FOLDER (priv->folder) &&
+                   tny_folder_get_folder_type (priv->folder) == TNY_FOLDER_TYPE_OUTBOX) {
+                       ModestTnyAccountStore *acc_store = modest_runtime_get_account_store ();
+                       my_account = modest_tny_account_store_get_local_folders_account (acc_store);
+               } else {
+                       my_account = tny_folder_get_account (priv->folder);
+               }
+
+               if (my_account) {
+                       if (my_account == account)
+                               modest_header_view_clear (MODEST_HEADER_VIEW (user_data));
+                       g_object_unref (my_account);
+               }
        }
 }