added join channel function
This commit is contained in:
@@ -111,6 +111,12 @@ struct GetActiveChannelData {
|
||||
active: bool,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Type)]
|
||||
struct UpdateChannelData {
|
||||
event_id: String,
|
||||
active: bool,
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
#[specta::specta]
|
||||
async fn get_accounts(db: DbState<'_>) -> Result<Vec<account::Data>, ()> {
|
||||
@@ -264,6 +270,19 @@ async fn create_channel(db: DbState<'_>, data: CreateChannelData) -> Result<chan
|
||||
.map_err(|_| ())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
#[specta::specta]
|
||||
async fn update_channel(db: DbState<'_>, data: UpdateChannelData) -> Result<channel::Data, ()> {
|
||||
db.channel()
|
||||
.update(
|
||||
channel::event_id::equals(data.event_id), // Unique filter
|
||||
vec![channel::active::set(data.active)], // Vec of updates
|
||||
)
|
||||
.exec()
|
||||
.await
|
||||
.map_err(|_| ())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
#[specta::specta]
|
||||
async fn get_channels(db: DbState<'_>, data: GetChannelData) -> Result<Vec<channel::Data>, ()> {
|
||||
@@ -335,6 +354,7 @@ async fn main() {
|
||||
get_latest_notes,
|
||||
get_note_by_id,
|
||||
create_channel,
|
||||
update_channel,
|
||||
get_channels,
|
||||
get_active_channels,
|
||||
create_chat,
|
||||
@@ -382,6 +402,7 @@ async fn main() {
|
||||
get_note_by_id,
|
||||
count_total_notes,
|
||||
create_channel,
|
||||
update_channel,
|
||||
get_channels,
|
||||
get_active_channels,
|
||||
create_chat,
|
||||
|
||||
Reference in New Issue
Block a user