summaryrefslogtreecommitdiffstats
path: root/Swift
diff options
context:
space:
mode:
Diffstat (limited to 'Swift')
-rw-r--r--Swift/Controllers/HistoryViewController.cpp44
-rw-r--r--Swift/Controllers/HistoryViewController.h2
2 files changed, 40 insertions, 6 deletions
diff --git a/Swift/Controllers/HistoryViewController.cpp b/Swift/Controllers/HistoryViewController.cpp
index 5f200f7..0c8cfcd 100644
--- a/Swift/Controllers/HistoryViewController.cpp
+++ b/Swift/Controllers/HistoryViewController.cpp
@@ -97,7 +97,7 @@ void HistoryViewController::handleSelectedContactChanged(RosterItem* newContact)
if (contacts_[type].count(contactJID)) {
currentResultDate_ = *contacts_[type][contactJID].rbegin();
- currentItemType_ = type;
+ selectedItemType_ = type;
messages = historyController_->getMessagesFromDate(selfJID_, contactJID, type, currentResultDate_);
}
}
@@ -156,7 +156,7 @@ void HistoryViewController::handleReturnPressed(const std::string& keyword) {
}
void HistoryViewController::handleScrollReachedTop(const boost::gregorian::date& date) {
- std::vector<HistoryMessage> messages = historyController_->getMessagesFromPreviousDate(selfJID_, selectedItem_->getJID(), currentItemType_, date);
+ std::vector<HistoryMessage> messages = historyController_->getMessagesFromPreviousDate(selfJID_, selectedItem_->getJID(), selectedItemType_, date);
reverse_foreach (const HistoryMessage& message, messages) {
addNewMessage(message, true);
@@ -164,7 +164,7 @@ void HistoryViewController::handleScrollReachedTop(const boost::gregorian::date&
}
void HistoryViewController::handleScrollReachedBottom(const boost::gregorian::date& date) {
- std::vector<HistoryMessage> messages = historyController_->getMessagesFromNextDate(selfJID_, selectedItem_->getJID(), currentItemType_, date);
+ std::vector<HistoryMessage> messages = historyController_->getMessagesFromNextDate(selfJID_, selectedItem_->getJID(), selectedItemType_, date);
foreach (const HistoryMessage& message, messages) {
addNewMessage(message, true);
@@ -172,11 +172,45 @@ void HistoryViewController::handleScrollReachedBottom(const boost::gregorian::da
}
void HistoryViewController::handlePreviousButtonClicked() {
- reset();
+ if (!selectedItem_) {
+ return;
+ }
+
+ std::set<boost::gregorian::date>::iterator date = contacts_[selectedItemType_][selectedItem_->getJID()].find(currentResultDate_);
+
+ if (*date == *contacts_[selectedItemType_][selectedItem_->getJID()].rbegin()) {
+ return;
+ }
+
+ historyWindow_->resetConversationView();
+ currentResultDate_ = *(++date);
+ std::vector<HistoryMessage> messages = historyController_->getMessagesFromDate(selfJID_, selectedItem_->getJID(), selectedItemType_, currentResultDate_);
+ historyWindow_->setDate(currentResultDate_);
+
+ foreach (const HistoryMessage& message, messages) {
+ addNewMessage(message, false);
+ }
}
void HistoryViewController::handleNextButtonClicked() {
- reset();
+ if (!selectedItem_) {
+ return;
+ }
+
+ std::set<boost::gregorian::date>::iterator date = contacts_[selectedItemType_][selectedItem_->getJID()].find(currentResultDate_);
+
+ if (date == contacts_[selectedItemType_][selectedItem_->getJID()].begin()) {
+ return;
+ }
+
+ historyWindow_->resetConversationView();
+ currentResultDate_ = *(--date);
+ std::vector<HistoryMessage> messages = historyController_->getMessagesFromDate(selfJID_, selectedItem_->getJID(), selectedItemType_, currentResultDate_);
+ historyWindow_->setDate(currentResultDate_);
+
+ foreach (const HistoryMessage& message, messages) {
+ addNewMessage(message, false);
+ }
}
void HistoryViewController::reset() {
diff --git a/Swift/Controllers/HistoryViewController.h b/Swift/Controllers/HistoryViewController.h
index a7667c4..e78b5be 100644
--- a/Swift/Controllers/HistoryViewController.h
+++ b/Swift/Controllers/HistoryViewController.h
@@ -56,7 +56,7 @@ namespace Swift {
std::map<HistoryMessage::Type, ContactsMap> contacts_;
ContactRosterItem* selectedItem_;
- HistoryMessage::Type currentItemType_;
+ HistoryMessage::Type selectedItemType_;
boost::gregorian::date currentResultDate_;
};
}