mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
REFACTOR: Improve the readability of code (#7076)
This commit is contained in:
@@ -106,9 +106,15 @@ export default Ember.Controller.extend(
|
|||||||
|
|
||||||
@computed("showAllAuthTokens", "model.user_auth_tokens")
|
@computed("showAllAuthTokens", "model.user_auth_tokens")
|
||||||
authTokens(showAllAuthTokens, tokens) {
|
authTokens(showAllAuthTokens, tokens) {
|
||||||
tokens.sort((a, b) =>
|
tokens.sort((a, b) => {
|
||||||
a.is_active ? -1 : b.is_active ? 1 : b.seen_at.localeCompare(a.seen_at)
|
if (a.is_active) {
|
||||||
);
|
return -1;
|
||||||
|
} else if (b.is_active) {
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
return b.seen_at.localeCompare(a.seen_at);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
return showAllAuthTokens
|
return showAllAuthTokens
|
||||||
? tokens
|
? tokens
|
||||||
|
|||||||
@@ -299,6 +299,14 @@ QUnit.test("visit my preferences", async assert => {
|
|||||||
QUnit.test("recently connected devices", async assert => {
|
QUnit.test("recently connected devices", async assert => {
|
||||||
await visit("/u/eviltrout/preferences");
|
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(
|
assert.equal(
|
||||||
find(".pref-auth-tokens > a:first")
|
find(".pref-auth-tokens > a:first")
|
||||||
.text()
|
.text()
|
||||||
|
|||||||
Reference in New Issue
Block a user