aboutsummaryrefslogtreecommitdiff
path: root/src/Cache.cpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2018-05-20 11:15:15 +0200
committerdec05eba <dec05eba@protonmail.com>2018-05-20 11:15:18 +0200
commit4c392178dac1de9a299beb78989c4e0f3fecade9 (patch)
tree552b7a7dfa58e8193705934059e28461815bb951 /src/Cache.cpp
parent34e1d3d9d40f9b9139b801de99292a563c3c9a96 (diff)
Add image preview and url/image open in browser
Diffstat (limited to 'src/Cache.cpp')
-rw-r--r--src/Cache.cpp24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/Cache.cpp b/src/Cache.cpp
index 074b7bc..e5d910c 100644
--- a/src/Cache.cpp
+++ b/src/Cache.cpp
@@ -5,6 +5,8 @@
#include "../include/Gif.hpp"
#include "../include/Chatbar.hpp"
#include "../include/WebPagePreview.hpp"
+#include "../include/ImagePreview.hpp"
+#include "../include/StringUtils.hpp"
#include <boost/filesystem/convenience.hpp>
#include <unordered_map>
#include <process.hpp>
@@ -267,11 +269,21 @@ namespace dchat
{
case ContentByUrlResult::CachedType::TEXTURE:
{
+ if(ImagePreview::getPreviewContentPtr() == it->second.texture)
+ {
+ ++it;
+ continue;
+ }
delete it->second.texture;
break;
}
case ContentByUrlResult::CachedType::GIF:
{
+ if(ImagePreview::getPreviewContentPtr() == it->second.texture)
+ {
+ ++it;
+ continue;
+ }
delete it->second.gif;
break;
}
@@ -311,18 +323,6 @@ namespace dchat
}
}
- static string stringReplaceChar(const string &str, const string &from, const string &to)
- {
- string result = str;
- size_t pos = 0;
- while((pos = result.find(from, pos)) != string::npos)
- {
- result.replace(pos, from.size(), to);
- pos += to.size();
- }
- return result;
- }
-
const ContentByUrlResult Cache::getContentByUrl(const string &url, int downloadLimitBytes)
{
lock_guard<mutex> lock(imageDownloadMutex);