Permalink
Browse files

Updated the way that messges are handled.

  Read messages are now marked as such, which causes a bug, as
 expected.  Issue #3 is real and will be a pain to fix.
  • Loading branch information...
1 parent 45d79aa commit 2c154cc4125bb114de1262833547715c09bf724e @skx skx committed May 13, 2013
Showing with 28 additions and 4 deletions.
  1. +3 −1 global.cc
  2. +15 −0 message.cc
  3. +5 −0 message.h
  4. +5 −3 screen.cc
View
@@ -257,6 +257,7 @@ std::vector<CMessage *> CGlobal::get_messages()
*/
CGlobal *global = CGlobal::Instance();
std::vector<std::string> folders = global->get_selected_folders();
+ std::string * filter = global->get_index_limit();
/**
* The sum of all messages we're going to display.
@@ -280,7 +281,8 @@ std::vector<CMessage *> CGlobal::get_messages()
*/
std::vector<CMessage *>::iterator mit;
for (mit = contents.begin(); mit != contents.end(); ++mit) {
- messages.push_back(*mit);
+ if ( (*mit)->matches_filter( filter ) )
+ messages.push_back(*mit) ;
}
}
View
@@ -93,6 +93,21 @@ std::string CMessage::flags()
return flags;
}
+/**
+ * Does this message match the given filter.
+ */
+bool CMessage::matches_filter( std::string *filter )
+{
+ if ( strcmp( filter->c_str(), "all" ) == 0 )
+ return true;
+
+ if ( ( strcmp( filter->c_str(), "new" ) == 0 ) &&
+ is_new() )
+ return true;
+
+ return false;
+}
+
/**
* Is this message new?
View
@@ -68,6 +68,11 @@ class CMessage
std::string flags();
/**
+ * Does this message match the given filter?
+ */
+ bool matches_filter( std::string *filter );
+
+ /**
* Is this message new?
*/
bool is_new();
View
@@ -196,8 +196,8 @@ void CScreen::drawIndex()
* Bound the selection.
*/
if (selected >= count) {
- global->set_selected_message(0);
- selected = 0;
+ selected = count-1;
+ global->set_selected_message(selected);
}
/**
@@ -295,7 +295,7 @@ void CScreen::drawMessage()
CMessage *cur = NULL;
if ((selected) < count)
- cur = messages[ selected];
+ cur = messages[selected];
else
{
clear();
@@ -360,6 +360,8 @@ void CScreen::drawMessage()
printw( "%s", body[i].c_str() );
}
+ if ( cur->is_new() )
+ cur->mark_read();
}
/**

0 comments on commit 2c154cc

Please sign in to comment.