summaryrefslogtreecommitdiffstats
path: root/Swift
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2012-11-05 07:50:34 (GMT)
committerKevin Smith <git@kismith.co.uk>2012-12-23 11:46:01 (GMT)
commit0c2cd2338ef77441e5b6b2a4cf1f5d6591c5f480 (patch)
tree2c9005405f99706e71f3445bc7db43ff48068269 /Swift
parent0a1d592c7bc85e537b8aa8425d8cbce7b48f915a (diff)
downloadswift-0c2cd2338ef77441e5b6b2a4cf1f5d6591c5f480.zip
swift-0c2cd2338ef77441e5b6b2a4cf1f5d6591c5f480.tar.bz2
Don't store duplicate status
Change-Id: I28731080f2e0b0223faa5da8489993be0fd69f6f
Diffstat (limited to 'Swift')
-rw-r--r--Swift/Controllers/StatusCache.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/Swift/Controllers/StatusCache.cpp b/Swift/Controllers/StatusCache.cpp
index 0e8c34d..ce69440 100644
--- a/Swift/Controllers/StatusCache.cpp
+++ b/Swift/Controllers/StatusCache.cpp
@@ -42,9 +42,20 @@ std::vector<StatusCache::PreviousStatus> StatusCache::getMatches(const std::stri
}
void StatusCache::addRecent(const std::string& text, StatusShow::Type type) {
- previousStatuses_.push_back(PreviousStatus(text, type));
+ if (text.empty()) {
+ return;
+ }
+ for (std::list<PreviousStatus>::iterator i = previousStatuses_.begin(); i != previousStatuses_.end(); ) {
+ if ((*i).first == text && (*i).second == type) {
+ previousStatuses_.erase(i++);
+ }
+ else {
+ ++i;
+ }
+ }
+ previousStatuses_.push_front(PreviousStatus(text, type));
for (size_t i = previousStatuses_.size(); i > MAX_ENTRIES; i--) {
- previousStatuses_.pop_front();
+ previousStatuses_.pop_back();
}
saveRecents();
}