From dd37c9651a0a5914a5e8c9be4c2f6ad23faf1a13 Mon Sep 17 00:00:00 2001
From: Ildar Kamalov <i.kamalov@adguard.com>
Date: Thu, 30 Jan 2020 11:57:51 +0300
Subject: [PATCH] - client: add initial flag for getLogs

---
 client/src/components/Logs/index.js | 7 ++++---
 client/src/reducers/queryLogs.js    | 4 ++--
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/client/src/components/Logs/index.js b/client/src/components/Logs/index.js
index 1281db28..f57fb704 100644
--- a/client/src/components/Logs/index.js
+++ b/client/src/components/Logs/index.js
@@ -25,7 +25,8 @@ import './Logs.css';
 import CellWrap from '../ui/CellWrap';
 
 const TABLE_FIRST_PAGE = 0;
-const INITIAL_REQUEST_DATA = ['', TABLE_FIRST_PAGE, TABLE_DEFAULT_PAGE_SIZE];
+const INITIAL_REQUEST = true;
+const INITIAL_REQUEST_DATA = ['', TABLE_FIRST_PAGE, INITIAL_REQUEST];
 const FILTERED_REASON = 'Filtered';
 
 class Logs extends Component {
@@ -36,10 +37,10 @@ class Logs extends Component {
         this.props.getLogsConfig();
     }
 
-    getLogs = (older_than, page) => {
+    getLogs = (older_than, page, initial) => {
         if (this.props.queryLogs.enabled) {
             this.props.getLogs({
-                older_than, page, pageSize: TABLE_DEFAULT_PAGE_SIZE,
+                older_than, page, pageSize: TABLE_DEFAULT_PAGE_SIZE, initial,
             });
         }
     };
diff --git a/client/src/reducers/queryLogs.js b/client/src/reducers/queryLogs.js
index ee1fc91b..52f98fd0 100644
--- a/client/src/reducers/queryLogs.js
+++ b/client/src/reducers/queryLogs.js
@@ -56,9 +56,9 @@ const queryLogs = handleActions(
         [actions.getLogsFailure]: state => ({ ...state, processingGetLogs: false }),
         [actions.getLogsSuccess]: (state, { payload }) => {
             const {
-                logs, oldest, older_than, page, pageSize,
+                logs, oldest, older_than, page, pageSize, initial,
             } = payload;
-            let logsWithOffset = state.allLogs.length > 0 ? state.allLogs : logs;
+            let logsWithOffset = state.allLogs.length > 0 && !initial ? state.allLogs : logs;
             let allLogs = logs;
 
             if (older_than) {