Skip to content

Commit

Permalink
Merge pull request #397 from tortuetorche/patch-better-onSettingsChan…
Browse files Browse the repository at this point in the history
…ge-event

Better 'onSettingsChange' event handling to get old setting values
  • Loading branch information
ArtificialOwl authored Apr 9, 2020
2 parents 660a931 + b0aa51c commit b232758
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 b232758

Please sign in to comment.