Skip to content

Commit

Permalink
changed delete effect sub format in backend, clean unused import
Browse files Browse the repository at this point in the history
  • Loading branch information
Chalkman071 committed Feb 10, 2024
1 parent b410be4 commit b522bc8
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 12 deletions.
2 changes: 1 addition & 1 deletion editor-blender/core/actions/state/led_editor.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import List, Optional, Tuple
from typing import List, Tuple

import bpy

Expand Down
1 change: 0 additions & 1 deletion editor-blender/core/actions/state/led_map.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from ...models import LEDEffect, LEDMap
from ...states import state
from ...utils.notification import notify
from ...utils.ui import redraw_area
from ..property.animation_data import set_ctrl_keyframes_from_state

Expand Down
2 changes: 1 addition & 1 deletion editor-blender/graphqls/subscriptions.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from dataclasses import dataclass
from enum import Enum
from typing import Any, Dict, List, Optional, Tuple, Union
from typing import Dict, List, Optional, Tuple, Union

from dataclass_wizard import JSONWizard
from gql import gql
Expand Down
29 changes: 21 additions & 8 deletions editor-server/src/graphql/mutations/led.rs
Original file line number Diff line number Diff line change
Expand Up @@ -405,17 +405,23 @@ impl LEDMutation {
let mysql = clients.mysql_pool();

// check if effect exists
let led_effect = sqlx::query!(
let led_effect = match sqlx::query!(
r#"
SELECT * FROM LEDEffect WHERE id = ?;
SELECT
LEDEffect.*,
Model.name as "model_name",
Part.name as "part_name"
FROM LEDEffect
INNER JOIN Model ON LEDEffect.model_id = Model.id
INNER JOIN Part ON LEDEffect.part_id = Part.id
WHERE LEDEffect.id = ?;
"#,
id
)
.fetch_optional(mysql)
.await;

match led_effect {
Ok(_) => {}
.fetch_one(mysql)
.await
{
Ok(led_effect) => led_effect,
Err(_) => {
return Ok(DeleteLEDEffectResponse {
ok: false,
Expand Down Expand Up @@ -495,7 +501,14 @@ impl LEDMutation {
let led_payload = LEDPayload {
create_effects: Vec::new(),
update_effects: Vec::new(),
delete_effects: vec![id],
delete_effects: vec![LEDEffectData {
id,
name: "".to_string(),
model_name: led_effect.model_name.clone(),
part_name: led_effect.part_name.clone(),
repeat: 0,
frames: vec![],
}],
};

Subscriptor::publish(led_payload);
Expand Down
2 changes: 1 addition & 1 deletion editor-server/src/graphql/subscriptions/led.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use futures_core::stream::Stream;
pub struct LEDPayload {
pub create_effects: Vec<LEDEffectData>,
pub update_effects: Vec<LEDEffectData>,
pub delete_effects: Vec<i32>,
pub delete_effects: Vec<LEDEffectData>,
}

#[derive(Default)]
Expand Down

0 comments on commit b522bc8

Please sign in to comment.