mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-19 05:12:41 +01:00
Use transactions to apply Ajax settings mutations
Summary: Ref T4103. Some settings (mostly nav collapsed/expanded states) use this endpoint to make adjustments when users press keys (like `\` to toggle the durable column). All of these settings are now formal, so swap things over to transactions. Test Plan: Collapsed/expanded various navs, reloaded pages, settings stuck. Reviewers: chad Reviewed By: chad Maniphest Tasks: T4103 Differential Revision: https://secure.phabricator.com/D16035
This commit is contained in:
parent
e3f4f051fe
commit
6199e95577
1 changed files with 16 additions and 6 deletions
|
@ -4,13 +4,23 @@ final class PhabricatorSettingsAdjustController
|
||||||
extends PhabricatorController {
|
extends PhabricatorController {
|
||||||
|
|
||||||
public function handleRequest(AphrontRequest $request) {
|
public function handleRequest(AphrontRequest $request) {
|
||||||
$user = $request->getUser();
|
$viewer = $this->getViewer();
|
||||||
|
|
||||||
$prefs = $user->loadPreferences();
|
$preferences = PhabricatorUserPreferences::loadUserPreferences($viewer);
|
||||||
$prefs->setPreference(
|
|
||||||
$request->getStr('key'),
|
$editor = id(new PhabricatorUserPreferencesEditor())
|
||||||
$request->getStr('value'));
|
->setActor($viewer)
|
||||||
$prefs->save();
|
->setContentSourceFromRequest($request)
|
||||||
|
->setContinueOnNoEffect(true)
|
||||||
|
->setContinueOnMissingFields(true);
|
||||||
|
|
||||||
|
$key = $request->getStr('key');
|
||||||
|
$value = $request->getStr('value');
|
||||||
|
|
||||||
|
$xactions = array();
|
||||||
|
$xactions[] = $preferences->newTransaction($key, $value);
|
||||||
|
|
||||||
|
$editor->applyTransactions($preferences, $xactions);
|
||||||
|
|
||||||
return id(new AphrontAjaxResponse())->setContent(array());
|
return id(new AphrontAjaxResponse())->setContent(array());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue