diff options
author | George Hazan <george.hazan@gmail.com> | 2024-04-09 12:30:16 +0300 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2024-04-09 12:30:16 +0300 |
commit | ec677fe11c84c09d10b3bbf7c7bca53ff105df22 (patch) | |
tree | f5aec5919afaa997ca9df02793e2001a8dce4492 /plugins/NewStory/src | |
parent | 35779696d8cc4aa50408e5dc660a74c854bc5cc4 (diff) |
NewStory: control attempts to fetch events up even if the history is empty
Diffstat (limited to 'plugins/NewStory/src')
-rw-r--r-- | plugins/NewStory/src/history_control.cpp | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/plugins/NewStory/src/history_control.cpp b/plugins/NewStory/src/history_control.cpp index 669e5f40f3..43a0cf6e4a 100644 --- a/plugins/NewStory/src/history_control.cpp +++ b/plugins/NewStory/src/history_control.cpp @@ -930,17 +930,27 @@ void NewstoryListData::ToggleSelection(int iFirst, int iLast) void NewstoryListData::TryUp(int iCount)
{
- if (totalCount == 0)
+ MEVENT hTopEvent = 0;
+ MCONTACT hContact;
+
+ if (totalCount != 0) {
+ auto *pTop = GetItem(0);
+ hContact = pTop->hContact;
+ hTopEvent = pTop->dbe.getEvent();
+ if (hTopEvent == 0)
+ return;
+ }
+ else {
+ hContact = (pMsgDlg) ? pMsgDlg->m_hContact : 0;
+ hTopEvent = -1;
+ }
+
+ if (hContact == 0)
return;
- auto *pTop = GetItem(0);
- MCONTACT hContact = pTop->hContact;
- if (pTop->dbe.getEvent() == 0 || hContact == 0)
- return;
-
int i;
for (i = 0; i < iCount; i++) {
- MEVENT hPrev = db_event_prev(hContact, pTop->dbe.getEvent());
+ MEVENT hPrev = (hTopEvent == -1) ? db_event_last(hContact) : db_event_prev(hContact, hTopEvent);
if (hPrev == 0)
break;
@@ -952,10 +962,9 @@ void NewstoryListData::TryUp(int iCount) }
ItemData *pPrev = nullptr;
- for (int j = 0; j < i + 1; j++) {
- auto *pItem = GetItem(j);
- pPrev = pItem->checkNext(pPrev);
- }
+ for (int j = 0; j < i + 1; j++)
+ if (auto *pItem = GetItem(j))
+ pPrev = pItem->checkNext(pPrev);
caret = 0;
CalcBottom();
|