mirror of https://github.com/zulip/zulip.git
echo: Update message controls dynamically for failed messages.
Previously, the message controls for failed messages was present for all messages, regardless of their status, and was being rendered unconditionally; only being hidden for successfully sent messages. This commit adds dynamic rendering for the failed message controls, only rendering them via the handlebars template when a message is confirmed to be failed. Fixes #31132.
This commit is contained in:
parent
e67ed2e704
commit
5583ddd3bf
|
@ -2,6 +2,9 @@ import $ from "jquery";
|
||||||
import assert from "minimalistic-assert";
|
import assert from "minimalistic-assert";
|
||||||
import {z} from "zod";
|
import {z} from "zod";
|
||||||
|
|
||||||
|
import render_message_controls from "../templates/message_controls.hbs";
|
||||||
|
import render_message_controls_failed_msg from "../templates/message_controls_failed_msg.hbs";
|
||||||
|
|
||||||
import * as alert_words from "./alert_words";
|
import * as alert_words from "./alert_words";
|
||||||
import * as blueslip from "./blueslip";
|
import * as blueslip from "./blueslip";
|
||||||
import * as compose_notifications from "./compose_notifications";
|
import * as compose_notifications from "./compose_notifications";
|
||||||
|
@ -118,20 +121,22 @@ function hide_retry_spinner($row: JQuery): boolean {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_message_failed(message_id: number, failed_msg: string): void {
|
function show_message_failed(message_id: number, _failed_msg: string): void {
|
||||||
// Failed to send message, so display inline retry/cancel
|
// Failed to send message, so display inline retry/cancel
|
||||||
message_live_update.update_message_in_all_views(message_id, ($row) => {
|
message_live_update.update_message_in_all_views(message_id, ($row) => {
|
||||||
$row.find(".slow-send-spinner").addClass("hidden");
|
$row.find(".slow-send-spinner").addClass("hidden");
|
||||||
const $failed_div = $row.find(".message_failed");
|
const $message_controls = $row.find(".message_controls");
|
||||||
$failed_div.toggleClass("hide", false);
|
$message_controls.html(render_message_controls_failed_msg());
|
||||||
$failed_div.find(".failed_text").attr("title", failed_msg);
|
|
||||||
});
|
});
|
||||||
|
// TODO: Show the `_failed_msg` in the UI, describing the reason for the failure.
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_failed_message_success(message_id: number): void {
|
function show_failed_message_success(message_id: number): void {
|
||||||
// Previously failed message succeeded
|
// Previously failed message succeeded
|
||||||
|
const msg = message_store.get(message_id);
|
||||||
message_live_update.update_message_in_all_views(message_id, ($row) => {
|
message_live_update.update_message_in_all_views(message_id, ($row) => {
|
||||||
$row.find(".message_failed").toggleClass("hide", true);
|
const $message_controls = $row.find(".message_controls");
|
||||||
|
$message_controls.html(render_message_controls({msg}));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -77,8 +77,7 @@
|
||||||
padding on either side of the message box. */
|
padding on either side of the message box. */
|
||||||
padding: 0 5px 0 3px;
|
padding: 0 5px 0 3px;
|
||||||
|
|
||||||
&:hover .message_controls,
|
&:hover .message_controls {
|
||||||
&:hover .message_failed {
|
|
||||||
.empty-star:hover {
|
.empty-star:hover {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
@ -142,8 +141,8 @@
|
||||||
|
|
||||||
@media (width < $sm_min), ((width >= $md_min) and (width < $mc_min)) {
|
@media (width < $sm_min), ((width >= $md_min) and (width < $mc_min)) {
|
||||||
/* This is intended to target the first message_controls child
|
/* This is intended to target the first message_controls child
|
||||||
when there are 3 displayed. 4 = 3 + hidden message_failed element. */
|
when there are 3 displayed. */
|
||||||
.message_control_button:nth-last-child(4) {
|
.message_control_button:nth-last-child(3) {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -504,34 +503,15 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.message_failed {
|
|
||||||
display: inline-flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
cursor: pointer;
|
|
||||||
position: relative;
|
|
||||||
vertical-align: middle;
|
|
||||||
padding-left: 2px;
|
|
||||||
|
|
||||||
&.hide {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.rotating {
|
|
||||||
display: inline-block;
|
|
||||||
outline: none;
|
|
||||||
|
|
||||||
animation: rotate 1s infinite linear;
|
|
||||||
}
|
|
||||||
|
|
||||||
.failed_message_action {
|
.failed_message_action {
|
||||||
opacity: 1 !important;
|
|
||||||
color: var(--color-failed-message-send-icon);
|
color: var(--color-failed-message-send-icon);
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
padding: 1px;
|
padding: 1px;
|
||||||
}
|
opacity: 1;
|
||||||
|
visibility: visible;
|
||||||
|
|
||||||
.message_control_button {
|
.rotating {
|
||||||
visibility: inherit;
|
animation: rotate 1s infinite linear;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,15 @@
|
||||||
<span data-tooltip-template-id="slow-send-spinner-tooltip-template" class="fa fa-circle-o-notch slow-send-spinner{{#unless msg/show_slow_send_spinner }} hidden{{/unless}}"></span>
|
<span data-tooltip-template-id="slow-send-spinner-tooltip-template" class="fa fa-circle-o-notch slow-send-spinner{{#unless msg/show_slow_send_spinner }} hidden{{/unless}}"></span>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
|
<div class="message_controls no-select">
|
||||||
|
{{#if msg/locally_echoed}}
|
||||||
|
{{#if msg/failed_request}}
|
||||||
|
{{> message_controls_failed_msg}}
|
||||||
|
{{/if}}
|
||||||
|
{{else}}
|
||||||
{{> message_controls}}
|
{{> message_controls}}
|
||||||
|
{{/if}}
|
||||||
|
</div>
|
||||||
|
|
||||||
{{#unless status_message}}
|
{{#unless status_message}}
|
||||||
{{#unless is_hidden}}
|
{{#unless is_hidden}}
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
<div class="message_controls no-select">
|
|
||||||
{{#if msg/sent_by_me}}
|
{{#if msg/sent_by_me}}
|
||||||
<div class="edit_content message_control_button"></div>
|
<div class="edit_content message_control_button"></div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
@ -11,26 +10,10 @@
|
||||||
</div>
|
</div>
|
||||||
{{/unless}}
|
{{/unless}}
|
||||||
|
|
||||||
{{#unless msg/locally_echoed}}
|
|
||||||
<div class="actions_hover message_control_button" data-tooltip-template-id="message-actions-tooltip-template" >
|
<div class="actions_hover message_control_button" data-tooltip-template-id="message-actions-tooltip-template" >
|
||||||
<i class="message-controls-icon message-actions-menu-button zulip-icon zulip-icon-more-vertical-spread" role="button" aria-haspopup="true" tabindex="0" aria-label="{{t 'Message actions' }}"></i>
|
<i class="message-controls-icon message-actions-menu-button zulip-icon zulip-icon-more-vertical-spread" role="button" aria-haspopup="true" tabindex="0" aria-label="{{t 'Message actions' }}"></i>
|
||||||
</div>
|
</div>
|
||||||
{{/unless}}
|
|
||||||
|
|
||||||
<div class="message_failed {{#unless msg.failed_request}}hide{{/unless}}">
|
|
||||||
<div class="message_control_button failed_message_action" data-tippy-content="{{t 'Retry' }}">
|
|
||||||
<i class="message-controls-icon fa fa-refresh refresh-failed-message" aria-label="{{t 'Retry' }}" role="button" tabindex="0"></i>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="message_control_button failed_message_action" data-tooltip-template-id="dismiss-failed-send-button-tooltip-template">
|
|
||||||
<i class="message-controls-icon fa fa-times-circle remove-failed-message" aria-label="{{t 'Dismiss' }}" role="button" tabindex="0"></i>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{{#unless msg/locally_echoed}}
|
|
||||||
<div class="star_container message_control_button {{#if msg/starred}}{{else}}empty-star{{/if}}" data-tooltip-template-id="{{#if msg/starred}}unstar{{else}}star{{/if}}-message-tooltip-template">
|
<div class="star_container message_control_button {{#if msg/starred}}{{else}}empty-star{{/if}}" data-tooltip-template-id="{{#if msg/starred}}unstar{{else}}star{{/if}}-message-tooltip-template">
|
||||||
<i role="button" tabindex="0" class="message-controls-icon star zulip-icon {{#if msg/starred}}zulip-icon-star-filled{{else}}zulip-icon-star{{/if}}"></i>
|
<i role="button" tabindex="0" class="message-controls-icon star zulip-icon {{#if msg/starred}}zulip-icon-star-filled{{else}}zulip-icon-star{{/if}}"></i>
|
||||||
</div>
|
</div>
|
||||||
{{/unless}}
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
<div class="message_control_button failed_message_action" data-tippy-content="{{t 'Retry' }}">
|
||||||
|
<i class="message-controls-icon fa fa-refresh refresh-failed-message" aria-label="{{t 'Retry' }}" role="button" tabindex="0"></i>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="message_control_button failed_message_action" data-tooltip-template-id="dismiss-failed-send-button-tooltip-template">
|
||||||
|
<i class="message-controls-icon fa fa-times-circle remove-failed-message" aria-label="{{t 'Dismiss' }}" role="button" tabindex="0"></i>
|
||||||
|
</div>
|
Loading…
Reference in New Issue