Skip to content

Commit

Permalink
Merge pull request #1740 from h3poteto/renovate/megalodon-1.x
Browse files Browse the repository at this point in the history
Update Rust crate megalodon to v1
  • Loading branch information
h3poteto authored Jan 13, 2025
2 parents 29ea2f8 + 8851a33 commit 09e214d
Show file tree
Hide file tree
Showing 3 changed files with 122 additions and 111 deletions.
4 changes: 2 additions & 2 deletions src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ sqlx = { version = "0.8.3", features = ["runtime-tokio-rustls", "sqlite", "migr
tokio = { version = "1.43.0", features = ["full"] }
futures = "0.3.31"
directories = "6.0.0"
megalodon = "0.15.2"
megalodon = "1.0.0"
tracing = "0.1.41"
reqwest = { version = ">=0.12.12", features = ["json", "multipart", "stream"] }
scraper = "0.22.0"
Expand Down
227 changes: 119 additions & 108 deletions src-tauri/src/streaming.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,58 +86,63 @@ pub async fn start_user(

let server_id = server.id;

let s = streaming.listen(Box::new(move |message| match message {
Message::Update(mes) => {
tracing::debug!("receive update");
app_handle
.emit(
"receive-home-status",
ReceiveHomeStatusPayload {
server_id,
status: mes,
},
)
.expect("Failed to send receive-home-status event");
}
Message::Notification(mes) => {
tracing::debug!("receive notification");
if mes.account.is_some() {
app_handle
.emit(
"receive-notification",
ReceiveNotificationPayload {
server_id,
notification: mes,
},
)
.expect("Failed to send receive-notification event");
let s = streaming.listen(Box::new(move |message| {
let app_handle = app_handle.clone();
Box::pin(async move {
match message {
Message::Update(mes) => {
tracing::debug!("receive update");
app_handle
.emit(
"receive-home-status",
ReceiveHomeStatusPayload {
server_id,
status: mes,
},
)
.expect("Failed to send receive-home-status event");
}
Message::Notification(mes) => {
tracing::debug!("receive notification");
if mes.account.is_some() {
app_handle
.emit(
"receive-notification",
ReceiveNotificationPayload {
server_id,
notification: mes,
},
)
.expect("Failed to send receive-notification event");
}
}
Message::StatusUpdate(mes) => {
tracing::debug!("receive status updated");
app_handle
.emit(
"receive-home-status-update",
ReceiveHomeStatusUpdatePayload {
server_id,
status: mes,
},
)
.expect("Failed to send receive-home-status-update event");
}
Message::Delete(status_id) => {
tracing::debug!("receive delete");
app_handle
.emit(
"delete-home-status",
DeleteHomeStatusPayload {
server_id,
status_id,
},
)
.expect("Failed to send delete-home-status event");
}
_ => {}
}
}
Message::StatusUpdate(mes) => {
tracing::debug!("receive status updated");
app_handle
.emit(
"receive-home-status-update",
ReceiveHomeStatusUpdatePayload {
server_id,
status: mes,
},
)
.expect("Failed to send receive-home-status-update event");
}
Message::Delete(status_id) => {
tracing::debug!("receive delete");
app_handle
.emit(
"delete-home-status",
DeleteHomeStatusPayload {
server_id,
status_id,
},
)
.expect("Failed to send delete-home-status event");
}
_ => {}
})
}));
s.await;

Expand Down Expand Up @@ -205,63 +210,69 @@ pub async fn start(
let server_id = server.id;
let name = timeline.name.clone();

let s = streaming.listen(Box::new(move |message| match message {
Message::Update(mes) => {
tracing::debug!("receive update");
app_handle
.emit(
"receive-timeline-status",
ReceiveTimelineStatusPayload {
server_id,
timeline_id,
name: name.clone(),
status: mes,
},
)
.expect("Failed to receive-timeline-status event");
}
Message::StatusUpdate(mes) => {
tracing::debug!("receive status update");
app_handle
.emit(
"receive-timeline-status-update",
ReceiveTimelineStatusUpdatePayload {
server_id,
timeline_id,
name: name.clone(),
status: mes,
},
)
.expect("Failed to receive-timeline-status-update event");
}
Message::Delete(status_id) => {
tracing::debug!("receive delete");
app_handle
.emit(
"delete-timeline-status",
DeleteTimelineStatusPayload {
server_id,
timeline_id,
name: name.clone(),
status_id,
},
)
.expect("Failed to delete-timeline-status event");
}
Message::Conversation(conversation) => {
tracing::debug!("receive conversation");
app_handle
.emit(
"receive-timeline-conversation",
ReceiveTimelineConversationPayload {
server_id,
timeline_id,
conversation,
},
)
.expect("Failed to receive-timeline-conversation event");
}
_ => {}
let s = streaming.listen(Box::new(move |message| {
let app_handle = app_handle.clone();
let name = name.clone();
Box::pin(async move {
match message {
Message::Update(mes) => {
tracing::debug!("receive update");
app_handle
.emit(
"receive-timeline-status",
ReceiveTimelineStatusPayload {
server_id,
timeline_id,
name: name.clone(),
status: mes,
},
)
.expect("Failed to receive-timeline-status event");
}
Message::StatusUpdate(mes) => {
tracing::debug!("receive status update");
app_handle
.emit(
"receive-timeline-status-update",
ReceiveTimelineStatusUpdatePayload {
server_id,
timeline_id,
name: name.clone(),
status: mes,
},
)
.expect("Failed to receive-timeline-status-update event");
}
Message::Delete(status_id) => {
tracing::debug!("receive delete");
app_handle
.emit(
"delete-timeline-status",
DeleteTimelineStatusPayload {
server_id,
timeline_id,
name: name.clone(),
status_id,
},
)
.expect("Failed to delete-timeline-status event");
}
Message::Conversation(conversation) => {
tracing::debug!("receive conversation");
app_handle
.emit(
"receive-timeline-conversation",
ReceiveTimelineConversationPayload {
server_id,
timeline_id,
conversation,
},
)
.expect("Failed to receive-timeline-conversation event");
}
_ => {}
}
})
}));
s.await;

Expand Down

0 comments on commit 09e214d

Please sign in to comment.