Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
jaesivsm committed Jun 22, 2024
1 parent 30f6279 commit 6d2d53a
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 29 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ db-bootstrap-tables:
$(COMPOSE) exec $(DB_CONTAINER_NAME) psql -h 0.0.0.0 -U postgres -c "GRANT ALL PRIVILEGES ON DATABASE $(DB_NAME) to $(DB_NAME);"

db-import-dump:
docker cp $(DUMP) jarr_$(DB_CONTAINER_NAME)_1:/tmp/dump.pgsql
docker cp $(DUMP) $(shell docker ps -q -f name=$(DB_CONTAINER_NAME)):/tmp/dump.pgsql
$(COMPOSE) exec $(DB_CONTAINER_NAME) su postgres -c "pg_restore -d $(DB_NAME) /tmp/dump.pgsql"
$(COMPOSE) exec $(DB_CONTAINER_NAME) rm /tmp/dump.pgsql

Expand Down
3 changes: 2 additions & 1 deletion jsclient/src/features/feedlist/FeedList.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,15 @@ import feedListStyle from "./feedListStyle";
import FeedRow from "./FeedRow";
import { toggleAllFolding, toggleMenu,
setSearchFilter,
filterFeedRows,
} from "./slice";
import { openPanel } from "../editpanel/slice";
import { feedListWidth } from "../../const";
import doFetchUnreadCount from "../../hooks/doFetchUnreadCount";
import doFetchFeeds from "../../hooks/doFetchFeeds";

function mapStateToProps(state) {
return { itemCount: state.feeds.feedListRows.filter(state.feeds.feedListFilter).length,
return { itemCount: filterFeedRows(state.feeds.feedListRows, state.feeds.searchTerm).length,
isFoldedFromParent: state.feeds.isParentFolded,
isFeedListOpen: state.feeds.isOpen,
isEditPanelOpen: state.edit.isOpen,
Expand Down
4 changes: 2 additions & 2 deletions jsclient/src/features/feedlist/FeedRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ import ExpandLess from "@mui/icons-material/ExpandLess";
import ExpandMore from "@mui/icons-material/ExpandMore";
// jarr
import doListClusters from "../../hooks/doListClusters";
import { toggleMenu, toggleFolding } from "./slice";
import { toggleMenu, toggleFolding, filterFeedRows } from "./slice";
import feedListStyle from "./feedListStyle";
import FeedIcon from "../../components/FeedIcon";

function mapStateToProps(state) {
return { feedListRows: state.feeds.feedListRows.filter(state.feeds.feedListFilter),
return { feedListRows: filterFeedRows(state.feeds.feedListRows, state.feeds.searchTerm),
isFoldedFromParent: state.feeds.isParentFolded,
selectedCategoryId: state.clusters.filters["category_id"],
selectedFeedId: state.clusters.filters["feed_id"],
Expand Down
56 changes: 31 additions & 25 deletions jsclient/src/features/feedlist/slice.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,41 +23,42 @@ function mergeCategoriesWithUnreads(feedListRows, unreads,
}).sort((row1, row2) => (row1.index - row2.index));
}

const defaultFilter = (row) => ( // will display row if
!row.folded // row is not folded
|| row.type === "categ" // row is a category (can't be folded)
|| row.type === "all-categ" // row is the "all categ" category (idem)
// row is a feed without category (idem)
|| (row.type === "feed" && row["category_id"] === null)
);
export const filterFeedRows = (rows, searchTerm) => {
const defaultFilter = (row) => ( // will display row if
!row.folded // row is not folded
|| row.type === "categ" // row is a category (can't be folded)
|| row.type === "all-categ" // row is the "all categ" category (idem)
// row is a feed without category (idem)
|| (row.type === "feed" && row["category_id"] === null)
);
const searchTermFilter = (row) => (
row.type !== "categ" && row.type !== "all-categ"
&& row.str.toLowerCase().includes(searchTerm)
);
if (searchTerm) {
return rows.filter(searchTermFilter);
} else {
return rows.filter(defaultFilter);
}
};

const feedSlice = createSlice({
name: "feeds",
initialState: { loadingFeeds: false,
loadingUnreadCounts: false,
unreadToFetch: true,
feedListRows: [],
searchTerm: null,
unreads: {},
isParentFolded: storageGet("left-menu-folded", "session") === "true",
isOpen: triboolMapping[storageGet("left-menu-open", "session")],
feedListFilter: defaultFilter,
icons: {},
categoryAsFeed: {},
},
reducers: {
requestedFeeds: (state, action) => ({ ...state, loadingFeeds: true }),
requestedUnreadCounts: (state, action) => ({ ...state, loadingUnreadCounts: true }),
setSearchFilter: (state, action) => {
if (!action.payload) {
return { ...state, feedListFilter: defaultFilter, };
}
const feedSearchStr = action.payload.toLowerCase();
return { ...state,
feedListFilter: (row) => (
row.type !== "categ" && row.type !== "all-categ"
&& row.str.toLowerCase().includes(feedSearchStr)
),
};
},
setSearchFilter: (state, action) => ({ ...state, searchTerm: action.payload }),
toggleAllFolding: (state, action) => {
const newFolding = !state.isParentFolded;
storageSet("left-menu-folded", newFolding, "session");
Expand Down Expand Up @@ -143,10 +144,15 @@ const feedSlice = createSlice({
},
});

export const { requestedFeeds, loadedFeeds,
requestedUnreadCounts, loadedUnreadCounts,
toggleMenu, toggleAllFolding, toggleFolding,
setSearchFilter,
changeReadCount,
export const {
changeReadCount,
loadedFeeds,
loadedUnreadCounts,
requestedFeeds,
requestedUnreadCounts,
setSearchFilter,
toggleAllFolding,
toggleFolding,
toggleMenu,
} = feedSlice.actions;
export default feedSlice.reducer;

0 comments on commit 6d2d53a

Please sign in to comment.