(ui): update boards list queries to only use sort params for list, and make sure archived boards are included in most places we are searching

This commit is contained in:
Mary Hipp
2024-10-11 13:52:52 -04:00
committed by Mary Hipp Rogers
parent 9933cdb6b7
commit 8d44363d49
9 changed files with 38 additions and 16 deletions

View File

@@ -44,10 +44,9 @@ export const checkImageAccess = async (name: string): Promise<boolean> => {
* @returns A promise that resolves to true if the client has access, else false.
*/
export const checkBoardAccess = async (id: string): Promise<boolean> => {
const { dispatch, getState } = getStore();
const { dispatch } = getStore();
try {
const queryArgs = selectListBoardsQueryArgs(getState());
const req = dispatch(boardsApi.endpoints.listAllBoards.initiate(queryArgs));
const req = dispatch(boardsApi.endpoints.listAllBoards.initiate({include_archived: true}));
req.unsubscribe();
const result = await req.unwrap();
return result.some((b) => b.board_id === id);

View File

@@ -1,12 +1,9 @@
import { useAppSelector } from 'app/store/storeHooks';
import { selectListBoardsQueryArgs } from 'features/gallery/store/gallerySelectors';
import type { BoardId } from 'features/gallery/store/types';
import { t } from 'i18next';
import { useListAllBoardsQuery } from 'services/api/endpoints/boards';
export const useBoardName = (board_id: BoardId) => {
const queryArgs = useAppSelector(selectListBoardsQueryArgs);
const { boardName } = useListAllBoardsQuery(queryArgs, {
const { boardName } = useListAllBoardsQuery({include_archived: true}, {
selectFromResult: ({ data }) => {
const selectedBoard = data?.find((b) => b.board_id === board_id);
const boardName = selectedBoard?.board_name || t('boards.uncategorized');

View File

@@ -2033,6 +2033,12 @@ export type components = {
*/
board_id: string;
};
/**
* BoardRecordOrderBy
* @description The order by options for board records
* @enum {string}
*/
BoardRecordOrderBy: "created_at" | "board_name";
/** Body_add_image_to_board */
Body_add_image_to_board: {
/**
@@ -18884,6 +18890,10 @@ export interface operations {
list_boards: {
parameters: {
query?: {
/** @description The attribute to order by */
order_by?: components["schemas"]["BoardRecordOrderBy"];
/** @description The direction to order by */
direction?: components["schemas"]["SQLiteDirection"];
/** @description Whether to list all boards */
all?: boolean | null;
/** @description The page offset */

View File

@@ -241,3 +241,5 @@ export type PostUploadAction =
| RGIPAdapterImagePostUploadAction
| UpscaleInitialImageAction
| ReplaceLayerWithImagePostUploadAction;
export type BoardRecordOrderBy = S["BoardRecordOrderBy"]