mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-08-30 22:25:12 +00:00
Simplified saving self bio.
This commit is contained in:
@@ -255,12 +255,7 @@ void SetupRows(
|
||||
AddSkip(container, st::settingsInfoAfterSkip);
|
||||
}
|
||||
|
||||
struct BioManager {
|
||||
rpl::producer<bool> canSave;
|
||||
Fn<void(FnMut<void()> done)> save;
|
||||
};
|
||||
|
||||
BioManager SetupBio(
|
||||
void SetupBio(
|
||||
not_null<Ui::VerticalLayout*> container,
|
||||
not_null<UserData*> self) {
|
||||
AddDivider(container);
|
||||
@@ -268,8 +263,7 @@ BioManager SetupBio(
|
||||
|
||||
const auto bioStyle = [] {
|
||||
auto result = st::settingsBio;
|
||||
result.textMargins.setRight(
|
||||
st::boxTextFont->spacew
|
||||
result.textMargins.setRight(st::boxTextFont->spacew
|
||||
+ st::boxTextFont->width(QString::number(kMaxBioLength)));
|
||||
return result;
|
||||
};
|
||||
@@ -317,10 +311,9 @@ BioManager SetupBio(
|
||||
const auto countLeft = qMax(kMaxBioLength - text.size(), 0);
|
||||
countdown->setText(QString::number(countLeft));
|
||||
};
|
||||
const auto save = [=](FnMut<void()> done) {
|
||||
const auto save = [=] {
|
||||
self->session().api().saveSelfBio(
|
||||
TextUtilities::PrepareForSending(bio->getLastText()),
|
||||
std::move(done));
|
||||
TextUtilities::PrepareForSending(bio->getLastText()));
|
||||
};
|
||||
|
||||
Info::Profile::AboutValue(
|
||||
@@ -343,7 +336,7 @@ BioManager SetupBio(
|
||||
const auto saved = *generation = std::abs(*generation) + 1;
|
||||
base::call_delayed(kSaveBioTimeout, bio, [=] {
|
||||
if (*generation == saved) {
|
||||
save(nullptr);
|
||||
save();
|
||||
*generation = 0;
|
||||
}
|
||||
});
|
||||
@@ -356,7 +349,7 @@ BioManager SetupBio(
|
||||
// to 'container' lifetime, not to the 'bio' lifetime.
|
||||
container->lifetime().add([=] {
|
||||
if (*generation > 0) {
|
||||
save(nullptr);
|
||||
save();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -366,7 +359,7 @@ BioManager SetupBio(
|
||||
cursor.setPosition(bio->getLastText().size());
|
||||
bio->setTextCursor(cursor);
|
||||
QObject::connect(bio, &Ui::InputField::submitted, [=] {
|
||||
save(nullptr);
|
||||
save();
|
||||
});
|
||||
QObject::connect(bio, &Ui::InputField::changed, updated);
|
||||
bio->setInstantReplaces(Ui::InstantReplaces::Default());
|
||||
@@ -386,11 +379,6 @@ BioManager SetupBio(
|
||||
st::settingsBioLabelPadding);
|
||||
|
||||
AddSkip(container);
|
||||
|
||||
return BioManager{
|
||||
changed->events() | rpl::distinct_until_changed(),
|
||||
save
|
||||
};
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@@ -402,14 +390,6 @@ Information::Information(
|
||||
setupContent(controller);
|
||||
}
|
||||
|
||||
//rpl::producer<bool> Information::sectionCanSaveChanges() {
|
||||
// return _canSaveChanges.value();
|
||||
//}
|
||||
//
|
||||
//void Information::sectionSaveChanges(FnMut<void()> done) {
|
||||
// _save(std::move(done));
|
||||
//}
|
||||
|
||||
void Information::setupContent(
|
||||
not_null<Window::SessionController*> controller) {
|
||||
const auto content = Ui::CreateChild<Ui::VerticalLayout>(this);
|
||||
@@ -418,9 +398,6 @@ void Information::setupContent(
|
||||
SetupPhoto(content, controller, self);
|
||||
SetupRows(content, controller, self);
|
||||
SetupBio(content, self);
|
||||
//auto manager = SetupBio(content, self);
|
||||
//_canSaveChanges = std::move(manager.canSave);
|
||||
//_save = std::move(manager.save);
|
||||
|
||||
Ui::ResizeFitChild(this, content);
|
||||
}
|
||||
|
Reference in New Issue
Block a user