Skip to content

Commit 9d8bf94

Browse files
committed
alternative performance fix?
1 parent 95affe3 commit 9d8bf94

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

Zero-K.info/Controllers/LobbyController.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,6 @@ public async Task<ActionResult> ChatMessages(ChatModel model)
183183
model = model ?? new ChatModel();
184184

185185
var db = new ZkDataContext();
186-
var ret = db.LobbyChatHistories.AsQueryable();
187186
bool isMuted = Punishment.GetActivePunishment(Global.AccountID, Request.UserHostAddress, 0, null, x => x.BanMute) != null;
188187
if (!string.IsNullOrEmpty(model.Channel))
189188
{
@@ -203,9 +202,9 @@ await Global.Server.GhostSay(new Say()
203202
User = Global.Account.Name,
204203
});
205204
}
206-
ret = ret
207-
.Where(x => x.Target == model.Channel && x.SayPlace == SayPlace.Channel)
208-
.OrderByDescending(x => x.LobbyChatHistoryID).Take(200);
205+
model.Data = db.LobbyChatHistories
206+
.Where(x => x.Target == model.Channel)
207+
.OrderByDescending(x => x.LobbyChatHistoryID).Take(200).ToList().Where(x => x.SayPlace == SayPlace.Channel).AsQueryable();
209208
}
210209
else if (!string.IsNullOrEmpty(model.User))
211210
{
@@ -224,7 +223,7 @@ await Global.Server.GhostSay(new Say()
224223
});
225224
}
226225
//Users can abuse rename to gain access to other users PMs, it's a feature
227-
ret = ret
226+
model.Data = db.LobbyChatHistories
228227
.Where(x => (x.User == model.User && x.Target == Global.Account.Name || x.User == Global.Account.Name && x.Target == model.User) && x.SayPlace == SayPlace.User)
229228
.OrderByDescending(x => x.LobbyChatHistoryID);
230229
}
@@ -233,7 +232,6 @@ await Global.Server.GhostSay(new Say()
233232
return PartialView("LobbyChatMessages", model);
234233
}
235234

236-
model.Data = ret;
237235
model.Message = "";
238236

239237
return PartialView("LobbyChatMessages", model);

0 commit comments

Comments
 (0)