mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-15 08:30:02 +00:00
implement ChatOp::Dialogue::Save
This commit is contained in:
parent
7b7a7003f1
commit
2f157d5957
4 changed files with 18 additions and 9 deletions
|
|
@ -530,6 +530,11 @@ impl<'a> MtxChat<'a> {
|
|||
.expect("failed to convert post into buffer");
|
||||
}
|
||||
}
|
||||
// trigger the chat ui to save the dialogue to the pddb
|
||||
xous::send_message(
|
||||
chat_cid,
|
||||
xous::Message::new_scalar(ChatOp::DialogueSave as usize, 0, 0, 0, 0),
|
||||
)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,8 +10,10 @@ pub const POST_SELECTED_PREV: usize = usize::MAX - 1;
|
|||
|
||||
#[derive(Debug, num_derive::FromPrimitive, num_derive::ToPrimitive)]
|
||||
pub enum ChatOp {
|
||||
// Sve the Dialogue to pddb (ie after PostAdd, PostDelete)
|
||||
DialogueSave = 0,
|
||||
///
|
||||
DialogueSet = 0,
|
||||
DialogueSet,
|
||||
///
|
||||
GamChangeFocus,
|
||||
/// a line of text has arrived
|
||||
|
|
|
|||
|
|
@ -182,6 +182,14 @@ pub fn server(
|
|||
let msg = xous::receive_message(sid).unwrap();
|
||||
log::debug!("got message {:?}", msg);
|
||||
match FromPrimitive::from_usize(msg.body.id()) {
|
||||
Some(ChatOp::DialogueSave) => {
|
||||
log::warn!("ChatOp::DialogueSave");
|
||||
ui.dialogue_save().expect("failed to save Dialogue");
|
||||
ui.dialogue_read().expect("failed to read Dialogue");
|
||||
if allow_redraw {
|
||||
ui.redraw().expect("CHAT couldn't redraw");
|
||||
}
|
||||
}
|
||||
Some(ChatOp::DialogueSet) => {
|
||||
log::info!("ChatOp::DialogueSet");
|
||||
let buffer =
|
||||
|
|
|
|||
|
|
@ -145,7 +145,7 @@ impl Ui {
|
|||
}
|
||||
}
|
||||
|
||||
fn dialogue_read(&mut self) -> Result<(), Error> {
|
||||
pub fn dialogue_read(&mut self) -> Result<(), Error> {
|
||||
match (&self.pddb_dict, &self.pddb_key) {
|
||||
(Some(dict), Some(key)) => {
|
||||
match self
|
||||
|
|
@ -200,7 +200,7 @@ impl Ui {
|
|||
}
|
||||
}
|
||||
|
||||
fn dialogue_save(&self) -> Result<(), Error> {
|
||||
pub fn dialogue_save(&self) -> Result<(), Error> {
|
||||
match (&self.dialogue, &self.pddb_dict, &self.pddb_key) {
|
||||
(Some(dialogue), Some(dict), Some(key)) => {
|
||||
let hint = Some(dialogue::MAX_BYTES + 2);
|
||||
|
|
@ -314,11 +314,6 @@ impl Ui {
|
|||
dialogue
|
||||
.post_add(author, timestamp, text, attach_url)
|
||||
.unwrap();
|
||||
match self.dialogue_save() {
|
||||
Ok(_) => log::info!("Dialogue saved"),
|
||||
Err(e) => log::warn!("Failed to save Dialogue: {e}"),
|
||||
}
|
||||
self.redraw().expect("failed chat ui redraw");
|
||||
}
|
||||
None => log::warn!("no Dialogue available to add Post"),
|
||||
}
|
||||
|
|
@ -517,7 +512,6 @@ impl Ui {
|
|||
// error: if Dialogue == None
|
||||
fn layout(&mut self) -> Result<bool, Error> {
|
||||
self.clear_area();
|
||||
match (&self.dialogue, &self.post_anchor) {
|
||||
match (&self.dialogue, &self.post_anchor ) {
|
||||
(Some(dialogue), Some(post_anchor)) => {
|
||||
log::info!("redrawing dialogue: {}", dialogue.title);
|
||||
|
|
|
|||
Loading…
Reference in a new issue