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

Feature/202106 fetch after trash #393

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { ArchiveAction } from "../../../contexts/archive-context";
import useGlobalSettings from "../../../hooks/use-global-settings";
import useLocation from "../../../hooks/use-location";
import { IArchiveProps } from "../../../interfaces/IArchiveProps";
import FetchGet from "../../../shared/fetch-get";
import FetchPost from "../../../shared/fetch-post";
import { Language } from "../../../shared/language";
import { ClearSearchCache } from "../../../shared/search/clear-search-cache";
Expand Down Expand Up @@ -76,6 +77,13 @@ const ModalForceDelete: React.FunctionComponent<IModalForceDeleteProps> = ({
).then((result) => {
if (result.statusCode === 200 || result.statusCode === 404) {
dispatch({ type: "remove", toRemoveFileList: toUndoTrashList });

if (state.pageNumber === 1) {
const url = new UrlQuery().UrlSearchTrashApi(state.pageNumber);
FetchGet(url).then((result) => {
console.log(result);
});
}
}

ClearSearchCache(history.location.search);
Expand Down
8 changes: 8 additions & 0 deletions starsky/starsky/clientapp/src/hooks/use-fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ const useFetch = (url: string, method: "get" | "post"): IConnectionDefault => {
return data;
};

/**
* From useFetch internal
* @param url - where to look for
* @param method - GET, POST
* @param mounted - is the component mounted
* @param abortController - cancel request
* @param setData - where to set the date when received
*/
export const fetchContent = async (
url: string,
method: "get" | "post",
Expand Down
6 changes: 6 additions & 0 deletions starsky/starsky/clientapp/src/hooks/use-filelist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ const useFileList = (
const [parent, setParent] = useState("/");
const location = new UrlQuery().UrlQueryServerApi(locationSearch);

/**
* fetchContent inside useFileList
* @param locationLocal url
* @param abortController how to abort
* @returns promise with no content
*/
const fetchContent = async (
locationLocal: string,
abortController: AbortController
Expand Down
13 changes: 13 additions & 0 deletions starsky/starsky/clientapp/src/hooks/use-searchlist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ const setErrorPageType = (
return false;
};

/**
* Search Query
* @param query - where to search for
* @param pageNumber - pagenumber starts with 1
* @param resetPageTypeBeforeLoading - add loading icon on startup
* @returns - promise with void
*/
const useSearchList = (
query: string | undefined,
pageNumber: number | undefined,
Expand All @@ -58,6 +65,12 @@ const useSearchList = (
? new UrlQuery().UrlQuerySearchApi(query, pageNumber)
: undefined;

/**
* From SearchList to fetch trash and search content
* @param locationScoped - url
* @param abortController - how to cancel
* @returns emthy promise
*/
const fetchContent = async (
locationScoped: string | undefined,
abortController: AbortController
Expand Down