Commit 59e50c27 authored by Guy Thouret's avatar Guy Thouret
Browse files

(feat) Split state change view to separate views for increasing and decreasing user state - #589

parent 42e5591b
Loading
Loading
Loading
Loading
+14 −13
Original line number Original line Diff line number Diff line
@@ -26,11 +26,9 @@ class UpdateUserState


    public function update(): void
    public function update(): void
    {
    {
        if ($this->user->getUserState() !== $this->userState->getState()) {
        $this->updateUserEntity();
        $this->updateUserEntity();
        $this->sendStateChangeNotification();
        $this->sendStateChangeNotification();
    }
    }
    }


    private function updateUserEntity(): void
    private function updateUserEntity(): void
    {
    {
@@ -41,14 +39,17 @@ class UpdateUserState


    private function sendStateChangeNotification(): void
    private function sendStateChangeNotification(): void
    {
    {
        if ($this->userState->getStateChange() !== 0) {
            $notificationView = ($this->userState->getStateChange() > 0) ?
                'reward_state_increase' : 'reward_state_decrease';
            Dispatcher::trigger('notification', 'reward', [
            Dispatcher::trigger('notification', 'reward', [
                'to' => [
                'to' => [
                    $this->userState->getUserGuid()
                    $this->userState->getUserGuid()
                ],
                ],
                'from' => Notification::SYSTEM_ENTITY,
                'from' => Notification::SYSTEM_ENTITY,
            'notification_view' => 'rewards_state_change',
                'notification_view' => $notificationView,
                'params' => $this->userState->export()
                'params' => $this->userState->export()
            ]);
            ]);
        }
        }

    }
}
}
+1 −1
Original line number Original line Diff line number Diff line
@@ -23,7 +23,7 @@ use Minds\Traits\MagicAttributes;
 * @method UserState setActivityPercentage(float $activityPercentage)
 * @method UserState setActivityPercentage(float $activityPercentage)
 * @method float getActivityPercentage()
 * @method float getActivityPercentage()
 * @method UserState setStateChange(int $stateChange)
 * @method UserState setStateChange(int $stateChange)
 * @method int getUserState()
 * @method int getStateChange()
 */
 */
class UserState
class UserState
{
{