Skip to content

Commit

Permalink
Enhanced onSettingsChange event to get old setting values
Browse files Browse the repository at this point in the history
Including `name` and `description` attributes

Signed-off-by: Tortue Torche <tortuetorche@users.noreply.github.com>
  • Loading branch information
tortuetorche committed Apr 9, 2020
1 parent 5a0e5bb commit b0aa51c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
10 changes: 9 additions & 1 deletion lib/Service/CirclesService.php
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,14 @@ public function settingsCircle($circleUniqueId, $settings) {
$circle = $this->circlesRequest->getCircle($circleUniqueId, $this->userId);
$this->hasToBeOwner($circle->getHigherViewer());

$oldSettings = array_merge(
$circle->getSettings(),
[
'circle_name' => $circle->getName(),
'circle_desc' => $circle->getDescription(),
]
);

if (!$this->viewerIsAdmin()) {
$settings['members_limit'] = $circle->getSetting('members_limit');
}
Expand All @@ -329,7 +337,7 @@ public function settingsCircle($circleUniqueId, $settings) {

$this->circlesRequest->updateCircle($circle, $this->userId);

$this->eventsService->onSettingsChange($circle);
$this->eventsService->onSettingsChange($circle, $oldSettings);
} catch (\Exception $e) {
throw $e;
}
Expand Down
5 changes: 3 additions & 2 deletions lib/Service/EventsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -747,9 +747,10 @@ public function onLinkRemove(Circle $circle, FederatedLink $link) {
* Called when the circle's settings are changed
*
* @param Circle $circle
* @param array $oldSettings
*/
public function onSettingsChange(Circle $circle) {
$this->dispatch('\OCA\Circles::onSettingsChange', ['circle' => $circle]);
public function onSettingsChange(Circle $circle, array $oldSettings = []) {
$this->dispatch('\OCA\Circles::onSettingsChange', ['circle' => $circle, 'oldSettings' => $oldSettings]);
}


Expand Down

0 comments on commit b0aa51c

Please sign in to comment.