mirror of https://github.com/PiyushXCoder/lupt.git
old browser fix
This commit is contained in:
parent
6f461ab4e2
commit
6623fda897
|
|
@ -52,7 +52,7 @@ pub struct SendImage {
|
||||||
pub src: String
|
pub src: String
|
||||||
}
|
}
|
||||||
|
|
||||||
// Request to send text t
|
// Request to send status
|
||||||
#[derive(Clone, Message)]
|
#[derive(Clone, Message)]
|
||||||
#[rtype(result = "()")]
|
#[rtype(result = "()")]
|
||||||
pub struct SendStatus {
|
pub struct SendStatus {
|
||||||
|
|
@ -61,7 +61,16 @@ pub struct SendStatus {
|
||||||
pub status: String
|
pub status: String
|
||||||
}
|
}
|
||||||
|
|
||||||
// Request to send text t
|
// Request to delete messages
|
||||||
|
#[derive(Clone, Message)]
|
||||||
|
#[rtype(result = "()")]
|
||||||
|
pub struct DeleteMsg {
|
||||||
|
pub kaksh_kunjika: String,
|
||||||
|
pub kunjika: String,
|
||||||
|
pub msg_id: Vec<u128>
|
||||||
|
}
|
||||||
|
|
||||||
|
// Request to send list of users
|
||||||
#[derive(Clone, Message)]
|
#[derive(Clone, Message)]
|
||||||
#[rtype(result = "String")]
|
#[rtype(result = "String")]
|
||||||
pub struct List {
|
pub struct List {
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ pub struct WsText {
|
||||||
pub msg_id: u128
|
pub msg_id: u128
|
||||||
}
|
}
|
||||||
|
|
||||||
// Request to send transfer text
|
// Request to send transfer Image
|
||||||
#[derive(Clone, Message)]
|
#[derive(Clone, Message)]
|
||||||
#[rtype(result = "()")]
|
#[rtype(result = "()")]
|
||||||
pub struct WsImage {
|
pub struct WsImage {
|
||||||
|
|
@ -28,7 +28,7 @@ pub struct WsImage {
|
||||||
pub msg_id: u128
|
pub msg_id: u128
|
||||||
}
|
}
|
||||||
|
|
||||||
// Request to send transfer text
|
// Request to send transfer status
|
||||||
#[derive(Clone, Message)]
|
#[derive(Clone, Message)]
|
||||||
#[rtype(result = "()")]
|
#[rtype(result = "()")]
|
||||||
pub struct WsStatus {
|
pub struct WsStatus {
|
||||||
|
|
@ -36,6 +36,14 @@ pub struct WsStatus {
|
||||||
pub sender_kunjika: String
|
pub sender_kunjika: String
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Request to delete messages
|
||||||
|
#[derive(Clone, Message)]
|
||||||
|
#[rtype(result = "()")]
|
||||||
|
pub struct WsDeleteMsg {
|
||||||
|
pub msg_id: Vec<u128>,
|
||||||
|
pub sender_kunjika: String
|
||||||
|
}
|
||||||
|
|
||||||
// Request to send transfer text
|
// Request to send transfer text
|
||||||
#[derive(Clone, Message)]
|
#[derive(Clone, Message)]
|
||||||
#[rtype(result = "()")]
|
#[rtype(result = "()")]
|
||||||
|
|
|
||||||
|
|
@ -57,4 +57,21 @@ impl Handler<ms::pind::SendStatus> for ChatPinnd {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// send delete messages for everyone
|
||||||
|
impl Handler<ms::pind::DeleteMsg> for ChatPinnd {
|
||||||
|
type Result = ();
|
||||||
|
|
||||||
|
fn handle(&mut self, msg: ms::pind::DeleteMsg, _: &mut Self::Context) -> Self::Result {
|
||||||
|
if let Some(kaksh) = self.kaksh.get_mut(&msg.kaksh_kunjika) {
|
||||||
|
kaksh.loog.iter().for_each(|c| {
|
||||||
|
c.addr.do_send(ms::sansad::WsDeleteMsg {
|
||||||
|
sender_kunjika: msg.kunjika.to_owned(),
|
||||||
|
msg_id: msg.msg_id.clone()
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -16,7 +16,7 @@ impl Handler<ms::sansad::WsText> for WsSansad {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// send text message
|
/// send image message
|
||||||
impl Handler<ms::sansad::WsImage> for WsSansad {
|
impl Handler<ms::sansad::WsImage> for WsSansad {
|
||||||
type Result = ();
|
type Result = ();
|
||||||
fn handle(&mut self, msg: ms::sansad::WsImage, ctx: &mut Self::Context) -> Self::Result {
|
fn handle(&mut self, msg: ms::sansad::WsImage, ctx: &mut Self::Context) -> Self::Result {
|
||||||
|
|
@ -30,7 +30,6 @@ impl Handler<ms::sansad::WsImage> for WsSansad {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// send text status
|
/// send text status
|
||||||
impl Handler<ms::sansad::WsStatus> for WsSansad {
|
impl Handler<ms::sansad::WsStatus> for WsSansad {
|
||||||
type Result = ();
|
type Result = ();
|
||||||
|
|
@ -44,6 +43,19 @@ impl Handler<ms::sansad::WsStatus> for WsSansad {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// delete messages
|
||||||
|
impl Handler<ms::sansad::WsDeleteMsg> for WsSansad {
|
||||||
|
type Result = ();
|
||||||
|
fn handle(&mut self, msg: ms::sansad::WsDeleteMsg, ctx: &mut Self::Context) -> Self::Result {
|
||||||
|
let json = json!({
|
||||||
|
"cmd": "del",
|
||||||
|
"msg_id": msg.msg_id,
|
||||||
|
"kunjika": msg.sender_kunjika // Sender's kunjuka
|
||||||
|
});
|
||||||
|
ctx.text(json.to_string());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// List Vayakti
|
/// List Vayakti
|
||||||
impl Handler<ms::sansad::WsList> for WsSansad {
|
impl Handler<ms::sansad::WsList> for WsSansad {
|
||||||
type Result = ();
|
type Result = ();
|
||||||
|
|
|
||||||
|
|
@ -87,7 +87,7 @@ impl WsSansad {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// send text to vayakti in kaksh
|
/// send image to vayakti in kaksh
|
||||||
pub async fn send_image(&mut self, val: Value) {
|
pub async fn send_image(&mut self, val: Value) {
|
||||||
// check if vayakti exist
|
// check if vayakti exist
|
||||||
if let Isthiti::None = self.isthiti {
|
if let Isthiti::None = self.isthiti {
|
||||||
|
|
@ -126,4 +126,51 @@ impl WsSansad {
|
||||||
src
|
src
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// delete text to vayakti in kaksh
|
||||||
|
pub async fn delete_msg(&mut self, val: Value) {
|
||||||
|
// check if vayakti exist
|
||||||
|
if let Isthiti::None = self.isthiti {
|
||||||
|
self.send_err_response("Not in any Kaksh");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// check if connected to any kaksh
|
||||||
|
match self.isthiti {
|
||||||
|
Isthiti::Kaksh(_) => (),
|
||||||
|
_ => {
|
||||||
|
self.send_err_response("Kaksh not connected");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// image src
|
||||||
|
let mut msg_id = vec![];
|
||||||
|
|
||||||
|
let ids = match val.get("msg_id") {
|
||||||
|
Some(val) => val,
|
||||||
|
None => {
|
||||||
|
self.send_err_response("Invalid request");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}.as_array().unwrap();
|
||||||
|
|
||||||
|
for id in ids {
|
||||||
|
msg_id.push(id.as_str().unwrap().parse::<u128>().unwrap());
|
||||||
|
}
|
||||||
|
drop(ids);
|
||||||
|
|
||||||
|
let kaksh_kunjika = match &self.isthiti {
|
||||||
|
Isthiti::Kaksh(kaksh_kunjika) => {
|
||||||
|
kaksh_kunjika.to_owned()
|
||||||
|
}, _ => {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
Broker::<SystemBroker>::issue_async(ms::pind::DeleteMsg {
|
||||||
|
kaksh_kunjika,
|
||||||
|
kunjika: self.kunjika.to_owned(),
|
||||||
|
msg_id
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -108,6 +108,7 @@ impl WsSansad {
|
||||||
"text" => { self.send_text(val).await },
|
"text" => { self.send_text(val).await },
|
||||||
"img" => { self.send_image(val).await },
|
"img" => { self.send_image(val).await },
|
||||||
"status" => { self.send_status(val).await },
|
"status" => { self.send_status(val).await },
|
||||||
|
"del" => { self.delete_msg(val).await },
|
||||||
"list" => { self.list().await },
|
"list" => { self.list().await },
|
||||||
"leave" => { self.leave_kaksh().await },
|
"leave" => { self.leave_kaksh().await },
|
||||||
_ => ()
|
_ => ()
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
|
|
||||||
class Actions {
|
class Actions {
|
||||||
actions = []; // [[id, func]]
|
constructor() {
|
||||||
|
this.actions = []; // [[id, func]]
|
||||||
|
}
|
||||||
|
|
||||||
execute() {
|
execute() {
|
||||||
if(this.actions.length <= 0) return;
|
if(this.actions.length <= 0) return;
|
||||||
|
|
|
||||||
|
|
@ -124,7 +124,7 @@ let Messages = class {
|
||||||
}
|
}
|
||||||
|
|
||||||
static prepareReply() {
|
static prepareReply() {
|
||||||
var text = this.selectedMessageToText();
|
var text = Messages.selectedMessageToText();
|
||||||
var el = $('#reply_clip');
|
var el = $('#reply_clip');
|
||||||
el.removeClass('is-hidden');
|
el.removeClass('is-hidden');
|
||||||
el.attr('msg', text);
|
el.attr('msg', text);
|
||||||
|
|
@ -135,7 +135,7 @@ let Messages = class {
|
||||||
static copyMessagesToClipboard() {
|
static copyMessagesToClipboard() {
|
||||||
var $temp = $("<textarea>");
|
var $temp = $("<textarea>");
|
||||||
$("body").append($temp);
|
$("body").append($temp);
|
||||||
$temp.val(this.selectedMessageToText()).select();
|
$temp.val(Messages.selectedMessageToText()).select();
|
||||||
document.execCommand("copy");
|
document.execCommand("copy");
|
||||||
$temp.remove();
|
$temp.remove();
|
||||||
Messages.unselectAll();
|
Messages.unselectAll();
|
||||||
|
|
@ -157,7 +157,11 @@ let Messages = class {
|
||||||
|
|
||||||
dialog(prop, function() {
|
dialog(prop, function() {
|
||||||
if($('#dialog_check').prop('checked')) {
|
if($('#dialog_check').prop('checked')) {
|
||||||
|
var msg_id = [];
|
||||||
|
$('.message.active').each(function() {
|
||||||
|
msg_id.push($(this).attr('msgid'));
|
||||||
|
});
|
||||||
|
console.log(msg_id)
|
||||||
} else $('.message.active').remove();
|
} else $('.message.active').remove();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue