Skip to content

Commit

Permalink
Merge pull request #1923 from kaloudis/channels-filters-online
Browse files Browse the repository at this point in the history
Channels: Filters: Online/Offline
  • Loading branch information
kaloudis authored Dec 28, 2023
2 parents 3c5ba98 + e859db2 commit 960c006
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
2 changes: 2 additions & 0 deletions components/Channels/FilterOptions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ export function FilterOptions(props: { ChannelsStore: ChannelsStore }) {
const getFilterOptions = (): FilterOption[] => {
const { ChannelsStore } = props;
const options: { [key: string]: any } = {
online: false,
offline: false,
announced: false,
unannounced: false
};
Expand Down
2 changes: 2 additions & 0 deletions locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,8 @@
"views.Wallet.Channels.private": "Private",
"views.Wallet.Channels.unannounced": "Unannounced",
"views.Wallet.Channels.announced": "Announced",
"views.Wallet.Channels.online": "Online",
"views.Wallet.Channels.offline": "Offline",
"views.Wallet.Channels.filters": "Filters",
"views.OpenChannel.announceChannel": "Announce channel",
"views.OpenChannel.scidAlias": "Attempt to use SCID alias",
Expand Down
13 changes: 11 additions & 2 deletions stores/ChannelsStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,12 +200,21 @@ export default class ChannelsStore {
?.toLocaleLowerCase()
.includes(query.toLocaleLowerCase())
)
.filter(
?.filter(
(channel: Channel) =>
this.filterOptions?.length === 0 ||
(!this.filterOptions?.includes('unannounced') &&
!this.filterOptions?.includes('announced')) ||
this.filterOptions?.includes(
channel.private ? 'unannounced' : 'announced'
)
)
.filter(
(channel: Channel) =>
(!this.filterOptions?.includes('online') &&
!this.filterOptions?.includes('offline')) ||
this.filterOptions?.includes(
channel.active ? 'online' : 'offline'
)
);
const sorted = filtered?.sort((a: any, b: any) => {
if (this.sort.type === 'numeric') {
Expand Down

0 comments on commit 960c006

Please sign in to comment.