stop using Gun.chain.map; monitor game list changes manually
This commit is contained in:
parent
f184df6447
commit
8e639a68eb
|
|
@ -796,8 +796,7 @@ $(function (){
|
|||
}
|
||||
|
||||
window.setTimeout(function(){
|
||||
gun.get(PacoSakoUUID).get('meta').map().on(function(d,key){
|
||||
if (key.match(/^[0-9a-f]{16}$/)) {
|
||||
function updateSelectMeta(d, key) {
|
||||
d = d || {};
|
||||
debug('got meta for key ' + key, d);
|
||||
const lightName = shortenName(String(d.lightName || 'Light'));
|
||||
|
|
@ -849,7 +848,26 @@ $(function (){
|
|||
$('#cb_select_game')[0].selectedIndex = -1;
|
||||
}
|
||||
}
|
||||
|
||||
let cancellers = {};
|
||||
let cancelAll = gun.get(PacoSakoUUID).get('meta').onWithCancel(function(meta) {
|
||||
for (const gameId in meta) { /* use of 'in' here is deliberate */
|
||||
/* 'gameId' may include extra GUN fields like '_' */
|
||||
if (gameId.match(/^[0-9a-f]{16}$/)) {
|
||||
if (!Gun.obj.is(meta[gameId])) {
|
||||
updateSelectMeta(null, gameId);
|
||||
if (gameId in cancellers) {
|
||||
cancellers[gameId]();
|
||||
delete cancellers[gameId];
|
||||
}
|
||||
} else if (!(gameId in cancellers)) {
|
||||
cancellers[gameId] = gun.get(meta[gameId]).onWithCancel(function(d) {
|
||||
updateSelectMeta(d, gameId);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}, { change: true });
|
||||
}, 1);
|
||||
|
||||
window.setInterval(function(){
|
||||
|
|
|
|||
Loading…
Reference in New Issue