Skip to content

Commit

Permalink
Revert OT
Browse files Browse the repository at this point in the history
  • Loading branch information
jcs090218 committed Jun 15, 2024
1 parent 9b542dc commit 937ddab
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
12 changes: 6 additions & 6 deletions src/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,11 @@ pub struct File {

impl File {
pub fn new(_path: String) -> Self {
let mut new_file = Self {
Self {
path: _path,
chat: Chat::new(),
view: None,
};
new_file.load_file(); // ensure read
new_file
}
}

/// Return the file path.
Expand All @@ -63,6 +61,7 @@ impl File {
}

pub fn update(&mut self, add_or_delete: &String, beg: usize, end: usize, contents: &String) {
self.load_file();
let view = self.view.as_mut().unwrap();

match add_or_delete.clone().as_str() {
Expand All @@ -79,13 +78,14 @@ impl File {
}

/// Return the file contents.
pub fn contents(&self) -> String {
pub fn contents(&mut self) -> String {
self.load_file();
let view = self.view.clone().unwrap();
view.to_string()
}

/// Write the content to file.
pub fn save(&self) {
pub fn save(&mut self) {
let contents = self.contents();
let _ = std::fs::write(&self.path, contents);
}
Expand Down
5 changes: 0 additions & 5 deletions src/handler/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,6 @@ pub mod info {
let room = room.lock().await;
let client = room.get_client(addr).unwrap();

//let file = data_str(json, "file").unwrap();
//let file = room.get_file(&addr, &file);

if !check_entered(channel, &client, METHOD).await {
return;
}
Expand All @@ -238,8 +235,6 @@ pub mod info {
channel
.send_json(&serde_json::json!({
"method": METHOD,
//"file": file_path,
//"contents": contents,
"clients": users,
"status": "success",
}))
Expand Down

0 comments on commit 937ddab

Please sign in to comment.