From ee563022d5e1a2e19f40bb0ea705d6483aa48403 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 9 Apr 2024 16:49:51 +0300 Subject: =?UTF-8?q?fixes=20#4338=20(NewStory:=20=D1=80=D0=B5=D0=BF=D0=BB?= =?UTF-8?q?=D0=B0=D0=B8=20=D0=B8=D1=81=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D1=83?= =?UTF-8?q?=D1=8E=D1=82=20=D1=84=D0=BE=D1=80=D0=BC=D0=B0=D1=82=20=D0=B4?= =?UTF-8?q?=D0=B0=D1=82=D1=8B=20=D0=B8=D0=B7=20=D0=BE=D0=BF=D0=B5=D1=80?= =?UTF-8?q?=D0=B0=D1=86=D0=B8=D0=BE=D0=BD=D0=BD=D0=BE=D0=B9=20=D1=81=D0=B8?= =?UTF-8?q?=D1=81=D1=82=D0=B5=D0=BC=D1=8B)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/NewStory/src/history_array.cpp | 34 ++++++++++++++++++---------------- plugins/NewStory/src/history_array.h | 5 +++-- 2 files changed, 21 insertions(+), 18 deletions(-) (limited to 'plugins/NewStory/src') diff --git a/plugins/NewStory/src/history_array.cpp b/plugins/NewStory/src/history_array.cpp index 09cb998927..d426456c4f 100644 --- a/plugins/NewStory/src/history_array.cpp +++ b/plugins/NewStory/src/history_array.cpp @@ -71,7 +71,15 @@ bool Filter::check(ItemData *item) const ItemData::ItemData() { memset(this, 0, sizeof(*this)); - savedHeight = -1; +} + +ItemData::ItemData(MEVENT hEvent) : + dbe(hEvent, true), + qtext(0), + pOwner(0) +{ + if (dbe.szReplyId) + dbe.szReplyId = mir_strdup(dbe.szReplyId); } ItemData::~ItemData() @@ -375,7 +383,8 @@ void ItemData::load(bool bLoadAlways) switch (dbe.eventType) { case EVENTTYPE_MESSAGE: - pOwner->MarkRead(this); + if (pOwner) + pOwner->MarkRead(this); __fallthrough; case EVENTTYPE_STATUSCHANGE: @@ -438,16 +447,13 @@ void ItemData::load(bool bLoadAlways) if (dbe.szReplyId) if (MEVENT hReply = db_event_getById(dbe.szModule, dbe.szReplyId)) { - DB::EventInfo dbei(hReply); - if (dbei) { + ItemData reply(hReply); + if (reply.dbe) { CMStringW str, wszNick; - wchar_t wszTime[100]; - TimeZone_PrintTimeStamp(0, dbei.timestamp, L"D t", wszTime, _countof(wszTime), 0); - - if (Contact::IsGroupChat(hContact) && dbei.szUserId) - wszNick = Utf2T(dbei.szUserId); - else if (dbei.flags & DBEF_SENT) { + if (Contact::IsGroupChat(hContact) && reply.dbe.szUserId) + wszNick = Utf2T(reply.dbe.szUserId); + else if (reply.dbe.flags & DBEF_SENT) { if (char *szProto = Proto_GetBaseAccountName(hContact)) wszNick = ptrW(Contact::GetInfo(CNF_DISPLAY, 0, szProto)); else @@ -455,13 +461,9 @@ void ItemData::load(bool bLoadAlways) } else wszNick = Clist_GetContactDisplayName(hContact, 0); - str.AppendFormat(L"%s %s %s:\n", wszTime, wszNick.c_str(), TranslateT("wrote")); + reply.wszNick = wszNick.GetBuffer(); - ptrW wszText(DbEvent_GetTextW(&dbei)); - if (mir_wstrlen(wszText) > 43) - wcscpy(wszText.get() + 40, L"..."); - str.Append(wszText); - qtext = str.Detach(); + qtext = TplFormatString(TPL_MESSAGE, hContact, &reply).Detach(); } } diff --git a/plugins/NewStory/src/history_array.h b/plugins/NewStory/src/history_array.h index 2fa212c0d6..c671d76f53 100644 --- a/plugins/NewStory/src/history_array.h +++ b/plugins/NewStory/src/history_array.h @@ -19,7 +19,7 @@ struct ItemData bool m_bOfflineFile; uint8_t m_grouping, m_bOfflineDownloaded; - int savedTop, savedHeight, leftOffset; + int savedTop, savedHeight = -1, leftOffset; DB::EventInfo dbe; wchar_t *wtext, *qtext; @@ -28,7 +28,8 @@ struct ItemData litehtml::document::ptr m_doc; - ItemData(); + explicit ItemData(); + explicit ItemData(MEVENT); ~ItemData(); ItemData* checkNext(ItemData *pPrev); -- cgit v1.2.3