Skip to content

Commit 2ac864a

Browse files
authored
Fix RedisInsight#4014: Undefined rows on second Hash page (RedisInsight#4019)
1 parent fd5f44d commit 2ac864a

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

src/modules/value-editor/valueviewmodel.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,18 @@ bool ValueEditor::ValueViewModel::isRowLoaded(int i)
6969
return m_model.isRowLoaded(i);
7070
}
7171

72-
void ValueEditor::ValueViewModel::loadRows(int start, int count)
72+
void ValueEditor::ValueViewModel::loadRows(int start, int limit)
7373
{
74+
int rowsLeft = totalRowCount() - start;
75+
int loaded = (rowsLeft > limit) ? limit : rowsLeft;
76+
7477
// frame already loaded
7578
if (m_model.isRowLoaded(start)) {
7679
m_startFramePosition = start;
80+
m_lastLoadedRowFrameSize = loaded;
81+
7782
emit layoutAboutToBeChanged();
78-
emit rowsLoaded(start, count);
83+
emit rowsLoaded(start, loaded);
7984
emit layoutChanged();
8085
return;
8186
}
@@ -85,15 +90,12 @@ void ValueEditor::ValueViewModel::loadRows(int start, int count)
8590
try {
8691
// NOTE(u_glide): Do so for proper rendering of QML table
8792
m_lastLoadedRowFrameSize = totalRowCount() - start;
88-
m_model.loadRows(start, count, [this, start, count, msg](const QString& err)
93+
m_model.loadRows(start, limit, [this, start, limit, loaded, msg](const QString& err)
8994
{
9095
if (!err.isEmpty()) {
9196
emit error(msg.arg(err));
9297
return;
93-
}
94-
95-
int loaded = totalRowCount() - start;
96-
loaded = (loaded > count) ? count : loaded;
98+
}
9799

98100
m_lastLoadedRowFrameSize = loaded;
99101
m_startFramePosition = start;

src/modules/value-editor/valueviewmodel.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class ValueViewModel : public QAbstractListModel
2727
Q_INVOKABLE QVariantMap getRow(int i);
2828

2929
// multi row operations
30-
Q_INVOKABLE void loadRows(int start, int count);
30+
Q_INVOKABLE void loadRows(int start, int limit);
3131
Q_INVOKABLE bool isMultiRow();
3232
Q_INVOKABLE void reload();
3333
Q_INVOKABLE int totalRowCount();

0 commit comments

Comments
 (0)