Skip to content

Commit

Permalink
Fixed excessive events sending from Qt to js side (#471)
Browse files Browse the repository at this point in the history
  • Loading branch information
vkjr authored Apr 18, 2019
1 parent a3330f3 commit 99e9bdc
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions ReactQt/runtime/src/rootview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class RootViewPrivate : public QObject {
RootView* q_ptr;
bool remoteJSDebugging = false;
QNetworkReply* liveReloadUrlReply = nullptr;
QSet<ulong> m_processedEvents;

RootViewPrivate(RootView* q) : q_ptr(q) {}

Expand Down Expand Up @@ -330,13 +331,20 @@ void RootView::componentComplete() {
void RootView::sendMouseEvent(QMouseEvent* event, const QString& eventType, QQuickItem* receiver) {
Q_D(RootView);

if (d->m_processedEvents.contains(event->timestamp())) {
return;
} else {
d->m_processedEvents.clear();
}

QVariantMap e = makeReactTouchEvent(receiver, event);
if (e.isEmpty())
return;

d->bridge->enqueueJSCall("RCTEventEmitter",
"receiveTouches",
QVariantList{normalizeInputEventName(eventType), QVariantList{e}, QVariantList{0}});
d->m_processedEvents.insert(event->timestamp());
event->setAccepted(true);
}

Expand Down

0 comments on commit 99e9bdc

Please sign in to comment.