mirror of https://github.com/procxx/kepka.git
fixed username save error
This commit is contained in:
parent
4991b6743f
commit
0685cf34d3
|
@ -172,6 +172,7 @@ void UsernameBox::onCheck() {
|
||||||
}
|
}
|
||||||
QString name = getName();
|
QString name = getName();
|
||||||
if (name.size() >= MinUsernameLength) {
|
if (name.size() >= MinUsernameLength) {
|
||||||
|
_checkUsername = getName();
|
||||||
_checkRequest = MTP::send(MTPaccount_CheckUsername(MTP_string(name)), rpcDone(&UsernameBox::onCheckDone), rpcFail(&UsernameBox::onCheckFail));
|
_checkRequest = MTP::send(MTPaccount_CheckUsername(MTP_string(name)), rpcDone(&UsernameBox::onCheckDone), rpcFail(&UsernameBox::onCheckFail));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -207,7 +208,7 @@ void UsernameBox::onUpdateDone(const MTPUser &user) {
|
||||||
bool UsernameBox::onUpdateFail(const RPCError &error) {
|
bool UsernameBox::onUpdateFail(const RPCError &error) {
|
||||||
_saveRequest = 0;
|
_saveRequest = 0;
|
||||||
QString err(error.type()), name = getName();
|
QString err(error.type()), name = getName();
|
||||||
if (err == "USERNAME_NOT_MODIFIED" || _sentUsername == textOneLine(name)) {
|
if (err == "USERNAME_NOT_MODIFIED" || _sentUsername == App::self()->username) {
|
||||||
App::self()->setName(textOneLine(App::self()->firstName), textOneLine(App::self()->lastName), textOneLine(App::self()->nameOrPhone), textOneLine(name));
|
App::self()->setName(textOneLine(App::self()->firstName), textOneLine(App::self()->lastName), textOneLine(App::self()->nameOrPhone), textOneLine(name));
|
||||||
emit closed();
|
emit closed();
|
||||||
return true;
|
return true;
|
||||||
|
@ -216,7 +217,7 @@ bool UsernameBox::onUpdateFail(const RPCError &error) {
|
||||||
_usernameInput.notaBene();
|
_usernameInput.notaBene();
|
||||||
_errorText = lang(lng_username_invalid);
|
_errorText = lang(lng_username_invalid);
|
||||||
return true;
|
return true;
|
||||||
} else if (err == "USERNAME_OCCUPIED") {
|
} else if (err == "USERNAME_OCCUPIED" || err == "USERNAMES_UNAVAILABLE") {
|
||||||
_usernameInput.setFocus();
|
_usernameInput.setFocus();
|
||||||
_usernameInput.notaBene();
|
_usernameInput.notaBene();
|
||||||
_errorText = lang(lng_username_occupied);
|
_errorText = lang(lng_username_occupied);
|
||||||
|
@ -228,7 +229,7 @@ bool UsernameBox::onUpdateFail(const RPCError &error) {
|
||||||
|
|
||||||
void UsernameBox::onCheckDone(const MTPBool &result) {
|
void UsernameBox::onCheckDone(const MTPBool &result) {
|
||||||
_checkRequest = 0;
|
_checkRequest = 0;
|
||||||
QString newError = result.v ? QString() : lang(lng_username_occupied);
|
QString newError = (result.v || _checkUsername == App::self()->username) ? QString() : lang(lng_username_occupied);
|
||||||
if (_errorText != newError) {
|
if (_errorText != newError) {
|
||||||
_errorText = newError;
|
_errorText = newError;
|
||||||
update();
|
update();
|
||||||
|
@ -242,7 +243,7 @@ bool UsernameBox::onCheckFail(const RPCError &error) {
|
||||||
_errorText = lang(lng_username_invalid);
|
_errorText = lang(lng_username_invalid);
|
||||||
update();
|
update();
|
||||||
return true;
|
return true;
|
||||||
} else if (err == "USERNAME_OCCUPIED") {
|
} else if (err == "USERNAME_OCCUPIED" && _checkUsername != App::self()->username) {
|
||||||
_errorText = lang(lng_username_occupied);
|
_errorText = lang(lng_username_occupied);
|
||||||
update();
|
update();
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -72,7 +72,7 @@ private:
|
||||||
QPixmap _cache;
|
QPixmap _cache;
|
||||||
|
|
||||||
mtpRequestId _saveRequest, _checkRequest;
|
mtpRequestId _saveRequest, _checkRequest;
|
||||||
QString _sentUsername, _errorText;
|
QString _sentUsername, _checkUsername, _errorText;
|
||||||
|
|
||||||
Text _about;
|
Text _about;
|
||||||
QTimer _checkTimer;
|
QTimer _checkTimer;
|
||||||
|
|
Loading…
Reference in New Issue