void PeerData::updateNameDelayed( const QString &newName, const QString &newNameOrPhone, const QString &newUsername) { if (name == newName) { if (isUser()) { if (asUser()->nameOrPhone == newNameOrPhone && asUser()->username == newUsername) { return; } } else if (isChannel()) { if (asChannel()->username == newUsername) { return; } } else if (isChat()) { return; } } ++nameVersion; name = newName; nameText.setText(st::msgNameStyle, name, Ui::NameTextOptions()); refreshEmptyUserpic(); Notify::PeerUpdate update(this); update.flags |= UpdateFlag::NameChanged; update.oldNameFirstChars = nameFirstChars(); if (isUser()) { if (asUser()->username != newUsername) { asUser()->username = newUsername; update.flags |= UpdateFlag::UsernameChanged; } asUser()->setNameOrPhone(newNameOrPhone); } else if (isChannel()) { if (asChannel()->username != newUsername) { asChannel()->username = newUsername; if (newUsername.isEmpty()) { asChannel()->removeFlags( MTPDchannel::Flag::f_username); } else { asChannel()->addFlags(MTPDchannel::Flag::f_username); } update.flags |= UpdateFlag::UsernameChanged; } } fillNames(); Notify::PeerUpdated().notify(update, true); }
void PeerData::updateFullForced() { Auth().api().requestFullPeer(this); if (auto channel = asChannel()) { if (!channel->amCreator() && !channel->inviter) { Auth().api().requestSelfParticipant(channel); } } }
void VM::printUncaughtError(gc<Fiber> fiber, gc<Object> error) { // Lazy lookup the error channel. if (errorChannel_.isNull()) { Module* core = findModule("core"); ASSERT_NOT_NULL(core); errorChannel_ = asChannel(core->getVariable("_errorChannel")); } // Send the error to the error-printing fiber and suspend the erroring one. errorChannel_->send(fiber, error); }
bool HistoryItem::canStopPoll() const { if (id < 0 || Has<HistoryMessageVia>() || Has<HistoryMessageForwarded>()) { return false; } const auto peer = _history->peer; if (peer->isSelf()) { return true; } else if (const auto channel = peer->asChannel()) { if (isPost() && channel->canEditMessages()) { return true; } else if (out()) { return isPost() ? channel->canPublish() : channel->canWrite(); } else { return false; } } return out(); }
void PeerData::fillNames() { _nameWords.clear(); _nameFirstChars.clear(); auto toIndexList = QStringList(); auto appendToIndex = [&](const QString &value) { if (!value.isEmpty()) { toIndexList.push_back(TextUtilities::RemoveAccents(value)); } }; appendToIndex(name); const auto appendTranslit = !toIndexList.isEmpty() && cRussianLetters().match(toIndexList.front()).hasMatch(); if (appendTranslit) { appendToIndex(translitRusEng(toIndexList.front())); } if (auto user = asUser()) { if (user->nameOrPhone != name) { appendToIndex(user->nameOrPhone); } appendToIndex(user->username); if (isSelf()) { appendToIndex(lang(lng_saved_messages)); } } else if (auto channel = asChannel()) { appendToIndex(channel->username); } auto toIndex = toIndexList.join(' '); toIndex += ' ' + rusKeyboardLayoutSwitch(toIndex); const auto namesList = TextUtilities::PrepareSearchWords(toIndex); for (const auto &name : namesList) { _nameWords.insert(name); _nameFirstChars.insert(name[0]); } }