Skip to content

Commit

Permalink
Fix client-feature, no-model compiles
Browse files Browse the repository at this point in the history
Some of the methods used in the client dispatch, namely `Channel::id`
and `Message::transform_content`, are not _required_ for functionality
by the dispatcher. Since these methods are `model` features, they can be
gated behind a `model` feature cfg.
  • Loading branch information
Zeyla Hellyer committed Jun 2, 2017
1 parent 81f8c9e commit 831c1c7
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions src/client/dispatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,10 @@ fn dispatch_message(context: Context,
event_store: &Arc<RwLock<EventStore>>) {
if let Some(handler) = handler!(on_message, event_store) {
thread::spawn(move || {
message.transform_content();
#[cfg(feature="model")]
{
message.transform_content();
}

(handler)(context, message);
});
Expand All @@ -128,7 +131,15 @@ fn handle_event(event: Event,
Event::ChannelCreate(event) => {
if let Some(handler) = handler!(on_channel_create, event_store) {
update!(update_with_channel_create, event);
let context = context(Some(event.channel.id()), conn, data);

let mut channel_id = None;

#[cfg(feature="model")]
{
channel_id = Some(event.channel.id());
}

let context = context(channel_id, conn, data);

thread::spawn(move || (handler)(context, event.channel));
} else {
Expand Down Expand Up @@ -172,7 +183,14 @@ fn handle_event(event: Event,
},
Event::ChannelUpdate(event) => {
if let Some(handler) = handler!(on_channel_update, event_store) {
let context = context(Some(event.channel.id()), conn, data);
let mut channel_id = None;

#[cfg(feature="model")]
{
channel_id = Some(event.channel.id());
}

let context = context(channel_id, conn, data);

feature_cache! {{
let before = CACHE.read().unwrap().channel(event.channel.id());
Expand Down

0 comments on commit 831c1c7

Please sign in to comment.