🪛 WIP on the DCPP search results
This commit is contained in:
@@ -8,6 +8,8 @@ import {
|
||||
import {
|
||||
AIRDCPP_SEARCH_INSTANCE_CREATED,
|
||||
AIRDCPP_SEARCH_RESULTS_RECEIVED,
|
||||
AIRDCPP_HUB_SEARCHES_SENT,
|
||||
AIRDCPP_HUB_USER_CONNECTED,
|
||||
} from "../constants/action-types";
|
||||
|
||||
interface SearchData {
|
||||
@@ -21,16 +23,28 @@ function sleep(ms: number): Promise<NodeJS.Timeout> {
|
||||
}
|
||||
|
||||
export const search = (data: SearchData) => async (dispatch) => {
|
||||
await SocketService.connect("admin", "password");
|
||||
await sleep(10000);
|
||||
await SocketService.connect("admin", "password", true);
|
||||
const instance: SearchInstance = await SocketService.post("search");
|
||||
|
||||
SocketService.addListener(
|
||||
`search/${instance.id}`,
|
||||
"search_hub_searches_sent",
|
||||
async (searchInfo) => {
|
||||
console.log("As", searchInfo)
|
||||
// Collect the results for 5 seconds before fetching them
|
||||
dispatch({
|
||||
type: AIRDCPP_HUB_SEARCHES_SENT,
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
await SocketService.post<SearchResponse>(
|
||||
`search/${instance.id}/hub_search`,
|
||||
data,
|
||||
);
|
||||
|
||||
await sleep(10000);
|
||||
const results = await SocketService.get(`search/${instance.id}/results/0/25`);
|
||||
console.log("results", results);
|
||||
dispatch({
|
||||
type: AIRDCPP_SEARCH_RESULTS_RECEIVED,
|
||||
results,
|
||||
|
||||
Reference in New Issue
Block a user