Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(channels): allow sending currently selected entries to other channels #235

Merged
merged 1 commit into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions crates/television-channels/src/channels/dirs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ impl From<&mut TelevisionChannel> for Channel {
fn from(value: &mut TelevisionChannel) -> Self {
match value {
c @ TelevisionChannel::GitRepos(_) => {
let entries = c.results(c.result_count(), 0);
let entries = if c.selected_entries().is_empty() {
c.results(c.result_count(), 0)
} else {
c.selected_entries().iter().cloned().collect()
};
Self::new(
entries
.iter()
Expand All @@ -46,7 +50,11 @@ impl From<&mut TelevisionChannel> for Channel {
)
}
c @ TelevisionChannel::Dirs(_) => {
let entries = c.results(c.result_count(), 0);
let entries = if c.selected_entries().is_empty() {
c.results(c.result_count(), 0)
} else {
c.selected_entries().iter().cloned().collect()
};
Self::new(
entries
.iter()
Expand Down
18 changes: 15 additions & 3 deletions crates/television-channels/src/channels/files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ impl From<&mut TelevisionChannel> for Channel {
fn from(value: &mut TelevisionChannel) -> Self {
match value {
c @ TelevisionChannel::GitRepos(_) => {
let entries = c.results(c.result_count(), 0);
let entries = if c.selected_entries().is_empty() {
c.results(c.result_count(), 0)
} else {
c.selected_entries().iter().cloned().collect()
};
Self::new(
entries
.iter()
Expand All @@ -46,7 +50,11 @@ impl From<&mut TelevisionChannel> for Channel {
)
}
c @ TelevisionChannel::Files(_) => {
let entries = c.results(c.result_count(), 0);
let entries = if c.selected_entries().is_empty() {
c.results(c.result_count(), 0)
} else {
c.selected_entries().iter().cloned().collect()
};
Self::new(
entries
.iter()
Expand All @@ -55,7 +63,11 @@ impl From<&mut TelevisionChannel> for Channel {
)
}
c @ TelevisionChannel::Text(_) => {
let entries = c.results(c.result_count(), 0);
let entries = if c.selected_entries().is_empty() {
c.results(c.result_count(), 0)
} else {
c.selected_entries().iter().cloned().collect()
};
Self::new(
entries
.iter()
Expand Down
34 changes: 25 additions & 9 deletions crates/television-channels/src/channels/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,16 @@ impl From<&mut TelevisionChannel> for Channel {
fn from(value: &mut TelevisionChannel) -> Self {
match value {
c @ TelevisionChannel::Files(_) => {
let entries = c.results(
c.result_count().min(
u32::try_from(MAX_PIPED_FILES).unwrap_or(u32::MAX),
),
0,
);
let entries = if c.selected_entries().is_empty() {
c.results(
c.result_count().min(
u32::try_from(MAX_PIPED_FILES).unwrap_or(u32::MAX),
),
0,
)
} else {
c.selected_entries().iter().cloned().collect()
};
Self::from_file_paths(
entries
.iter()
Expand All @@ -140,7 +144,11 @@ impl From<&mut TelevisionChannel> for Channel {
)
}
c @ TelevisionChannel::GitRepos(_) => {
let entries = c.results(c.result_count(), 0);
let entries = if c.selected_entries().is_empty() {
c.results(c.result_count(), 0)
} else {
c.selected_entries().iter().cloned().collect()
};
Self::new(
entries
.iter()
Expand All @@ -151,11 +159,19 @@ impl From<&mut TelevisionChannel> for Channel {
)
}
c @ TelevisionChannel::Text(_) => {
let entries = c.results(c.result_count(), 0);
let entries = if c.selected_entries().is_empty() {
c.results(c.result_count(), 0)
} else {
c.selected_entries().iter().cloned().collect()
};
Self::from_text_entries(entries)
}
c @ TelevisionChannel::Dirs(_) => {
let entries = c.results(c.result_count(), 0);
let entries = if c.selected_entries().is_empty() {
c.results(c.result_count(), 0)
} else {
c.selected_entries().iter().cloned().collect()
};
Self::new(
entries
.iter()
Expand Down
Loading