tooltip: Remove "last active" time from deactivated user tooltip.

Removes "last active" time from deactivated user tooltip and instead adds
"This user has been deactivated." Also, in the deactivated bot tooltip,
"This bot has been deactivated." has been added.

Fixes #32136.
This commit is contained in:
opmkumar 2024-11-13 23:12:04 +05:30 committed by Tim Abbott
parent e3118d8fc9
commit c4ad9d8e09
3 changed files with 43 additions and 3 deletions

View File

@ -240,6 +240,7 @@ export function get_title_data(
second_line: string | undefined;
third_line: string;
show_you?: boolean;
is_deactivated?: boolean;
} {
if (is_group) {
// For groups, just return a string with recipient names.
@ -253,6 +254,7 @@ export function get_title_data(
// Since it's not a group, user_ids_string is a single user ID.
const user_id = Number.parseInt(user_ids_string, 10);
const person = people.get_by_user_id(user_id);
const is_deactivated = !people.is_person_active(user_id);
if (person.is_bot) {
const bot_owner = people.get_bot_owner_user(person);
@ -266,7 +268,10 @@ export function get_title_data(
return {
first_line: person.full_name,
second_line: bot_owner_name,
third_line: "",
third_line: is_deactivated
? $t({defaultMessage: "This bot has been deactivated."})
: "",
is_deactivated,
};
}
@ -283,6 +288,16 @@ export function get_title_data(
const last_seen = user_last_seen_time_status(user_id);
const is_my_user = people.is_my_user_id(user_id);
if (is_deactivated) {
return {
first_line: person.full_name,
second_line: $t({defaultMessage: "This user has been deactivated."}),
third_line: "",
show_you: is_my_user,
is_deactivated,
};
}
// Users has a status.
if (user_status.get_status_text(user_id)) {
return {

View File

@ -6,9 +6,9 @@
{{/if}}
</div>
{{#if second_line}}
<div class="tooltip-inner-content">{{second_line}}</div>
<div class="tooltip-inner-content {{#if is_deactivated}}italic{{/if}}" >{{second_line}}</div>
{{/if}}
{{#if third_line}}
<div class="tooltip-inner-content">{{third_line}}</div>
<div class="tooltip-inner-content {{#if is_deactivated}}italic{{/if}}">{{third_line}}</div>
{{/if}}
</div>

View File

@ -192,6 +192,7 @@ test("title_data", ({override}) => {
first_line: "Blue Herring Bot",
second_line: "translated: Owner: Human Myself",
third_line: "",
is_deactivated: false,
};
assert.deepEqual(
buddy_data.get_title_data(bot_with_owner.user_id, is_group),
@ -228,6 +229,30 @@ test("title_data", ({override}) => {
show_you: false,
};
assert.deepEqual(buddy_data.get_title_data(old_user.user_id, is_group), expected_data);
// Deactivated users.
people.deactivate(selma);
expected_data = {
first_line: "Human Selma",
second_line: "translated: This user has been deactivated.",
third_line: "",
show_you: false,
is_deactivated: true,
};
assert.deepEqual(buddy_data.get_title_data(selma.user_id, is_group), expected_data);
// Deactivated bots.
people.deactivate(bot_with_owner);
expected_group_data = {
first_line: "Blue Herring Bot",
second_line: "translated: Owner: Human Myself",
third_line: "translated: This bot has been deactivated.",
is_deactivated: true,
};
assert.deepEqual(
buddy_data.get_title_data(bot_with_owner.user_id, is_group),
expected_group_data,
);
});
test("filters deactivated users", () => {