From 78c5dd9a8648dba7ca09f59b4b7460610c6ff3a6 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 18 Sep 2023 18:14:53 +0300 Subject: Telegram: ability to add custom chat reactions using NewHistory --- plugins/ExternalAPI/m_NewStory.h | 10 ++++++++++ plugins/NewStory/src/history_svc.cpp | 14 ++++++++++++++ 2 files changed, 24 insertions(+) (limited to 'plugins') diff --git a/plugins/ExternalAPI/m_NewStory.h b/plugins/ExternalAPI/m_NewStory.h index 309ac45d60..ad6c7583a9 100644 --- a/plugins/ExternalAPI/m_NewStory.h +++ b/plugins/ExternalAPI/m_NewStory.h @@ -2,6 +2,16 @@ #include +///////////////////////////////////////////////////////////////////////////////////////// +// NS get current event + +#define MS_NEWSTORY_GETCURRENT "NewStory/GetCurrent" + +__forceinline MEVENT NS_GetCurrent(HANDLE hwnd) +{ + return (MEVENT)CallService(MS_NEWSTORY_GETCURRENT, WPARAM(hwnd), 0); +} + ///////////////////////////////////////////////////////////////////////////////////////// // NS get selection diff --git a/plugins/NewStory/src/history_svc.cpp b/plugins/NewStory/src/history_svc.cpp index ad59635956..6ddaae2add 100644 --- a/plugins/NewStory/src/history_svc.cpp +++ b/plugins/NewStory/src/history_svc.cpp @@ -17,6 +17,15 @@ along with this program. If not, see . #include "stdafx.h" +static INT_PTR SvcGetCurrent(WPARAM wParam, LPARAM) +{ + if (auto *pData = (NewstoryListData *)wParam) + if (auto *p = pData->GetItem(pData->caret)) + return p->hEvent; + + return 0; +} + static INT_PTR SvcGetSelection(WPARAM wParam, LPARAM lParam) { auto *pData = (NewstoryListData *)wParam; @@ -27,6 +36,10 @@ static INT_PTR SvcGetSelection(WPARAM wParam, LPARAM lParam) if (p->m_bSelected) pRet->push_back(p->hEvent); } + + if (pRet->empty() && pData->caret != -1) + if (auto *p = pData->GetItem(pData->caret)) + pRet->push_back(p->hEvent); } return 0; @@ -37,5 +50,6 @@ static INT_PTR SvcGetSelection(WPARAM wParam, LPARAM lParam) void InitServices() { + CreateServiceFunction(MS_NEWSTORY_GETCURRENT, &SvcGetCurrent); CreateServiceFunction(MS_NEWSTORY_GETSELECTION, &SvcGetSelection); } -- cgit v1.2.3