diff options
author | igrechuhin <i.grechuhin@gmail.com> | 2016-06-01 15:05:27 +0300 |
---|---|---|
committer | igrechuhin <i.grechuhin@gmail.com> | 2016-06-01 15:05:27 +0300 |
commit | 4ded724a1ab01730e5324b6cdc587ba6c335ecbc (patch) | |
tree | 3d2e9ba9a97d5b3a1263d193a951f6ed9eeab4be /map | |
parent | a15e1ca1f08123c31bb48f2e217c468931d91717 (diff) | |
parent | 0ae019f82dc2d4e30a1bbf3ea924d07d22621a52 (diff) |
Merge pull request #3387 from mgsergio/get-user-stats-from-server
[editor] Get user stats from server
Diffstat (limited to 'map')
-rw-r--r-- | map/framework.cpp | 11 | ||||
-rw-r--r-- | map/framework.hpp | 24 |
2 files changed, 18 insertions, 17 deletions
diff --git a/map/framework.cpp b/map/framework.cpp index c5253230b3..2fd2cacd9a 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -412,6 +412,8 @@ Framework::Framework() editor.LoadMapEdits(); m_model.GetIndex().AddObserver(editor); + + LOG(LINFO, ("Editor initialized")); } Framework::~Framework() @@ -2900,12 +2902,3 @@ bool Framework::RollBackChanges(FeatureID const & fid) } return rolledBack; } - -bool Framework::UpdateUserStats(string const & userName) -{ - auto userStats = make_unique<editor::UserStats>(userName); - if (!userStats->GetUpdateStatus()) - return false; - m_userStats = move(userStats); - return true; -} diff --git a/map/framework.hpp b/map/framework.hpp index 1fd41a1d7f..1e8a4c2dea 100644 --- a/map/framework.hpp +++ b/map/framework.hpp @@ -43,7 +43,6 @@ #include "base/thread_checker.hpp" #include "std/list.hpp" -#include "std/shared_ptr.hpp" #include "std/target_os.hpp" #include "std/unique_ptr.hpp" #include "std/vector.hpp" @@ -675,15 +674,24 @@ private: public: //@{ - //User statistics. - editor::UserStats const * GetUserStats() const { return m_userStats.get(); } - /// Sends a synchronous request to the server and updates user's stats. - /// @returns true on success. - bool UpdateUserStats(string const & userName); - void DropUserStats() { m_userStats = nullptr; } + // User statistics. + + editor::UserStats GetUserStats(string const & userName) const + { + return m_userStatsLoader.GetStats(userName); + } + + // Reads user stats from server or gets it from cache calls |fn| on success. + void UpdateUserStats(string const & userName, + editor::UserStatsLoader::TOnUpdateCallback fn) + { + m_userStatsLoader.Update(userName, fn); + } + + void DropUserStats(string const & userName) { m_userStatsLoader.DropStats(userName); } private: - unique_ptr<editor::UserStats> m_userStats; + editor::UserStatsLoader m_userStatsLoader; //@} DECLARE_THREAD_CHECKER(m_threadChecker); |