Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onboarding: Add one-time go-to-conversation tooltip. #32169

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 33 additions & 2 deletions web/src/compose_recipient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
import $ from "jquery";
import _, {isNumber} from "lodash";
import assert from "minimalistic-assert";
import type * as tippy from "tippy.js";
import type {Instance} from "tippy.js";
import tippy from "tippy.js";

import render_inline_decorated_stream_name from "../templates/inline_decorated_stream_name.hbs";

Expand All @@ -19,6 +20,7 @@ import * as dropdown_widget from "./dropdown_widget.ts";
import type {Option} from "./dropdown_widget.ts";
import {$t} from "./i18n.ts";
import * as narrow_state from "./narrow_state.ts";
import {ONE_TIME_NOTICES_TO_DISPLAY} from "./onboarding_steps.ts";
import {realm} from "./state_data.ts";
import * as stream_data from "./stream_data.ts";
import * as sub_store from "./sub_store.ts";
Expand Down Expand Up @@ -73,6 +75,7 @@ export let update_narrow_to_recipient_visibility = (): void => {
compose_state.has_full_recipient()
) {
$(".conversation-arrow").toggleClass("narrow_to_compose_recipients", true);
show_tippy_tooltip();
return;
}
} else if (message_type === "private") {
Expand All @@ -83,6 +86,7 @@ export let update_narrow_to_recipient_visibility = (): void => {
compose_state.has_full_recipient()
) {
$(".conversation-arrow").toggleClass("narrow_to_compose_recipients", true);
show_tippy_tooltip();
return;
}
}
Expand All @@ -95,6 +99,33 @@ export function rewire_update_narrow_to_recipient_visibility(
update_narrow_to_recipient_visibility = value;
}

function show_tippy_tooltip(): void {
const arrow_element = document.querySelector(".conversation-arrow");
if (!arrow_element) {
return;
}

if (ONE_TIME_NOTICES_TO_DISPLAY.has("conversation_tooltip")) {
return;
}
const instance = tippy(arrow_element, {
content: "Go to conversation",
trigger: "manual",
placement: "top",
});

instance.show();
ONE_TIME_NOTICES_TO_DISPLAY.add("conversation_tooltip");

arrow_element.addEventListener(
"click",
() => {
instance.hide();
},
{once: true},
);
}

function update_fade(): void {
if (!compose_state.composing()) {
return;
Expand Down Expand Up @@ -252,7 +283,7 @@ export function possibly_update_stream_name_in_compose(stream_id: number): void
}
}

function item_click_callback(event: JQuery.ClickEvent, dropdown: tippy.Instance): void {
function item_click_callback(event: JQuery.ClickEvent, dropdown: Instance): void {
const recipient_id_str = $(event.currentTarget).attr("data-unique-id");
assert(recipient_id_str !== undefined);
let recipient_id: string | number = recipient_id_str;
Expand Down
Loading