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

Channels: sort by close height #1672

Merged
merged 2 commits into from
Sep 21, 2023
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
2 changes: 1 addition & 1 deletion views/Channels/Channel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ export default class ChannelView extends React.Component<
sensitive
/>
)}
{closeHeight && (
{!!closeHeight && (
<KeyValue
keyValue={localeString(
'views.Channel.closeHeight'
Expand Down
164 changes: 96 additions & 68 deletions views/Channels/ChannelsPane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,72 +40,97 @@ interface ChannelsProps {
@inject('ChannelsStore', 'SettingsStore')
@observer
export default class ChannelsPane extends React.PureComponent<ChannelsProps> {
private getChannelsSortKeys = () => [
{
key: `${localeString('views.Channel.capacity')} (${localeString(
'views.Channel.SortButton.largestFirst'
)})`,
value: {
param: 'channelCapacity',
dir: 'DESC',
type: 'numeric'
}
},
{
key: `${localeString('views.Channel.capacity')} (${localeString(
'views.Channel.SortButton.smallestFirst'
)})`,
value: { param: 'channelCapacity', dir: 'ASC', type: 'numeric' }
},
{
key: `${localeString(
'views.Channel.inboundCapacity'
)} (${localeString('views.Channel.SortButton.largestFirst')})`,
value: { param: 'remoteBalance', dir: 'DESC', type: 'numeric' }
},
{
key: `${localeString(
'views.Channel.inboundCapacity'
)} (${localeString('views.Channel.SortButton.smallestFirst')})`,
value: { param: 'remoteBalance', dir: 'ASC', type: 'numeric' }
},
{
key: `${localeString(
'views.Channel.outboundCapacity'
)} (${localeString('views.Channel.SortButton.largestFirst')})`,
value: { param: 'localBalance', dir: 'DESC', type: 'numeric' }
},
{
key: `${localeString(
'views.Channel.outboundCapacity'
)} (${localeString('views.Channel.SortButton.smallestFirst')})`,
value: { param: 'localBalance', dir: 'ASC', type: 'numeric' }
},
{
key: `${localeString('views.Channel.displayName')} (${localeString(
'views.Channel.SortButton.ascending'
)})`,
value: { param: 'displayName', dir: 'ASC', type: 'alphanumeric' }
},
{
key: `${localeString('views.Channel.displayName')} (${localeString(
'views.Channel.SortButton.descending'
)})`,
value: { param: 'displayName', dir: 'DESC', type: 'alphanumeric' }
private getChannelsSortKeys = (closed?: boolean) => {
const sortKeys = [];

if (closed) {
sortKeys.push(
{
key: `${localeString(
'views.Channel.closeHeight'
)} (${localeString('views.Channel.SortButton.ascending')})`,
value: { param: 'closeHeight', dir: 'ASC', type: 'numeric' }
},
{
key: `${localeString(
'views.Channel.closeHeight'
)} (${localeString(
'views.Channel.SortButton.descending'
)})`,
value: {
param: 'closeHeight',
dir: 'DESC',
type: 'numeric'
}
}
);
}
// {
// key: `${localeString('views.Channel.channelId')} (${localeString(
// 'views.Channel.SortButton.ascending'
// )})`,
// value: { param: 'channelId', dir: 'ASC', type: 'alphanumeric' }
// },
// {
// key: `${localeString('views.Channel.channelId')} (${localeString(
// 'views.Channel.SortButton.descending'
// )})`,
// value: { param: 'channelId', dir: 'DESC', type: 'alphanumeric' }
// }
];

sortKeys.push(
{
key: `${localeString('views.Channel.capacity')} (${localeString(
'views.Channel.SortButton.largestFirst'
)})`,
value: {
param: 'channelCapacity',
dir: 'DESC',
type: 'numeric'
}
},
{
key: `${localeString('views.Channel.capacity')} (${localeString(
'views.Channel.SortButton.smallestFirst'
)})`,
value: { param: 'channelCapacity', dir: 'ASC', type: 'numeric' }
},
{
key: `${localeString(
'views.Channel.inboundCapacity'
)} (${localeString('views.Channel.SortButton.largestFirst')})`,
value: { param: 'remoteBalance', dir: 'DESC', type: 'numeric' }
},
{
key: `${localeString(
'views.Channel.inboundCapacity'
)} (${localeString('views.Channel.SortButton.smallestFirst')})`,
value: { param: 'remoteBalance', dir: 'ASC', type: 'numeric' }
},
{
key: `${localeString(
'views.Channel.outboundCapacity'
)} (${localeString('views.Channel.SortButton.largestFirst')})`,
value: { param: 'localBalance', dir: 'DESC', type: 'numeric' }
},
{
key: `${localeString(
'views.Channel.outboundCapacity'
)} (${localeString('views.Channel.SortButton.smallestFirst')})`,
value: { param: 'localBalance', dir: 'ASC', type: 'numeric' }
},
{
key: `${localeString(
'views.Channel.displayName'
)} (${localeString('views.Channel.SortButton.ascending')})`,
value: {
param: 'displayName',
dir: 'ASC',
type: 'alphanumeric'
}
},
{
key: `${localeString(
'views.Channel.displayName'
)} (${localeString('views.Channel.SortButton.descending')})`,
value: {
param: 'displayName',
dir: 'DESC',
type: 'alphanumeric'
}
}
);

return sortKeys;
};

renderItem = ({ item }) => {
const { ChannelsStore, navigation } = this.props;
Expand Down Expand Up @@ -196,7 +221,6 @@ export default class ChannelsPane extends React.PureComponent<ChannelsProps> {

render() {
const { ChannelsStore, SettingsStore, navigation } = this.props;
const { channelsType, search } = ChannelsStore;
const {
loading,
getChannels,
Expand All @@ -207,7 +231,9 @@ export default class ChannelsPane extends React.PureComponent<ChannelsProps> {
filteredPendingChannels,
filteredClosedChannels,
setSort,
showSearch
showSearch,
channelsType,
search
} = ChannelsStore;

const lurkerMode: boolean =
Expand Down Expand Up @@ -287,7 +313,9 @@ export default class ChannelsPane extends React.PureComponent<ChannelsProps> {
onValueChange={(value: any) => {
setSort(value);
}}
values={this.getChannelsSortKeys()}
values={this.getChannelsSortKeys(
channelsType === ChannelsType.Closed
)}
/>
</Row>
<FilterOptions ChannelsStore={ChannelsStore} />
Expand Down