globe for status
This commit is contained in:
@@ -410,6 +410,13 @@ fn channel_group_title(group_id: &str) -> &'static str {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn channel_group_system_image(group_id: &str) -> Option<&'static str> {
|
||||||
|
match group_id {
|
||||||
|
"jav" | "chinese" => Some("globe"),
|
||||||
|
_ => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn channel_group_order(group_id: &str) -> usize {
|
fn channel_group_order(group_id: &str) -> usize {
|
||||||
match group_id {
|
match group_id {
|
||||||
"meta-search" => 0,
|
"meta-search" => 0,
|
||||||
@@ -483,6 +490,7 @@ pub fn build_channel_groups(channels: &[ChannelView]) -> Vec<ChannelGroup> {
|
|||||||
groups.push(ChannelGroup {
|
groups.push(ChannelGroup {
|
||||||
id: group_id.clone(),
|
id: group_id.clone(),
|
||||||
title: channel_group_title(&group_id).to_string(),
|
title: channel_group_title(&group_id).to_string(),
|
||||||
|
systemImage: channel_group_system_image(&group_id).map(str::to_string),
|
||||||
channelIds: channel_ids,
|
channelIds: channel_ids,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -675,5 +683,11 @@ mod tests {
|
|||||||
.expect("meta group present");
|
.expect("meta group present");
|
||||||
assert_eq!(meta_group["channelIds"], serde_json::json!(["all"]));
|
assert_eq!(meta_group["channelIds"], serde_json::json!(["all"]));
|
||||||
assert!(meta_group.get("channels").is_none());
|
assert!(meta_group.get("channels").is_none());
|
||||||
|
|
||||||
|
let chinese_group = groups
|
||||||
|
.iter()
|
||||||
|
.find(|group| group["id"] == "chinese")
|
||||||
|
.expect("chinese group present");
|
||||||
|
assert_eq!(chinese_group["systemImage"], "globe");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,8 @@ pub struct Channel {
|
|||||||
pub struct ChannelGroup {
|
pub struct ChannelGroup {
|
||||||
pub id: String,
|
pub id: String,
|
||||||
pub title: String,
|
pub title: String,
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub systemImage: Option<String>,
|
||||||
pub channelIds: Vec<String>,
|
pub channelIds: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user