backend: remove outdated code for search
This removes outdated code, which was used to make search requests to the server.
This commit is contained in:
parent
766d38d91c
commit
976ed8d945
4 changed files with 0 additions and 63 deletions
|
@ -124,10 +124,6 @@ pub fn backend_loop(rx: Receiver<BKResponse>) {
|
|||
let init = false;
|
||||
APPOP!(show_room_messages, (msgs, init));
|
||||
}
|
||||
Ok(BKResponse::RoomMessagesInit(msgs)) => {
|
||||
let init = true;
|
||||
APPOP!(show_room_messages, (msgs, init));
|
||||
}
|
||||
Ok(BKResponse::RoomMessagesTo(msgs, room, prev_batch)) => {
|
||||
APPOP!(show_room_messages_top, (msgs, room, prev_batch));
|
||||
}
|
||||
|
|
|
@ -262,10 +262,6 @@ impl Backend {
|
|||
let r = room::add_to_fav(self, roomid, tofav);
|
||||
bkerror!(r, tx, BKResponse::AddToFavError);
|
||||
}
|
||||
Ok(BKCommand::Search(roomid, term)) => {
|
||||
let r = room::search(self, roomid, term);
|
||||
bkerror!(r, tx, BKResponse::SearchError);
|
||||
}
|
||||
Ok(BKCommand::AcceptInv(roomid)) => {
|
||||
let r = room::join_room(self, roomid);
|
||||
bkerror!(r, tx, BKResponse::AcceptInvError);
|
||||
|
|
|
@ -491,58 +491,6 @@ pub fn direct_chat(bk: &Backend, user: Member, internal_id: String) -> Result<()
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub fn search(bk: &Backend, roomid: String, term: Option<String>) -> Result<(), Error> {
|
||||
let tx = bk.tx.clone();
|
||||
|
||||
match term {
|
||||
Some(ref t) if !t.is_empty() => {
|
||||
make_search(bk, roomid, t.clone())
|
||||
}
|
||||
_ => {
|
||||
tx.send(BKResponse::SearchEnd).unwrap();
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn make_search(bk: &Backend, roomid: String, term: String) -> Result<(), Error> {
|
||||
let url = bk.url("search", vec![])?;
|
||||
|
||||
let attrs = json!({
|
||||
"search_categories": {
|
||||
"room_events": {
|
||||
"keys": ["content.body"],
|
||||
"search_term": term,
|
||||
"filter": {
|
||||
"rooms": [ roomid.clone() ],
|
||||
},
|
||||
"order_by": "recent",
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
let tx = bk.tx.clone();
|
||||
|
||||
thread::spawn(move || {
|
||||
match json_q("post", &url, &attrs, 0) {
|
||||
Ok(js) => {
|
||||
tx.send(BKResponse::SearchEnd).unwrap();
|
||||
let res = &js["search_categories"]["room_events"]["results"];
|
||||
let events = res.as_array().unwrap().iter().rev();
|
||||
let ms = Message::from_json_events_iter(roomid.clone(), events);
|
||||
|
||||
tx.send(BKResponse::RoomMessagesInit(ms)).unwrap();
|
||||
}
|
||||
Err(err) => {
|
||||
tx.send(BKResponse::SearchEnd).unwrap();
|
||||
tx.send(BKResponse::SearchError(err)).unwrap()
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn add_to_fav(bk: &Backend, roomid: String, tofav: bool) -> Result<(), Error> {
|
||||
let userid = bk.data.lock().unwrap().user_id.clone();
|
||||
let url = bk.url(&format!("user/{}/rooms/{}/tags/m.favourite", userid, roomid), vec![])?;
|
||||
|
|
|
@ -65,7 +65,6 @@ pub enum BKCommand {
|
|||
SetRoomTopic(String, String),
|
||||
SetRoomAvatar(String, String),
|
||||
AttachFile(Message),
|
||||
Search(String, Option<String>),
|
||||
NewRoom(String, RoomType, String),
|
||||
DirectChat(Member, String),
|
||||
AddToFav(String, bool),
|
||||
|
@ -123,7 +122,6 @@ pub enum BKResponse {
|
|||
Media(String),
|
||||
MediaUrl(Url),
|
||||
AttachedFile(Message),
|
||||
SearchEnd,
|
||||
NewRoom(Room, String),
|
||||
AddedToFav(String, bool),
|
||||
RoomNotifications(String, i32, i32),
|
||||
|
@ -165,7 +163,6 @@ pub enum BKResponse {
|
|||
GetRoomAvatarError(Error),
|
||||
MediaError(Error),
|
||||
AttachFileError(Error),
|
||||
SearchError(Error),
|
||||
NewRoomError(Error, String),
|
||||
AddToFavError(Error),
|
||||
AcceptInvError(Error),
|
||||
|
|
Loading…
Reference in a new issue