mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01: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 metaverseServerUrl: '';
|
||||||
property string actions: 'snapshot';
|
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 labelText: actions;
|
||||||
property string filter: '';
|
property string filter: '';
|
||||||
onFilterChanged: filterChoicesByText();
|
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
|
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.
|
// If supplied, cb1 will be run after the first page IFF it is not the last, for responsiveness.
|
||||||
var options = [
|
var options = [
|
||||||
//'now=' + new Date().toISOString(),
|
'now=' + new Date().toISOString(),
|
||||||
'include_actions=' + actions,
|
'include_actions=' + actions,
|
||||||
'restriction=' + (Account.isLoggedIn() ? 'open,hifi' : 'open'),
|
'restriction=' + (Account.isLoggedIn() ? 'open,hifi' : 'open'),
|
||||||
'require_online=true',
|
'require_online=true',
|
||||||
|
@ -107,16 +108,10 @@ Column {
|
||||||
];
|
];
|
||||||
var url = metaverseBase + 'user_stories?' + options.join('&');
|
var url = metaverseBase + 'user_stories?' + options.join('&');
|
||||||
var thisRequestId = ++requestId;
|
var thisRequestId = ++requestId;
|
||||||
rpc('request', {
|
rpc('request', url, function (error, data) {
|
||||||
uri: url
|
|
||||||
}, function (error, data) {
|
|
||||||
console.log('fixme response', url, JSON.stringify(error), JSON.stringify(data));
|
|
||||||
data.total_pages = 1; // fixme remove after testing
|
|
||||||
if (thisRequestId !== requestId) {
|
if (thisRequestId !== requestId) {
|
||||||
error = 'stale';
|
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)) {
|
if (handleError(url, error, data, cb)) {
|
||||||
return; // abandon stale requests
|
return; // abandon stale requests
|
||||||
}
|
}
|
||||||
|
@ -130,6 +125,10 @@ Column {
|
||||||
cb();
|
cb();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
property var delay: Timer { // No setTimeout or nextTick in QML.
|
||||||
|
interval: 0;
|
||||||
|
onTriggered: fillDestinations();
|
||||||
|
}
|
||||||
function fillDestinations() { // Public
|
function fillDestinations() { // Public
|
||||||
function report(label, error) {
|
function report(label, error) {
|
||||||
console.log(label, actions, error || 'ok', allStories.length, 'filtered to', suggestions.count);
|
console.log(label, actions, error || 'ok', allStories.length, 'filtered to', suggestions.count);
|
||||||
|
@ -142,14 +141,14 @@ Column {
|
||||||
allStories.slice(counter).forEach(filter);
|
allStories.slice(counter).forEach(filter);
|
||||||
report('user stories update', error);
|
report('user stories update', error);
|
||||||
root.visible = !!suggestions.count;
|
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) {
|
allStories.forEach(function (story) {
|
||||||
counter++;
|
counter++;
|
||||||
filter(story);
|
filter(story);
|
||||||
root.visible = !!suggestions.count;
|
root.visible = !!suggestions.count;
|
||||||
});
|
});
|
||||||
report('user stories');
|
report('user stories');
|
||||||
}*/);
|
});
|
||||||
}
|
}
|
||||||
function identity(x) {
|
function identity(x) {
|
||||||
return x;
|
return x;
|
||||||
|
@ -160,7 +159,7 @@ Column {
|
||||||
if (story.action === 'snapshot') {
|
if (story.action === 'snapshot') {
|
||||||
return true;
|
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) {
|
function matches(story) {
|
||||||
if (!words.length) {
|
if (!words.length) {
|
||||||
|
|
|
@ -40,17 +40,11 @@ StackView {
|
||||||
property var rpcCounter: 0;
|
property var rpcCounter: 0;
|
||||||
signal sendToScript(var message);
|
signal sendToScript(var message);
|
||||||
function rpc(method, parameters, callback) {
|
function rpc(method, parameters, callback) {
|
||||||
console.log('fixme rpc', method);
|
rpcCalls[rpcCounter] = callback;
|
||||||
sendToScript('foo');
|
|
||||||
console.log('fixme sent to script');
|
|
||||||
/*rpcCalls[rpcCounter] = callback;
|
|
||||||
var message = {method: method, params: parameters, id: rpcCounter++, jsonrpc: "2.0"};
|
var message = {method: method, params: parameters, id: rpcCounter++, jsonrpc: "2.0"};
|
||||||
console.log('fixme sending rpc', JSON.stringify(message));
|
|
||||||
sendToScript(message);
|
sendToScript(message);
|
||||||
console.log('fixme sent rpc', message.id);*/
|
|
||||||
}
|
}
|
||||||
function fromScript(message) {
|
function fromScript(message) {
|
||||||
console.log('fixme got message from script:', JSON.stringify(message));
|
|
||||||
var callback = rpcCalls[message.id];
|
var callback = rpcCalls[message.id];
|
||||||
if (!callback) {
|
if (!callback) {
|
||||||
console.log('No callback for message fromScript', JSON.stringify(message));
|
console.log('No callback for message fromScript', JSON.stringify(message));
|
||||||
|
@ -78,7 +72,7 @@ StackView {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function resetAfterTeleport() {
|
function resetAfterTeleport() {
|
||||||
//storyCardFrame.shown = root.shown = false;
|
//storyCardFrame.shown = root.shown = false;
|
||||||
}
|
}
|
||||||
function goCard(targetString) {
|
function goCard(targetString) {
|
||||||
|
|
|
@ -78,9 +78,8 @@
|
||||||
httpRequest.open(options.method, options.uri, true);
|
httpRequest.open(options.method, options.uri, true);
|
||||||
httpRequest.send(options.body);
|
httpRequest.send(options.body);
|
||||||
}
|
}
|
||||||
function fromQmlXX(message) {
|
function fromQml(message) {
|
||||||
print('fixme got fromQml', JSON.stringify(message));
|
var response = {id: message.id, jsonrpc: "2.0"};
|
||||||
/*var response = {id: message.id, jsonrpc: "2.0"};
|
|
||||||
switch (message.method) {
|
switch (message.method) {
|
||||||
case 'request':
|
case 'request':
|
||||||
request(message.params, function (error, data) {
|
request(message.params, function (error, data) {
|
||||||
|
@ -92,7 +91,7 @@
|
||||||
default:
|
default:
|
||||||
response.error = {message: 'Unrecognized message', data: message};
|
response.error = {message: 'Unrecognized message', data: message};
|
||||||
}
|
}
|
||||||
tablet.sendToQml(response);*/
|
tablet.sendToQml(response);
|
||||||
}
|
}
|
||||||
function messagesWaiting(isWaiting) {
|
function messagesWaiting(isWaiting) {
|
||||||
button.editProperties({
|
button.editProperties({
|
||||||
|
@ -102,21 +101,18 @@
|
||||||
}
|
}
|
||||||
var hasEventBridge = false;
|
var hasEventBridge = false;
|
||||||
function wireEventBridge(on) {
|
function wireEventBridge(on) {
|
||||||
print('fixme wireEventBridge', on, hasEventBridge);
|
|
||||||
if (on) {
|
if (on) {
|
||||||
if (!hasEventBridge) {
|
if (!hasEventBridge) {
|
||||||
tablet.fromQml.connect(fromQmlXX);
|
tablet.fromQml.connect(fromQml);
|
||||||
print('fixme wired', tablet);
|
|
||||||
hasEventBridge = true;
|
hasEventBridge = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (hasEventBridge) {
|
if (hasEventBridge) {
|
||||||
tablet.fromQml.disconnect(fromQmlXX);
|
tablet.fromQml.disconnect(fromQml);
|
||||||
hasEventBridge = false;
|
hasEventBridge = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
wireEventBridge(true);
|
|
||||||
|
|
||||||
function onClicked() {
|
function onClicked() {
|
||||||
if (onGotoScreen) {
|
if (onGotoScreen) {
|
||||||
|
@ -169,7 +165,6 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var didNotify = false;
|
var didNotify = false;
|
||||||
print('fixme poll', url, JSON.stringify(data.user_stories));
|
|
||||||
data.user_stories.forEach(function (story) {
|
data.user_stories.forEach(function (story) {
|
||||||
if (stories[story.id]) { // already seen
|
if (stories[story.id]) { // already seen
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in a new issue