Skip to content

Commit

Permalink
fix: remove duplicates for Vec<MetaItemPreview>
Browse files Browse the repository at this point in the history
co-author: @tymmesyde

Signed-off-by: Lachezar Lechev <[email protected]>
  • Loading branch information
elpiel committed Oct 8, 2024
1 parent b6a333f commit 118e0a2
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 18 deletions.
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ openssl = { version = "=0.10.40" }
http-cache-reqwest = { version = "0.4.5" }
reqwest-middleware = { version = "0.1.6" }

itertools = "0.13"

[profile.release]
lto = true
opt-level = 3
Expand Down
1 change: 1 addition & 0 deletions stremio-core-protobuf/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ semver = { version = "1", features = ["serde"] }
chrono = "0.4.*"
boolinator = "2.4.*"
Inflector = "0.11.*"
itertools.workspace = true

hex = "0.4.*"
url = { version = "2.4", features = ["serde"] }
Expand Down
46 changes: 28 additions & 18 deletions stremio-core-protobuf/src/bridge/loadable.rs
Original file line number Diff line number Diff line change
@@ -1,24 +1,29 @@
use itertools::Itertools;
use url::Url;

use stremio_core::deep_links::MetaItemDeepLinks;
use stremio_core::models::common::{Loadable, ResourceError};
use stremio_core::models::ctx::{Ctx, CtxError};
use stremio_core::models::link::LinkError;
use stremio_core::models::streaming_server::PlaybackDevice;
use stremio_core::runtime::EnvError;

use stremio_core::types::{
addon::{Descriptor, DescriptorPreview, ResourcePath, ResourceRequest},
api::{GetModalResponse, GetNotificationResponse, LinkAuthKey, LinkCodeResponse},
library::LibraryItem,
resource::{MetaItem, MetaItemPreview, Stream, Subtitles},
streaming_server::{Settings, Statistics},
watched_bitfield::WatchedBitField,
use stremio_core::{
deep_links::MetaItemDeepLinks,
models::{
common::{Loadable, ResourceError},
ctx::{Ctx, CtxError},
link::LinkError,
streaming_server::PlaybackDevice,
},
runtime::EnvError,
types::{
addon::{Descriptor, DescriptorPreview, ResourcePath, ResourceRequest},
api::{GetModalResponse, GetNotificationResponse, LinkAuthKey, LinkCodeResponse},
library::LibraryItem,
resource::{MetaItem, MetaItemPreview, Stream, Subtitles},
streaming_server::{Settings, Statistics},
watched_bitfield::WatchedBitField,
},
};

use crate::bridge::ToProtobuf;
use crate::protobuf::stremio::core::models;
use crate::protobuf::stremio::core::models::{LoadedModal, LoadedNotification, PlaybackDevices};
use crate::{
bridge::ToProtobuf,
protobuf::stremio::core::models::{self, LoadedModal, LoadedNotification, PlaybackDevices},
};

impl ToProtobuf<models::loadable_page::Content, (&Ctx, &ResourceRequest)>
for Loadable<Vec<MetaItemPreview>, ResourceError>
Expand All @@ -29,7 +34,12 @@ impl ToProtobuf<models::loadable_page::Content, (&Ctx, &ResourceRequest)>
) -> models::loadable_page::Content {
match &self {
Loadable::Ready(ready) => models::loadable_page::Content::Ready(models::Page {
meta_items: ready.to_protobuf::<E>(&(*ctx, *request)),
meta_items: ready
.iter()
.unique_by(|meta_item| &meta_item.id)
.map(|meta_item| meta_item.to_owned())
.collect_vec()
.to_protobuf(&(*ctx, *request)),
}),
Loadable::Err(error) => models::loadable_page::Content::Error(models::Error {
message: error.to_string(),
Expand Down

0 comments on commit 118e0a2

Please sign in to comment.