mirror of
https://github.com/overte-org/overte.git
synced 2025-04-08 08:14:48 +02:00
add nextTick, and cleanup
This commit is contained in:
parent
f9debf1388
commit
b6ae0a5bde
3 changed files with 18 additions and 30 deletions
|
@ -34,7 +34,8 @@ Column {
|
|||
|
||||
property string metaverseServerUrl: '';
|
||||
property string actions: 'snapshot';
|
||||
Component.onCompleted: fillDestinations();
|
||||
// sendToScript doesn't get wired until after everything gets created. So we have to queue fillDestinations on nextTick.
|
||||
Component.onCompleted: delay.start();
|
||||
property string labelText: actions;
|
||||
property string filter: '';
|
||||
onFilterChanged: filterChoicesByText();
|
||||
|
@ -98,7 +99,7 @@ Column {
|
|||
function getUserStoryPage(pageNumber, cb, cb1) { // cb(error) after all pages of domain data have been added to model
|
||||
// If supplied, cb1 will be run after the first page IFF it is not the last, for responsiveness.
|
||||
var options = [
|
||||
//'now=' + new Date().toISOString(),
|
||||
'now=' + new Date().toISOString(),
|
||||
'include_actions=' + actions,
|
||||
'restriction=' + (Account.isLoggedIn() ? 'open,hifi' : 'open'),
|
||||
'require_online=true',
|
||||
|
@ -107,16 +108,10 @@ Column {
|
|||
];
|
||||
var url = metaverseBase + 'user_stories?' + options.join('&');
|
||||
var thisRequestId = ++requestId;
|
||||
rpc('request', {
|
||||
uri: url
|
||||
}, function (error, data) {
|
||||
console.log('fixme response', url, JSON.stringify(error), JSON.stringify(data));
|
||||
data.total_pages = 1; // fixme remove after testing
|
||||
rpc('request', url, function (error, data) {
|
||||
if (thisRequestId !== requestId) {
|
||||
error = 'stale';
|
||||
}
|
||||
//console.log('fixme', actions, pageNumber, thisRequestId, requestId, url, error)
|
||||
//console.log('fixme data', actions, pageNumber, JSON.stringify(data));
|
||||
if (handleError(url, error, data, cb)) {
|
||||
return; // abandon stale requests
|
||||
}
|
||||
|
@ -130,6 +125,10 @@ Column {
|
|||
cb();
|
||||
});
|
||||
}
|
||||
property var delay: Timer { // No setTimeout or nextTick in QML.
|
||||
interval: 0;
|
||||
onTriggered: fillDestinations();
|
||||
}
|
||||
function fillDestinations() { // Public
|
||||
function report(label, error) {
|
||||
console.log(label, actions, error || 'ok', allStories.length, 'filtered to', suggestions.count);
|
||||
|
@ -142,14 +141,14 @@ Column {
|
|||
allStories.slice(counter).forEach(filter);
|
||||
report('user stories update', error);
|
||||
root.visible = !!suggestions.count;
|
||||
}/*, function () { // If there's more than a page, put what we have in the model right away, keeping track of how many are processed.
|
||||
}, function () { // If there's more than a page, put what we have in the model right away, keeping track of how many are processed.
|
||||
allStories.forEach(function (story) {
|
||||
counter++;
|
||||
filter(story);
|
||||
root.visible = !!suggestions.count;
|
||||
});
|
||||
report('user stories');
|
||||
}*/);
|
||||
});
|
||||
}
|
||||
function identity(x) {
|
||||
return x;
|
||||
|
@ -160,7 +159,7 @@ Column {
|
|||
if (story.action === 'snapshot') {
|
||||
return true;
|
||||
}
|
||||
return true; // fixme restore (story.place_name !== AddressManager.placename); // Not our entry, but do show other entry points to current domain.
|
||||
return story.place_name !== AddressManager.placename; // Not our entry, but do show other entry points to current domain.
|
||||
}
|
||||
function matches(story) {
|
||||
if (!words.length) {
|
||||
|
|
|
@ -40,17 +40,11 @@ StackView {
|
|||
property var rpcCounter: 0;
|
||||
signal sendToScript(var message);
|
||||
function rpc(method, parameters, callback) {
|
||||
console.log('fixme rpc', method);
|
||||
sendToScript('foo');
|
||||
console.log('fixme sent to script');
|
||||
/*rpcCalls[rpcCounter] = callback;
|
||||
rpcCalls[rpcCounter] = callback;
|
||||
var message = {method: method, params: parameters, id: rpcCounter++, jsonrpc: "2.0"};
|
||||
console.log('fixme sending rpc', JSON.stringify(message));
|
||||
sendToScript(message);
|
||||
console.log('fixme sent rpc', message.id);*/
|
||||
}
|
||||
function fromScript(message) {
|
||||
console.log('fixme got message from script:', JSON.stringify(message));
|
||||
var callback = rpcCalls[message.id];
|
||||
if (!callback) {
|
||||
console.log('No callback for message fromScript', JSON.stringify(message));
|
||||
|
@ -78,7 +72,7 @@ StackView {
|
|||
}
|
||||
|
||||
|
||||
function resetAfterTeleport() {
|
||||
function resetAfterTeleport() {
|
||||
//storyCardFrame.shown = root.shown = false;
|
||||
}
|
||||
function goCard(targetString) {
|
||||
|
|
|
@ -78,9 +78,8 @@
|
|||
httpRequest.open(options.method, options.uri, true);
|
||||
httpRequest.send(options.body);
|
||||
}
|
||||
function fromQmlXX(message) {
|
||||
print('fixme got fromQml', JSON.stringify(message));
|
||||
/*var response = {id: message.id, jsonrpc: "2.0"};
|
||||
function fromQml(message) {
|
||||
var response = {id: message.id, jsonrpc: "2.0"};
|
||||
switch (message.method) {
|
||||
case 'request':
|
||||
request(message.params, function (error, data) {
|
||||
|
@ -92,7 +91,7 @@
|
|||
default:
|
||||
response.error = {message: 'Unrecognized message', data: message};
|
||||
}
|
||||
tablet.sendToQml(response);*/
|
||||
tablet.sendToQml(response);
|
||||
}
|
||||
function messagesWaiting(isWaiting) {
|
||||
button.editProperties({
|
||||
|
@ -102,21 +101,18 @@
|
|||
}
|
||||
var hasEventBridge = false;
|
||||
function wireEventBridge(on) {
|
||||
print('fixme wireEventBridge', on, hasEventBridge);
|
||||
if (on) {
|
||||
if (!hasEventBridge) {
|
||||
tablet.fromQml.connect(fromQmlXX);
|
||||
print('fixme wired', tablet);
|
||||
tablet.fromQml.connect(fromQml);
|
||||
hasEventBridge = true;
|
||||
}
|
||||
} else {
|
||||
if (hasEventBridge) {
|
||||
tablet.fromQml.disconnect(fromQmlXX);
|
||||
tablet.fromQml.disconnect(fromQml);
|
||||
hasEventBridge = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
wireEventBridge(true);
|
||||
|
||||
function onClicked() {
|
||||
if (onGotoScreen) {
|
||||
|
@ -169,7 +165,6 @@
|
|||
return;
|
||||
}
|
||||
var didNotify = false;
|
||||
print('fixme poll', url, JSON.stringify(data.user_stories));
|
||||
data.user_stories.forEach(function (story) {
|
||||
if (stories[story.id]) { // already seen
|
||||
return;
|
||||
|
|
Loading…
Reference in a new issue