Skip to content

Commit

Permalink
reformat code
Browse files Browse the repository at this point in the history
  • Loading branch information
d99kris committed Dec 9, 2023
1 parent b5d80cd commit 5c41ced
Show file tree
Hide file tree
Showing 5 changed files with 167 additions and 163 deletions.
14 changes: 9 additions & 5 deletions lib/tgchat/src/tgchat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1190,7 +1190,7 @@ void TgChat::Impl::InitProxy()
auto proxies = td::move_tl_object_as<td::td_api::proxies>(proxiesObject);
if (!proxies) return;

for (const td::td_api::object_ptr<td::td_api::proxy> &proxy : proxies->proxies_)
for (const td::td_api::object_ptr<td::td_api::proxy>& proxy : proxies->proxies_)
{
if (proxy)
{
Expand Down Expand Up @@ -2490,19 +2490,22 @@ void TgChat::Impl::GetSponsoredMessages(const std::string& p_ChatId)
}
else if (sponsoredMessage->sponsor_->type_->get_id() == td::td_api::messageSponsorTypePublicChannel::ID)
{
auto& messageSponsorTypePublicChannel = static_cast<td::td_api::messageSponsorTypePublicChannel&>(*sponsoredMessage->sponsor_->type_);
auto& messageSponsorTypePublicChannel =
static_cast<td::td_api::messageSponsorTypePublicChannel&>(*sponsoredMessage->sponsor_->type_);
chatMessage.senderId = StrUtil::NumToHex(messageSponsorTypePublicChannel.chat_id_);
link = td::move_tl_object_as<td::td_api::InternalLinkType>(messageSponsorTypePublicChannel.link_);
}
else if (sponsoredMessage->sponsor_->type_->get_id() == td::td_api::messageSponsorTypePrivateChannel::ID)
{
auto& messageSponsorTypePrivateChannel = static_cast<const td::td_api::messageSponsorTypePrivateChannel&>(*sponsoredMessage->sponsor_->type_);
auto& messageSponsorTypePrivateChannel =
static_cast<const td::td_api::messageSponsorTypePrivateChannel&>(*sponsoredMessage->sponsor_->type_);
// @todo: chatMessage.senderId = StrUtil::NumToHex(messageSponsorTypePrivateChannel.bot_user_id_);
url = messageSponsorTypePrivateChannel.invite_link_;
}
else if (sponsoredMessage->sponsor_->type_->get_id() == td::td_api::messageSponsorTypeWebsite::ID)
{
auto& messageSponsorTypeWebsite = static_cast<const td::td_api::messageSponsorTypeWebsite&>(*sponsoredMessage->sponsor_->type_);
auto& messageSponsorTypeWebsite =
static_cast<const td::td_api::messageSponsorTypeWebsite&>(*sponsoredMessage->sponsor_->type_);
// @todo: chatMessage.senderId = StrUtil::NumToHex(messageSponsorTypeWebsite.bot_user_id_);
url = messageSponsorTypeWebsite.url_;
}
Expand Down Expand Up @@ -2622,7 +2625,8 @@ std::string TgChat::Impl::GetContactName(int64_t p_UserId)
}
}

void TgChat::Impl::GetChatHistory(int64_t p_ChatId, int64_t p_FromMsgId, int32_t p_Offset, int32_t p_Limit, bool p_Sequence)
void TgChat::Impl::GetChatHistory(int64_t p_ChatId, int64_t p_FromMsgId, int32_t p_Offset, int32_t p_Limit,
bool p_Sequence)
{
// *INDENT-OFF*
Status::Set(Status::FlagFetching);
Expand Down
28 changes: 14 additions & 14 deletions lib/wmchat/go/gowm.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,8 +340,8 @@ func JidToStr(jid types.JID) string {
}

func GetChatId(chatJid types.JID, senderJid types.JID) string {
if (chatJid.Server == "broadcast") {
if (chatJid.User == "status") {
if chatJid.Server == "broadcast" {
if chatJid.User == "status" {
return JidToStr(chatJid) // status updates
} else {
return JidToStr(senderJid) // broadcast messages
Expand Down Expand Up @@ -615,7 +615,7 @@ func (handler *WmEventHandler) HandleHistorySync(historySync *events.HistorySync
hasMessages = true
}

if (hasMessages) {
if hasMessages {
isMuted := false
settings, setErr := client.Store.ChatSettings.GetChatSettings(chatJid)
if setErr != nil {
Expand Down Expand Up @@ -648,7 +648,7 @@ func (handler *WmEventHandler) HandleGroupInfo(groupInfo *events.GroupInfo) {
quotedId := ""
selfJid := *client.Store.ID
senderJidStr := ""
if ((groupInfo.Sender != nil) && (JidToStr(*groupInfo.Sender) != JidToStr(groupInfo.JID))) {
if (groupInfo.Sender != nil) && (JidToStr(*groupInfo.Sender) != JidToStr(groupInfo.JID)) {
senderJidStr = JidToStr(*groupInfo.Sender)
}

Expand All @@ -657,21 +657,21 @@ func (handler *WmEventHandler) HandleGroupInfo(groupInfo *events.GroupInfo) {
fileStatus := FileStatusNone

text := ""
if (groupInfo.Name != nil) {
if groupInfo.Name != nil {
// Group name change
if (senderJidStr == "") {
if senderJidStr == "" {
senderJidStr = JidToStr(groupInfo.JID)
}

groupName := *groupInfo.Name
text = "[Changed group name to " + groupName.Name + "]"
} else if (len(groupInfo.Join) > 0) {
} else if len(groupInfo.Join) > 0 {
// Group member joined
if ((len(groupInfo.Join) == 1) && ((senderJidStr == "") || (senderJidStr == JidToStr(groupInfo.Join[0])))) {
if (len(groupInfo.Join) == 1) && ((senderJidStr == "") || (senderJidStr == JidToStr(groupInfo.Join[0]))) {
senderJidStr = JidToStr(groupInfo.Join[0])
text = "[Joined]"
} else {
if (senderJidStr == "") {
if senderJidStr == "" {
senderJidStr = JidToStr(groupInfo.JID)
}

Expand All @@ -686,13 +686,13 @@ func (handler *WmEventHandler) HandleGroupInfo(groupInfo *events.GroupInfo) {

text = "[Added " + joined + "]"
}
} else if (len(groupInfo.Leave) > 0) {
} else if len(groupInfo.Leave) > 0 {
// Group member left
if ((len(groupInfo.Leave) == 1) && ((senderJidStr == "") || (senderJidStr == JidToStr(groupInfo.Leave[0])))) {
if (len(groupInfo.Leave) == 1) && ((senderJidStr == "") || (senderJidStr == JidToStr(groupInfo.Leave[0]))) {
senderJidStr = JidToStr(groupInfo.Leave[0])
text = "[Left]"
} else {
if (senderJidStr == "") {
if senderJidStr == "" {
senderJidStr = JidToStr(groupInfo.JID)
}

Expand Down Expand Up @@ -735,7 +735,7 @@ func (handler *WmEventHandler) HandleDeleteChat(deleteChat *events.DeleteChat) {
chatId := deleteChat.JID.ToNonAD().String()

LOG_TRACE(fmt.Sprintf("Call CWmDeleteChatNotify %s", chatId))
CWmDeleteChatNotify(connId, chatId);
CWmDeleteChatNotify(connId, chatId)
}

func (handler *WmEventHandler) HandleMute(mute *events.Mute) {
Expand All @@ -750,7 +750,7 @@ func (handler *WmEventHandler) HandleMute(mute *events.Mute) {
isMuted := *muteAction.Muted

LOG_TRACE(fmt.Sprintf("Call CWmUpdateMuteNotify %s %s", chatId, strconv.FormatBool(isMuted)))
CWmUpdateMuteNotify(connId, chatId, BoolToInt(isMuted));
CWmUpdateMuteNotify(connId, chatId, BoolToInt(isMuted))
}

func GetNameFromContactInfo(contactInfo types.ContactInfo) string {
Expand Down
3 changes: 2 additions & 1 deletion src/uicontactlistdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ void UiContactListDialog::UpdateList()
(StrUtil::ToLower(name).find(StrUtil::ToLower(StrUtil::ToString(m_FilterStr))) != std::string::npos))
{
static const bool isMultipleProfiles = m_Model->IsMultipleProfiles();
std::string displayName = name + (isMultipleProfiles ? " @ " + m_Model->GetProfileDisplayName(contactInfo.first) : "");
std::string displayName = name +
(isMultipleProfiles ? " @ " + m_Model->GetProfileDisplayName(contactInfo.first) : "");
m_Items.push_back(StrUtil::TrimPadWString(StrUtil::ToWString(displayName), m_W));
m_ContactInfosVec.push_back(std::make_pair(contactInfo.first, contactInfo.second));
}
Expand Down
Loading

0 comments on commit 5c41ced

Please sign in to comment.