Add fixes for stream service get parametrs.

pull/98/head
Andrey Dolgolev 2021-08-12 19:43:14 +03:00
rodzic 309e510598
commit 86263290b4
2 zmienionych plików z 46 dodań i 22 usunięć

Wyświetl plik

@ -80,8 +80,8 @@ const EntriesNavigation = () => {
const loadMoreButtonRef = useRef(null);
const [streamBoundary, setStreamBoundary] = useState({
start_time: 0,
end_time: 0,
start_time: null,
end_time: null,
include_start: false,
include_end: true,
next_event_time: null,
@ -174,12 +174,6 @@ const EntriesNavigation = () => {
// }
// };
useEffect(() => {
if (!streamBoundary.start_time && !streamBoundary.end_time) {
refetch();
}
}, [streamBoundary]);
const setFilterProps = useCallback(
(filterIdx, props) => {
const newFilterProps = [...newFilterState];
@ -514,8 +508,8 @@ const EntriesNavigation = () => {
onClick={() => {
remove();
setStreamBoundary({
start_time: 0,
end_time: 0,
start_time: null,
end_time: null,
include_start: false,
include_end: true,
next_event_time: null,
@ -557,7 +551,7 @@ const EntriesNavigation = () => {
)}
</Stack>
{entries
?.sort((a, b) => b.timestamp - a.timestamp)
?.sort((a, b) => b.timestamp - a.timestamp) // TODO(Andrey) improve that for bi chunks of data sorting can take time
.map((entry, idx) => (
<StreamEntry
key={`entry-list-${idx}`}
@ -586,9 +580,20 @@ const EntriesNavigation = () => {
</Button>
</Center>
) : (
""
<Center>
{!isFetching ? (
"Тransactions not found. You can subscribe to more addresses in Subscriptions menu."
) : (
<Button
isLoading
loadingText="Loading"
variant="outline"
colorScheme="suggested"
></Button>
)}
</Center>
)}
{streamBoundary.previous_event_time && isLoading && (
{streamBoundary.previous_event_time && isLoading ? (
<Center>
<Spinner
//hidden={!isFetchingMore}
@ -600,6 +605,8 @@ const EntriesNavigation = () => {
speed="1.5s"
/>
</Center>
) : (
""
)}
</Flex>
</Flex>

Wyświetl plik

@ -9,15 +9,32 @@ export const getStream = ({
end_time,
include_start,
include_end,
}) =>
http({
}) => {
let params = {};
if (searchTerm) {
params.q = encodeURIComponent(searchTerm);
}
if (start_time) {
params.start_time = encodeURIComponent(start_time);
}
if (end_time) {
params.end_time = encodeURIComponent(end_time);
}
if (include_start) {
params.include_start = encodeURIComponent(true);
}
if (include_end) {
params.include_end = encodeURIComponent(true);
}
return http({
method: "GET",
url: `${API}/streams/`,
params: {
q: searchTerm,
start_time: encodeURIComponent(start_time),
end_time: encodeURIComponent(end_time),
include_start: encodeURIComponent(include_start),
include_end: encodeURIComponent(include_end),
},
params: params,
});
};