Commit c8f15cb5 authored by Sébastien Blin's avatar Sébastien Blin
Browse files

chatview: prepare UI to see a conversation with a disabled account



The GNOME client should be able to see a conversation even if the
account is disabled. This patch prepares the UI to remove buttons
and the message bar if the account is disabled.

Change-Id: Ic71d6c2b61afb77a7ac9acdeae7de527efaf265b
Reviewed-by: Andreas Traczyk's avatarAndreas Traczyk <andreas.traczyk@savoirfairelinux.com>
parent d0b9c1cb
......@@ -517,7 +517,9 @@ update_chatview_frame(ChatView* self)
// get temporary status
bool temp = contactInfo.profileInfo.type == lrc::api::profile::Type::TEMPORARY || contactInfo.profileInfo.type == lrc::api::profile::Type::PENDING;
webkit_chat_update_chatview_frame(WEBKIT_CHAT_CONTAINER(priv->webkit_chat_container), contactInfo.isBanned, temp, alias.c_str(), bestName.c_str());
webkit_chat_update_chatview_frame(WEBKIT_CHAT_CONTAINER(priv->webkit_chat_container),
(*priv->accountInfo_)->enabled,
contactInfo.isBanned, temp, alias.c_str(), bestName.c_str());
webkit_chat_container_set_invitation(WEBKIT_CHAT_CONTAINER(priv->webkit_chat_container),
(contactInfo.profileInfo.type == lrc::api::profile::Type::PENDING),
......
......@@ -612,21 +612,6 @@ webkit_chat_disable_send_interaction(WebKitChatContainer *view, bool isDisabled)
);
}
void
webkit_chat_hide_message_bar(WebKitChatContainer *view, bool isHidden)
{
auto priv = WEBKIT_CHAT_CONTAINER_GET_PRIVATE(view);
gchar* function_call = g_strdup_printf("hideMessageBar(%s);", isHidden ? "true" : "false");
webkit_web_view_run_javascript(
WEBKIT_WEB_VIEW(priv->webview_chat),
function_call,
NULL,
NULL,
NULL
);
}
void
webkit_chat_container_clear_sender_images(WebKitChatContainer *view)
{
......@@ -794,11 +779,12 @@ webkit_chat_set_header_visible(WebKitChatContainer *view, bool isVisible)
}
void
webkit_chat_update_chatview_frame(WebKitChatContainer *view, bool isBanned, bool isTemporary, const gchar* alias, const gchar* bestId)
webkit_chat_update_chatview_frame(WebKitChatContainer *view, bool accountEnabled, bool isBanned, bool isTemporary, const gchar* alias, const gchar* bestId)
{
WebKitChatContainerPrivate *priv = WEBKIT_CHAT_CONTAINER_GET_PRIVATE(view);
gchar* function_call = g_strdup_printf("update_chatview_frame(%s, %s, \"%s\", \"%s\")",
gchar* function_call = g_strdup_printf("update_chatview_frame(%s, %s, %s, \"%s\", \"%s\")",
accountEnabled ? "true" : "false",
isBanned ? "true" : "false", isTemporary ? "true" : "false", alias, bestId);
webkit_web_view_run_javascript(
......
......@@ -54,9 +54,8 @@ void webkit_chat_container_set_sender_image (WebKitChatContainer *view
gboolean webkit_chat_container_is_ready (WebKitChatContainer *view);
void webkit_chat_container_set_display_links (WebKitChatContainer *view, bool display);
void webkit_chat_disable_send_interaction (WebKitChatContainer *view, bool isDisabled);
void webkit_chat_hide_message_bar (WebKitChatContainer *view, bool isHidden);
void webkit_chat_container_set_invitation (WebKitChatContainer *view, bool show, const std::string& contactUri);
void webkit_chat_set_header_visible (WebKitChatContainer *view, bool isVisible);
void webkit_chat_update_chatview_frame (WebKitChatContainer *view, bool isBanned, bool isInvited, const gchar* alias, const gchar* bestId);
void webkit_chat_update_chatview_frame (WebKitChatContainer *view, bool accountEnabled, bool isBanned, bool isInvited, const gchar* alias, const gchar* bestId);
G_END_DECLS
......@@ -122,6 +122,7 @@ const invitation = document.getElementById("invitation")
const navbar = document.getElementById("navbar")
const invitationText = document.getElementById("text")
var messages = document.getElementById("messages")
const callButtons = document.getElementById("callButtons")
/* States: allows us to avoid re-doing something if it isn't meaningful */
var displayLinksEnabled = false
......@@ -129,6 +130,7 @@ var hoverBackButtonAllowed = true
var hasInvitation = false
var isTemporary = false
var isBanned = false
var isAccountEnabled = true
var isInitialLoading = false
var imagesLoadingCounter = 0
......@@ -192,13 +194,14 @@ function back_to_bottom() {
* handles most of the required work (except the showing/hiding the invitation,
* which is handled by showInvitation()).
*
* @param accountEnabled whether account is enabled or not
* @param banned whether contact is banned or not
* @param temporary whether contact is temporary or not
* @param alias
* @param bestId
*/
/* exported update_chatview_frame */
function update_chatview_frame(banned, temporary, alias, bestid) {
function update_chatview_frame(accountEnabled, banned, temporary, alias, bestid) {
/* This function updates lots of things in the navbar and we don't want to
trigger that many DOM updates. Instead set display to none so DOM is
updated only once. */
......@@ -215,6 +218,12 @@ function update_chatview_frame(banned, temporary, alias, bestid) {
idField.classList.add("oneEntry")
}
if (isAccountEnabled !== accountEnabled) {
isAccountEnabled = accountEnabled
hideMessageBar(!accountEnabled)
hideControls(accountEnabled)
}
if (isBanned !== banned) {
isBanned = banned
hideMessageBar(banned)
......@@ -679,6 +688,18 @@ function humanFileSize(bytes) {
return bytes.toFixed(1)+" "+units[u]
}
/**
* Hide or show add to conversations/calls whether the account is enabled
* @param accountEnabled true if account is enabled
*/
function hideControls(accountEnabled) {
if (!accountEnabled) {
callButtons.setAttribute("style", "display: none")
} else {
callButtons.setAttribute("style", "display: block")
}
}
/**
* Change the value of the progress bar.
*
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment