From 761b76539dee873ed3db0ee09c1df1cd0c87be7c Mon Sep 17 00:00:00 2001 From: Toby Zerner Date: Mon, 1 Jun 2015 12:26:11 +0930 Subject: [PATCH] Use pre-loaded state if applicable. closes flarum/core#89 --- framework/core/src/Core/Models/Discussion.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/framework/core/src/Core/Models/Discussion.php b/framework/core/src/Core/Models/Discussion.php index 1dd4f0523..eb3c72116 100755 --- a/framework/core/src/Core/Models/Discussion.php +++ b/framework/core/src/Core/Models/Discussion.php @@ -295,6 +295,11 @@ class Discussion extends Model */ public function stateFor(User $user) { + $loadedState = array_get($this->relations, 'state'); + if ($loadedState && $loadedState->user_id === $user->id) { + return $loadedState; + } + $state = $this->state($user)->first(); if (! $state) {