From a51716398f6ebc39004cbe6143956b7ce2a62b01 Mon Sep 17 00:00:00 2001
From: George Hazan <george.hazan@gmail.com>
Date: Tue, 9 Apr 2024 18:54:23 +0300
Subject: =?UTF-8?q?Revert=20"fixes=20#4338=20(NewStory:=20=D1=80=D0=B5?=
 =?UTF-8?q?=D0=BF=D0=BB=D0=B0=D0=B8=20=D0=B8=D1=81=D0=BF=D0=BE=D0=BB=D1=8C?=
 =?UTF-8?q?=D0=B7=D1=83=D1=8E=D1=82=20=D1=84=D0=BE=D1=80=D0=BC=D0=B0=D1=82?=
 =?UTF-8?q?=20=D0=B4=D0=B0=D1=82=D1=8B=20=D0=B8=D0=B7=20=D0=BE=D0=BF=D0=B5?=
 =?UTF-8?q?=D1=80=D0=B0=D1=86=D0=B8=D0=BE=D0=BD=D0=BD=D0=BE=D0=B9=20=D1=81?=
 =?UTF-8?q?=D0=B8=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

This reverts commit ee563022d5e1a2e19f40bb0ea705d6483aa48403.
---
 plugins/NewStory/src/history_array.cpp | 34 ++++++++++++++++------------------
 plugins/NewStory/src/history_array.h   |  5 ++---
 2 files changed, 18 insertions(+), 21 deletions(-)

(limited to 'plugins/NewStory/src')

diff --git a/plugins/NewStory/src/history_array.cpp b/plugins/NewStory/src/history_array.cpp
index d426456c4f..09cb998927 100644
--- a/plugins/NewStory/src/history_array.cpp
+++ b/plugins/NewStory/src/history_array.cpp
@@ -71,15 +71,7 @@ bool Filter::check(ItemData *item) const
 ItemData::ItemData()
 {
 	memset(this, 0, sizeof(*this));
-}
-
-ItemData::ItemData(MEVENT hEvent) :
-	dbe(hEvent, true),
-	qtext(0),
-	pOwner(0)
-{
-	if (dbe.szReplyId)
-		dbe.szReplyId = mir_strdup(dbe.szReplyId);
+	savedHeight = -1;
 }
 
 ItemData::~ItemData()
@@ -383,8 +375,7 @@ void ItemData::load(bool bLoadAlways)
 
 	switch (dbe.eventType) {
 	case EVENTTYPE_MESSAGE:
-		if (pOwner)
-			pOwner->MarkRead(this);
+		pOwner->MarkRead(this);
 		__fallthrough;
 
 	case EVENTTYPE_STATUSCHANGE:
@@ -447,13 +438,16 @@ void ItemData::load(bool bLoadAlways)
 
 	if (dbe.szReplyId)
 		if (MEVENT hReply = db_event_getById(dbe.szModule, dbe.szReplyId)) {
-			ItemData reply(hReply);
-			if (reply.dbe) {
+			DB::EventInfo dbei(hReply);
+			if (dbei) {
 				CMStringW str, wszNick;
 
-				if (Contact::IsGroupChat(hContact) && reply.dbe.szUserId)
-					wszNick = Utf2T(reply.dbe.szUserId);
-				else if (reply.dbe.flags & DBEF_SENT) {
+				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 (char *szProto = Proto_GetBaseAccountName(hContact))
 						wszNick = ptrW(Contact::GetInfo(CNF_DISPLAY, 0, szProto));
 					else
@@ -461,9 +455,13 @@ void ItemData::load(bool bLoadAlways)
 				}
 				else wszNick = Clist_GetContactDisplayName(hContact, 0);
 				
-				reply.wszNick = wszNick.GetBuffer();
+				str.AppendFormat(L"%s %s %s:\n", wszTime, wszNick.c_str(), TranslateT("wrote"));
 
-				qtext = TplFormatString(TPL_MESSAGE, hContact, &reply).Detach();
+				ptrW wszText(DbEvent_GetTextW(&dbei));
+				if (mir_wstrlen(wszText) > 43)
+					wcscpy(wszText.get() + 40, L"...");
+				str.Append(wszText);
+				qtext = str.Detach();
 			}
 		}
 
diff --git a/plugins/NewStory/src/history_array.h b/plugins/NewStory/src/history_array.h
index c671d76f53..2fa212c0d6 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 = -1, leftOffset;
+	int savedTop, savedHeight, leftOffset;
 
 	DB::EventInfo dbe;
 	wchar_t *wtext, *qtext;
@@ -28,8 +28,7 @@ struct ItemData
 
 	litehtml::document::ptr m_doc;
 
-	explicit ItemData();
-	explicit ItemData(MEVENT);
+	ItemData();
 	~ItemData();
 
 	ItemData* checkNext(ItemData *pPrev);
-- 
cgit v1.2.3