mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-15 08:30:02 +00:00
refactor chat timestamp to u64
This commit is contained in:
parent
29d06e18bf
commit
9db7a3c2c5
5 changed files with 13 additions and 13 deletions
|
|
@ -35,7 +35,7 @@ pub const POST_TEXT_MAX: usize = 3072;
|
|||
#[derive(Archive, Serialize, Deserialize, Debug)]
|
||||
pub struct Find {
|
||||
pub author: xous_ipc::String<128>,
|
||||
pub timestamp: u32,
|
||||
pub timestamp: u64,
|
||||
pub key: Option<usize>, // the return post key if found.
|
||||
}
|
||||
|
||||
|
|
@ -48,7 +48,7 @@ pub struct Dialogue {
|
|||
#[derive(Archive, Serialize, Deserialize, Debug)]
|
||||
pub struct Post {
|
||||
pub author: xous_ipc::String<128>,
|
||||
pub timestamp: u32,
|
||||
pub timestamp: u64,
|
||||
pub text: xous_ipc::String<POST_TEXT_MAX>,
|
||||
pub attach_url: Option<xous_ipc::String<128>>,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ pub struct Dialogue {
|
|||
posts: Vec<Post>,
|
||||
authors: HashMap<u16, Author>,
|
||||
author_lookup: HashMap<String, u16>,
|
||||
last_timestamp: u32,
|
||||
last_timestamp: u64,
|
||||
last_author_id: u16,
|
||||
}
|
||||
|
||||
|
|
@ -48,7 +48,7 @@ impl Dialogue {
|
|||
pub fn post_add(
|
||||
&mut self,
|
||||
author: &str,
|
||||
timestamp: u32,
|
||||
timestamp: u64,
|
||||
text: &str,
|
||||
_attach_url: Option<&str>,
|
||||
) -> Result<(), Error> {
|
||||
|
|
@ -82,7 +82,7 @@ impl Dialogue {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn post_find(&self, author: &str, timestamp: u32) -> Option<usize> {
|
||||
pub fn post_find(&self, author: &str, timestamp: u64) -> Option<usize> {
|
||||
if let Some(author_id) = self.author_lookup.get(author) {
|
||||
match self
|
||||
.posts
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ use rkyv::{Archive, Deserialize, Serialize};
|
|||
#[derive(Archive, Serialize, Deserialize, Debug)]
|
||||
pub struct Post {
|
||||
author_id: u16,
|
||||
timestamp: u32,
|
||||
timestamp: u64,
|
||||
text: String,
|
||||
attach: Option<Attach>,
|
||||
pub flags: u16,
|
||||
|
|
@ -15,7 +15,7 @@ pub struct Post {
|
|||
|
||||
#[allow(dead_code)]
|
||||
impl Post {
|
||||
pub fn new(author_id: u16, timestamp: u32, text: &str, attach: Option<Attach>) -> Self {
|
||||
pub fn new(author_id: u16, timestamp: u64, text: &str, attach: Option<Attach>) -> Self {
|
||||
Self {
|
||||
author_id: author_id,
|
||||
timestamp: timestamp,
|
||||
|
|
@ -45,7 +45,7 @@ impl Post {
|
|||
self.text.as_str()
|
||||
}
|
||||
|
||||
pub fn timestamp(&self) -> u32 {
|
||||
pub fn timestamp(&self) -> u64 {
|
||||
self.timestamp
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ impl Chat {
|
|||
pub fn post_add(
|
||||
&self,
|
||||
author: &str,
|
||||
timestamp: u32,
|
||||
timestamp: u64,
|
||||
text: &str,
|
||||
attach_url: Option<&str>,
|
||||
) -> Result<(), Error> {
|
||||
|
|
@ -90,7 +90,7 @@ impl Chat {
|
|||
}
|
||||
|
||||
// get a Post from the current Dialogue
|
||||
pub fn post_find(&self, author: &str, timestamp: u32) -> Result<Option<usize>, Error> {
|
||||
pub fn post_find(&self, author: &str, timestamp: u64) -> Result<Option<usize>, Error> {
|
||||
let mut find = Find {
|
||||
author: xous_ipc::String::new(),
|
||||
timestamp: timestamp,
|
||||
|
|
@ -266,7 +266,7 @@ pub fn server(
|
|||
xous::terminate_process(0)
|
||||
}
|
||||
|
||||
pub fn now() -> u32 {
|
||||
pub fn now() -> u64 {
|
||||
SystemTime::now()
|
||||
.duration_since(UNIX_EPOCH)
|
||||
.unwrap()
|
||||
|
|
|
|||
|
|
@ -238,7 +238,7 @@ impl Ui {
|
|||
pub fn post_add(
|
||||
&mut self,
|
||||
author: &str,
|
||||
timestamp: u32,
|
||||
timestamp: u64,
|
||||
text: &str,
|
||||
attach_url: Option<&str>,
|
||||
) -> Result<(), Error> {
|
||||
|
|
@ -264,7 +264,7 @@ impl Ui {
|
|||
}
|
||||
|
||||
// get a Post from the current Dialogue
|
||||
pub fn post_find(&self, author: &str, timestamp: u32) -> Option<usize> {
|
||||
pub fn post_find(&self, author: &str, timestamp: u64) -> Option<usize> {
|
||||
match &self.dialogue {
|
||||
Some(dialogue) => dialogue.post_find(author, timestamp),
|
||||
None => None,
|
||||
|
|
|
|||
Loading…
Reference in a new issue