mirror of
https://github.com/aljazceru/rabbit.git
synced 2025-12-18 14:34:25 +01:00
fix: prevent oneose from being called twice
This commit is contained in:
@@ -48,6 +48,9 @@ const FollowingColumn: Component<FollowingColumnDisplayProps> = (props) => {
|
|||||||
],
|
],
|
||||||
eoseLimit: 20,
|
eoseLimit: 20,
|
||||||
continuous: loadMore.continuous(),
|
continuous: loadMore.continuous(),
|
||||||
|
onEOSE: () => {
|
||||||
|
console.log('home: eose');
|
||||||
|
},
|
||||||
clientEventFilter: (event) => {
|
clientEventFilter: (event) => {
|
||||||
if (props.column.contentFilter == null) return true;
|
if (props.column.contentFilter == null) return true;
|
||||||
return applyContentFilter(props.column.contentFilter)(event.content);
|
return applyContentFilter(props.column.contentFilter)(event.content);
|
||||||
|
|||||||
@@ -138,12 +138,16 @@ const useSubscription = (propsProvider: () => UseSubscriptionProps | null) => {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
oneose: () => {
|
oneose: () => {
|
||||||
|
// sometimes `oneose` called twice
|
||||||
|
if (eose()) return;
|
||||||
|
|
||||||
if (onEOSE != null) {
|
if (onEOSE != null) {
|
||||||
onEOSE();
|
onEOSE();
|
||||||
}
|
}
|
||||||
|
|
||||||
setEose(true);
|
setEose(true);
|
||||||
updateEvents();
|
updateEvents();
|
||||||
|
storedEvents.splice(0, storedEvents.length);
|
||||||
|
|
||||||
if (!continuous) {
|
if (!continuous) {
|
||||||
sub.close();
|
sub.close();
|
||||||
@@ -157,20 +161,15 @@ const useSubscription = (propsProvider: () => UseSubscriptionProps | null) => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// avoid updating an array too rapidly while this is fetching stored events
|
// avoid updating an array too rapidly while this is fetching stored events
|
||||||
let updating = false;
|
|
||||||
const intervalId = setInterval(() => {
|
const intervalId = setInterval(() => {
|
||||||
if (updating) return;
|
|
||||||
updating = true;
|
|
||||||
if (eose()) {
|
if (eose()) {
|
||||||
clearInterval(intervalId);
|
clearInterval(intervalId);
|
||||||
updating = false;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (pushed) {
|
if (pushed) {
|
||||||
pushed = false;
|
pushed = false;
|
||||||
updateEvents();
|
updateEvents();
|
||||||
}
|
}
|
||||||
updating = false;
|
|
||||||
}, 100);
|
}, 100);
|
||||||
|
|
||||||
onCleanup(() => {
|
onCleanup(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user