Skip to content

Commit

Permalink
Merge pull request #2164 from acterglobal/ben-no-more-category-id
Browse files Browse the repository at this point in the history
Remove id from category
  • Loading branch information
gnunicorn authored Sep 9, 2024
2 parents 87e372e + 5bd32dd commit d8fecd6
Show file tree
Hide file tree
Showing 10 changed files with 7 additions and 72 deletions.
1 change: 0 additions & 1 deletion native/acter/api.rsh
Original file line number Diff line number Diff line change
Expand Up @@ -2044,7 +2044,6 @@ object ActerAppSettingsBuilder {


object Category {
fn id() -> string;
fn title() -> string;
fn entries() -> string;
fn display() -> Option<Display>;
Expand Down
6 changes: 0 additions & 6 deletions native/acter/src/api/categories.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,7 @@ impl CategoriesBuilder {
self.entries.clear();
}
pub fn add(&mut self, cat: Box<Category>) {
let id = cat.id();
let idx = self.entries.iter().position(|p| p.id == id);
self.entries.push(*cat);
if let Some(index) = idx {
// remove the existing entry and replace it with the freshly added one
self.entries.swap_remove(index);
}
}
pub(crate) fn build(self) -> CategoriesStateEventContent {
CategoriesStateEventContent {
Expand Down
1 change: 0 additions & 1 deletion native/acter/src/api/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,6 @@ pub fn new_link_ref_builder(title: String, uri: String) -> Result<RefDetailsBuil
Ok(builder)
}

#[allow(clippy::boxed_local)]
pub fn new_obj_ref_builder(
position: Option<String>,
reference: Box<RefDetails>,
Expand Down
2 changes: 0 additions & 2 deletions native/acter/src/api/news.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,6 @@ impl NewsSlideDraft {
}
}

#[allow(clippy::boxed_local)]
pub fn color(&mut self, colors: Box<ColorizeBuilder>) {
self.colorize_builder = *colors;
}
Expand All @@ -320,7 +319,6 @@ impl NewsSlideDraft {
.build()?)
}

#[allow(clippy::boxed_local)]
pub fn add_reference(&mut self, reference: Box<ObjRef>) -> &Self {
self.references.push(*reference);
self
Expand Down
2 changes: 0 additions & 2 deletions native/acter/src/api/pins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,6 @@ impl PinDraft {
self
}

#[allow(clippy::boxed_local)]
pub fn display(&mut self, display: Box<Display>) -> &mut Self {
self.content.display(Some(*display));
self
Expand Down Expand Up @@ -456,7 +455,6 @@ impl PinUpdateBuilder {
self
}

#[allow(clippy::boxed_local)]
pub fn display(&mut self, display: Box<Display>) -> &mut Self {
self.content.display(Some(Some(*display)));
self
Expand Down
4 changes: 0 additions & 4 deletions native/acter/src/api/tasks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,6 @@ impl TaskListDraft {
self
}

#[allow(clippy::boxed_local)]
pub fn display(&mut self, display: Box<Display>) -> &mut Self {
self.content.display(Some(*display));
self
Expand Down Expand Up @@ -853,7 +852,6 @@ impl TaskDraft {
self
}

#[allow(clippy::boxed_local)]
pub fn display(&mut self, display: Box<Display>) -> &mut Self {
self.content.display(Some(*display));
self
Expand Down Expand Up @@ -935,7 +933,6 @@ impl TaskUpdateBuilder {
self
}

#[allow(clippy::boxed_local)]
pub fn display(&mut self, display: Box<Display>) -> &mut Self {
self.content.display(Some(Some(*display)));
self
Expand Down Expand Up @@ -1166,7 +1163,6 @@ impl TaskListUpdateBuilder {
self
}

#[allow(clippy::boxed_local)]
pub fn display(&mut self, display: Box<Display>) -> &mut Self {
self.content.display(Some(Some(*display)));
self
Expand Down
7 changes: 6 additions & 1 deletion native/acter/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@
#![feature(vec_into_raw_parts)]
#![feature(async_closure)]
#![feature(box_into_inner)]
#![allow(unused, dead_code, clippy::transmutes_expressible_as_ptr_casts)]
#![allow(
unused,
dead_code,
clippy::boxed_local,
clippy::transmutes_expressible_as_ptr_casts
)]

#[rustfmt::skip]
#[cfg(feature = "uniffi")]
Expand Down
5 changes: 0 additions & 5 deletions native/core/src/events/common/categories.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ pub struct CategoriesStateEventContent {

#[derive(Debug, Clone, Serialize, Eq, PartialEq, Deserialize, Builder)]
pub struct Category {
pub id: String,
pub title: String,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[builder(default, setter(name = "display_typed"))]
Expand All @@ -22,9 +21,6 @@ pub struct Category {
}

impl Category {
pub fn id(&self) -> String {
self.id.clone()
}
pub fn title(&self) -> String {
self.title.clone()
}
Expand All @@ -38,7 +34,6 @@ impl Category {
pub fn update_builder(&self) -> CategoryBuilder {
CategoryBuilder::default()
.entries(self.entries())
.id(self.id.clone())
.title(self.title.clone())
.display_typed(self.display.clone())
.to_owned()
Expand Down
3 changes: 1 addition & 2 deletions native/test/src/tests/categories.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ async fn categories_e2e() -> Result<()> {
new_cat_builder.add_entry("a".to_owned());
new_cat_builder.add_entry("b".to_owned());
new_cat_builder.add_entry("c".to_owned());
new_cat_builder.id("campaigns".to_owned());
new_cat_builder.title("Campaigns".to_owned());
let new_cat = new_cat_builder.build()?;

Expand Down Expand Up @@ -78,14 +77,14 @@ async fn categories_e2e() -> Result<()> {
let updated = updater.build()?;

let mut space_cat_updater = new_space_categories.update_builder();
space_cat_updater.clear();
space_cat_updater.add(Box::new(updated.clone()));

// and we add a second now.
let mut new_cat_builder = new_space_categories.new_category_builder();
new_cat_builder.add_entry("c".to_owned());
new_cat_builder.add_entry("b".to_owned());
new_cat_builder.add_entry("a".to_owned());
new_cat_builder.id("new-campaign".to_owned());
new_cat_builder.title("Campaigns".to_owned());
let new_cat = new_cat_builder.build()?;
space_cat_updater.add(Box::new(new_cat.clone()));
Expand Down
48 changes: 0 additions & 48 deletions packages/rust_sdk/lib/acter_flutter_sdk_ffi.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23919,16 +23919,6 @@ class Api {
int,
int,
)>();
late final _categoryIdPtr = _lookup<
ffi.NativeFunction<
_CategoryIdReturn Function(
ffi.IntPtr,
)>>("__Category_id");

late final _categoryId = _categoryIdPtr.asFunction<
_CategoryIdReturn Function(
int,
)>();
late final _categoryTitlePtr = _lookup<
ffi.NativeFunction<
_CategoryTitleReturn Function(
Expand Down Expand Up @@ -49093,35 +49083,6 @@ class Category {

Category._(this._api, this._box);

String id() {
var tmp0 = 0;
tmp0 = _box.borrow();
final tmp1 = _api._categoryId(
tmp0,
);
final tmp3 = tmp1.arg0;
final tmp4 = tmp1.arg1;
final tmp5 = tmp1.arg2;
if (tmp4 == 0) {
print("returning empty string");
return "";
}
final ffi.Pointer<ffi.Uint8> tmp3_ptr = ffi.Pointer.fromAddress(tmp3);
List<int> tmp3_buf = [];
final tmp3_precast = tmp3_ptr.cast<ffi.Uint8>();
for (int i = 0; i < tmp4; i++) {
int char = tmp3_precast.elementAt(i).value;
tmp3_buf.add(char);
}
final tmp2 = utf8.decode(tmp3_buf, allowMalformed: true);
if (tmp5 > 0) {
final ffi.Pointer<ffi.Void> tmp3_0;
tmp3_0 = ffi.Pointer.fromAddress(tmp3);
_api.__deallocate(tmp3_0, tmp5 * 1, 1);
}
return tmp2;
}

String title() {
var tmp0 = 0;
tmp0 = _box.borrow();
Expand Down Expand Up @@ -60342,15 +60303,6 @@ class _SimpleSettingWithTurnOffBuilderBuildReturn extends ffi.Struct {
external int arg4;
}

class _CategoryIdReturn extends ffi.Struct {
@ffi.IntPtr()
external int arg0;
@ffi.UintPtr()
external int arg1;
@ffi.UintPtr()
external int arg2;
}

class _CategoryTitleReturn extends ffi.Struct {
@ffi.IntPtr()
external int arg0;
Expand Down

0 comments on commit d8fecd6

Please sign in to comment.