mirror of
https://github.com/discourse/discourse.git
synced 2025-03-20 20:30:23 +08:00
REFACTOR: Improve the readability of code (#7076)
This commit is contained in:
parent
fbedaea5ed
commit
59c66fd226
@ -106,9 +106,15 @@ export default Ember.Controller.extend(
|
||||
|
||||
@computed("showAllAuthTokens", "model.user_auth_tokens")
|
||||
authTokens(showAllAuthTokens, tokens) {
|
||||
tokens.sort((a, b) =>
|
||||
a.is_active ? -1 : b.is_active ? 1 : b.seen_at.localeCompare(a.seen_at)
|
||||
);
|
||||
tokens.sort((a, b) => {
|
||||
if (a.is_active) {
|
||||
return -1;
|
||||
} else if (b.is_active) {
|
||||
return 1;
|
||||
} else {
|
||||
return b.seen_at.localeCompare(a.seen_at);
|
||||
}
|
||||
});
|
||||
|
||||
return showAllAuthTokens
|
||||
? tokens
|
||||
|
@ -299,6 +299,14 @@ QUnit.test("visit my preferences", async assert => {
|
||||
QUnit.test("recently connected devices", async assert => {
|
||||
await visit("/u/eviltrout/preferences");
|
||||
|
||||
assert.equal(
|
||||
find(".auth-tokens > .auth-token:first .auth-token-device")
|
||||
.text()
|
||||
.trim(),
|
||||
"Linux Computer",
|
||||
"it should display active token first"
|
||||
);
|
||||
|
||||
assert.equal(
|
||||
find(".pref-auth-tokens > a:first")
|
||||
.text()
|
||||
|
Loading…
x
Reference in New Issue
Block a user