mirror of
https://github.com/zulip/zulip.git
synced 2025-11-13 18:36:36 +00:00
Send messages using SockJS on staging
(imported from commit 812d20b1eab76eeb0d8fb92029fdb38d5faa9cce)
This commit is contained in:
@@ -315,34 +315,13 @@ function compose_error(error_text, bad_input) {
|
|||||||
|
|
||||||
var send_options;
|
var send_options;
|
||||||
|
|
||||||
function send_message() {
|
function send_message_ajax(request, success) {
|
||||||
var request = create_message_object();
|
|
||||||
exports.snapshot_message(request);
|
|
||||||
|
|
||||||
if (request.type === "private") {
|
|
||||||
request.to = JSON.stringify(request.to);
|
|
||||||
} else {
|
|
||||||
request.to = JSON.stringify([request.to]);
|
|
||||||
}
|
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
dataType: 'json', // This seems to be ignored. We still get back an xhr.
|
dataType: 'json', // This seems to be ignored. We still get back an xhr.
|
||||||
url: '/json/send_message',
|
url: '/json/send_message',
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
data: request,
|
data: request,
|
||||||
success: function (resp, statusText, xhr) {
|
success: success,
|
||||||
$("#new_message_content").val('').focus();
|
|
||||||
autosize_textarea();
|
|
||||||
$("#send-status").hide(0);
|
|
||||||
if (request.type === "private") {
|
|
||||||
onboarding.mark_checklist_step("sent_private_message");
|
|
||||||
} else {
|
|
||||||
onboarding.mark_checklist_step("sent_stream_message");
|
|
||||||
}
|
|
||||||
clear_message_snapshot();
|
|
||||||
$("#compose-send-button").removeAttr('disabled');
|
|
||||||
$("#sending-indicator").hide();
|
|
||||||
},
|
|
||||||
error: function (xhr, error_type) {
|
error: function (xhr, error_type) {
|
||||||
if (error_type !== 'timeout' && reload.is_pending()) {
|
if (error_type !== 'timeout' && reload.is_pending()) {
|
||||||
// The error might be due to the server changing
|
// The error might be due to the server changing
|
||||||
@@ -353,7 +332,48 @@ function send_message() {
|
|||||||
compose_error(response, $('#new_message_content'));
|
compose_error(response, $('#new_message_content'));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
var socket = new Socket("/sockjs");
|
||||||
|
function send_message_socket(request, success) {
|
||||||
|
socket.send(request, success, function (type, resp) {
|
||||||
|
var err_msg = "Error sending message";
|
||||||
|
if (type === 'response') {
|
||||||
|
err_msg += ": " + resp.msg;
|
||||||
|
}
|
||||||
|
compose_error(err_msg, $('#new_message_content'));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function send_message() {
|
||||||
|
var request = create_message_object();
|
||||||
|
exports.snapshot_message(request);
|
||||||
|
|
||||||
|
if (request.type === "private") {
|
||||||
|
request.to = JSON.stringify(request.to);
|
||||||
|
} else {
|
||||||
|
request.to = JSON.stringify([request.to]);
|
||||||
|
}
|
||||||
|
|
||||||
|
function success() {
|
||||||
|
$("#new_message_content").val('').focus();
|
||||||
|
autosize_textarea();
|
||||||
|
$("#send-status").hide(0);
|
||||||
|
if (request.type === "private") {
|
||||||
|
onboarding.mark_checklist_step("sent_private_message");
|
||||||
|
} else {
|
||||||
|
onboarding.mark_checklist_step("sent_stream_message");
|
||||||
|
}
|
||||||
|
clear_message_snapshot();
|
||||||
|
$("#compose-send-button").removeAttr('disabled');
|
||||||
|
$("#sending-indicator").hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (feature_flags.use_socket) {
|
||||||
|
send_message_socket(request, success);
|
||||||
|
} else {
|
||||||
|
send_message_ajax(request, success);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.finish = function () {
|
exports.finish = function () {
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ exports.left_side_userlist = page_params.staging ||
|
|||||||
|
|
||||||
// Still very beta:
|
// Still very beta:
|
||||||
exports.fade_users_when_composing = page_params.staging || is_customer4;
|
exports.fade_users_when_composing = page_params.staging || is_customer4;
|
||||||
|
exports.use_socket = page_params.staging;
|
||||||
|
|
||||||
|
|
||||||
// Still burning in...
|
// Still burning in...
|
||||||
|
|||||||
Reference in New Issue
Block a user