FIX: profile page is not loading (#19351)

When looking as an anonymous user at a profile page of another user (who has user status with an ending date) the profile page wasn't loading.

Reported in https://meta.discourse.org/t/profile-page-not-loading/247928.
This commit is contained in:
Andrei Prigorshnev 2022-12-07 16:09:50 +04:00 committed by GitHub
parent d3649873a2
commit f2d0832618
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 5 deletions

View File

@ -12,10 +12,10 @@ export default class UserStatusMessage extends Component {
return null;
}
return until(
this.status.ends_at,
this.currentUser.user_option.timezone,
this.currentUser.locale
);
const timezone = this.currentUser
? this.currentUser.timezone
: moment.tz.guess();
return until(this.status.ends_at, timezone, this.currentUser?.locale);
}
}

View File

@ -141,4 +141,17 @@ module("Integration | Component | user-status-message", function (hooks) {
document.querySelector("[data-tippy-root] .user-status-message-tooltip")
);
});
test("doesn't blow up with an anonymous user", async function (assert) {
this.owner.unregister("service:current-user");
this.set("status", {
emoji: "tooth",
description: "off to dentist",
ends_at: "2100-02-02T12:30:00.000Z",
});
await render(hbs`<UserStatusMessage @status={{this.status}} />`);
assert.dom(".user-status-message").exists();
});
});