mirror of
https://github.com/vale981/tdesktop
synced 2025-03-06 10:11:41 -05:00
improved messages to self: always not unread, show sending clock icon
This commit is contained in:
parent
ad21781c7c
commit
bb416b520a
6 changed files with 50 additions and 30 deletions
|
@ -967,8 +967,8 @@ namespace App {
|
|||
}
|
||||
}
|
||||
|
||||
bool showPhone = !isServiceUser(user->id) && (user->input.type() != mtpc_inputPeerSelf) && !user->contact;
|
||||
bool showPhoneChanged = !isServiceUser(user->id) && (user->input.type() != mtpc_inputPeerSelf) && ((showPhone && !wasShowPhone) || (!showPhone && wasShowPhone));
|
||||
bool showPhone = !isServiceUser(user->id) && !user->isSelf() && !user->contact;
|
||||
bool showPhoneChanged = !isServiceUser(user->id) && !user->isSelf() && ((showPhone && !wasShowPhone) || (!showPhone && wasShowPhone));
|
||||
if (showPhoneChanged) {
|
||||
user->setName(textOneLine(user->firstName), textOneLine(user->lastName), showPhone ? App::formatPhone(user->phone) : QString(), textOneLine(user->username));
|
||||
}
|
||||
|
|
|
@ -891,13 +891,7 @@ HistoryItem *ChannelHistory::addNewToBlocks(const MTPMessage &msg, NewMessageTyp
|
|||
if (item && isImportant) {
|
||||
setLastMessage(item);
|
||||
if (type == NewMessageUnread) {
|
||||
if (item->unread()) {
|
||||
newItemAdded(item);
|
||||
} else if (item->out()) {
|
||||
outboxRead(item);
|
||||
} else {
|
||||
inboxRead(item);
|
||||
}
|
||||
newItemAdded(item);
|
||||
}
|
||||
}
|
||||
return item;
|
||||
|
@ -1565,13 +1559,7 @@ HistoryItem *History::addNewMessage(const MTPMessage &msg, NewMessageType type)
|
|||
if (item) {
|
||||
setLastMessage(item);
|
||||
if (type == NewMessageUnread) {
|
||||
if (item->unread()) {
|
||||
newItemAdded(item);
|
||||
} else if (item->out()) {
|
||||
outboxRead(item);
|
||||
} else {
|
||||
inboxRead(item);
|
||||
}
|
||||
newItemAdded(item);
|
||||
}
|
||||
}
|
||||
return item;
|
||||
|
@ -1677,13 +1665,7 @@ HistoryItem *History::addNewItem(HistoryBlock *to, bool newBlock, HistoryItem *a
|
|||
height += dh;
|
||||
}
|
||||
if (newMsg) {
|
||||
if (adding->unread()) {
|
||||
newItemAdded(adding);
|
||||
} else if (adding->out()) {
|
||||
outboxRead(adding);
|
||||
} else {
|
||||
inboxRead(adding);
|
||||
}
|
||||
newItemAdded(adding);
|
||||
}
|
||||
|
||||
if (!isChannel() || adding->fromChannel()) {
|
||||
|
@ -1764,12 +1746,17 @@ void History::newItemAdded(HistoryItem *item) {
|
|||
}
|
||||
if (item->out()) {
|
||||
if (unreadBar) unreadBar->destroy();
|
||||
if (!item->unread()) {
|
||||
outboxRead(item);
|
||||
}
|
||||
} else if (item->unread()) {
|
||||
bool skip = false;
|
||||
if (!isChannel() || peer->asChannel()->amIn()) {
|
||||
notifies.push_back(item);
|
||||
App::main()->newUnreadMsg(this, item);
|
||||
}
|
||||
} else {
|
||||
inboxRead(item);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6379,6 +6366,10 @@ void HistoryMessage::drawInfo(Painter &p, int32 right, int32 bottom, bool select
|
|||
}
|
||||
}
|
||||
p.drawPixmap(iconPos, App::sprite(), *iconRect);
|
||||
} else if (id < 0 && history()->peer->isSelf()) {
|
||||
iconPos = QPoint(infoRight - infoW, infoBottom - st::msgViewsImg.pxHeight() + st::msgViewsPos.y());
|
||||
iconRect = &(overimg ? st::msgInvSendingViewsImg : st::msgSendingViewsImg);
|
||||
p.drawPixmap(iconPos, App::sprite(), *iconRect);
|
||||
}
|
||||
if (out() && !fromChannel()) {
|
||||
iconPos = QPoint(infoRight - st::msgCheckImg.pxWidth() + st::msgCheckPos.x(), infoBottom - st::msgCheckImg.pxHeight() + st::msgCheckPos.y());
|
||||
|
@ -6415,6 +6406,22 @@ void HistoryMessage::setViewsCount(int32 count) {
|
|||
}
|
||||
}
|
||||
|
||||
void HistoryMessage::setId(MsgId newId) {
|
||||
bool wasPositive = (id > 0), positive = (newId > 0);
|
||||
id = newId;
|
||||
if (wasPositive == positive) {
|
||||
if (App::main()) App::main()->msgUpdated(history()->peer->id, this);
|
||||
} else {
|
||||
if (_text.hasSkipBlock()) {
|
||||
_text.setSkipBlock(HistoryMessage::skipBlockWidth(), HistoryMessage::skipBlockHeight());
|
||||
_textWidth = 0;
|
||||
_textHeight = 0;
|
||||
}
|
||||
initDimensions();
|
||||
if (App::main()) App::main()->itemResized(this);
|
||||
}
|
||||
}
|
||||
|
||||
void HistoryMessage::draw(Painter &p, uint32 selection) const {
|
||||
bool outbg = out() && !fromChannel();
|
||||
|
||||
|
|
|
@ -831,7 +831,7 @@ public:
|
|||
}
|
||||
bool unread() const {
|
||||
if ((out() && (id > 0 && id < _history->outboxReadBefore)) || (!out() && id > 0 && id < _history->inboxReadBefore)) return false;
|
||||
return (id > 0 && !out() && channelId() != NoChannel) ? true : (_flags & MTPDmessage_flag_unread);
|
||||
return (id > 0 && !out() && channelId() != NoChannel) ? true : (history()->peer->isSelf() ? false : (_flags & MTPDmessage_flag_unread));
|
||||
}
|
||||
bool notifyByFrom() const {
|
||||
return _flags & MTPDmessage_flag_notify_by_from;
|
||||
|
@ -858,7 +858,7 @@ public:
|
|||
return _history->isChannel() && isImportantChannelMessage(id, _flags);
|
||||
}
|
||||
virtual bool needCheck() const {
|
||||
return out();
|
||||
return out() || (id < 0 && history()->peer->isSelf());
|
||||
}
|
||||
virtual bool hasPoint(int32 x, int32 y) const {
|
||||
return false;
|
||||
|
@ -898,6 +898,9 @@ public:
|
|||
}
|
||||
virtual void setViewsCount(int32 count) {
|
||||
}
|
||||
virtual void setId(MsgId newId) {
|
||||
id = newId;
|
||||
}
|
||||
virtual void drawInDialog(Painter &p, const QRect &r, bool act, const HistoryItem *&cacheFor, Text &cache) const = 0;
|
||||
virtual QString notificationHeader() const {
|
||||
return QString();
|
||||
|
@ -1524,6 +1527,7 @@ public:
|
|||
|
||||
void drawInfo(Painter &p, int32 right, int32 bottom, bool selected, InfoDisplayType type) const;
|
||||
void setViewsCount(int32 count);
|
||||
void setId(MsgId newId);
|
||||
void draw(Painter &p, uint32 selection) const;
|
||||
virtual void drawMessageText(Painter &p, const QRect &trect, uint32 selection) const;
|
||||
|
||||
|
@ -1564,6 +1568,8 @@ public:
|
|||
int32 result = _timeWidth;
|
||||
if (!_viewsText.isEmpty()) {
|
||||
result += st::msgDateViewsSpace + _viewsWidth + st::msgDateCheckSpace + st::msgViewsImg.pxWidth();
|
||||
} else if (id < 0 && history()->peer->isSelf()) {
|
||||
result += st::msgDateCheckSpace + st::msgCheckImg.pxWidth();
|
||||
}
|
||||
if (out() && !fromChannel()) {
|
||||
result += st::msgDateCheckSpace + st::msgCheckImg.pxWidth();
|
||||
|
@ -1574,6 +1580,8 @@ public:
|
|||
int32 result = 0;
|
||||
if (!_viewsText.isEmpty()) {
|
||||
result += st::msgDateViewsSpace + _viewsWidth + st::msgDateCheckSpace + st::msgViewsImg.pxWidth();
|
||||
} else if (id < 0 && history()->peer->isSelf()) {
|
||||
result += st::msgDateCheckSpace + st::msgCheckImg.pxWidth();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -5765,7 +5765,7 @@ void HistoryWidget::onStickerSend(DocumentData *sticker) {
|
|||
|
||||
bool lastKeyboardUsed = lastForceReplyReplied();
|
||||
|
||||
bool out = (_peer->input.type() != mtpc_inputPeerSelf), unread = (_peer->input.type() != mtpc_inputPeerSelf);
|
||||
bool out = !_peer->isSelf(), unread = !_peer->isSelf();
|
||||
int32 flags = newMessageFlags(_peer) | MTPDmessage::flag_media; // unread, out
|
||||
int32 sendFlags = 0;
|
||||
if (replyToId()) {
|
||||
|
|
|
@ -4318,7 +4318,10 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
|
|||
}
|
||||
}
|
||||
if (App::wnd()) App::wnd()->changingMsgId(msgRow, d.vid.v);
|
||||
msgRow->id = d.vid.v;
|
||||
msgRow->setId(d.vid.v);
|
||||
if (msgRow->history()->peer->isSelf()) {
|
||||
msgRow->history()->unregTyping(App::self());
|
||||
}
|
||||
if (!App::historyRegItem(msgRow)) {
|
||||
msgUpdated(h->peer->id, msgRow);
|
||||
} else {
|
||||
|
@ -4560,7 +4563,7 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
|
|||
UserData *user = App::userLoaded(d.vuser_id.v);
|
||||
if (user) {
|
||||
user->setPhone(qs(d.vphone));
|
||||
user->setName(user->firstName, user->lastName, (user->contact || isServiceUser(user->id) || user->input.type() == mtpc_inputPeerSelf || user->phone.isEmpty()) ? QString() : App::formatPhone(user->phone), user->username);
|
||||
user->setName(user->firstName, user->lastName, (user->contact || isServiceUser(user->id) || user->isSelf() || user->phone.isEmpty()) ? QString() : App::formatPhone(user->phone), user->username);
|
||||
App::markPeerUpdated(user);
|
||||
}
|
||||
} break;
|
||||
|
|
|
@ -207,6 +207,9 @@ public:
|
|||
bool isChannel() const {
|
||||
return peerIsChannel(id);
|
||||
}
|
||||
bool isSelf() const {
|
||||
return (input.type() == mtpc_inputPeerSelf);
|
||||
}
|
||||
UserData *asUser();
|
||||
const UserData *asUser() const;
|
||||
ChatData *asChat();
|
||||
|
@ -582,9 +585,8 @@ inline const QString &PeerData::userName() const {
|
|||
return isUser() ? asUser()->username : (isChannel() ? asChannel()->username : emptyUsername());
|
||||
}
|
||||
|
||||
|
||||
inline int32 newMessageFlags(PeerData *p) {
|
||||
return (p->input.type() == mtpc_inputPeerSelf) ? 0 : (((p->isChat() || (p->isUser() && !p->asUser()->botInfo)) ? MTPDmessage_flag_unread : 0) | MTPDmessage_flag_out);
|
||||
return p->isSelf() ? 0 : (((p->isChat() || (p->isUser() && !p->asUser()->botInfo)) ? MTPDmessage_flag_unread : 0) | MTPDmessage_flag_out);
|
||||
}
|
||||
|
||||
typedef QMap<char, QPixmap> PreparedPhotoThumbs;
|
||||
|
|
Loading…
Add table
Reference in a new issue