Improved state conservation in pages.meet
This commit is contained in:
parent
7dabf832b6
commit
870c52c7bf
|
@ -1,5 +1,8 @@
|
|||
app.pages.meet = {
|
||||
data: [],
|
||||
dataCurrent: function() {
|
||||
return app.pages.meet.data[app.pages.meet.carousel._current];
|
||||
},
|
||||
isActive: function() { return (window.location.hash+'/').startsWith('#meet/') },
|
||||
load: function(args) {
|
||||
document.querySelector('#page-meet').removeAttribute('style');
|
||||
|
@ -25,8 +28,8 @@ app.pages.meet = {
|
|||
},
|
||||
_paintInterval: false,
|
||||
paintInterval: function() {
|
||||
if (app.pages.meet.data._paintInterval) return;
|
||||
app.pages.meet.data._paintInterval = true;
|
||||
if (app.pages.meet._paintInterval) return;
|
||||
app.pages.meet._paintInterval = true;
|
||||
setInterval(function() {
|
||||
if (app.pages.meet.isActive())
|
||||
app.pages.meet.paint();
|
||||
|
@ -80,7 +83,19 @@ app.pages.meet = {
|
|||
var tpl = app.template.fill({}, app.template.get('meet.actions'));
|
||||
dom.innerHTML += tpl;
|
||||
}; _();
|
||||
var index = app.storage.get('status_meet_index') || 0;
|
||||
var index = app.storage.get('status_meet_index') || null;
|
||||
if (index !== null) {
|
||||
for (var j = 0; j < app.pages.meet.data.length; j++) {
|
||||
console.log(app.pages.meet.data[j]._id)
|
||||
console.log(index)
|
||||
console.log('---')
|
||||
if (app.pages.meet.data[j]._id === index) {
|
||||
app.pages.meet.carousel._current = j;
|
||||
index = j;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else index = 0;
|
||||
app.pages.meet.carousel.set(parseInt(index));
|
||||
},
|
||||
exit: function() {
|
||||
|
@ -93,8 +108,9 @@ app.pages.meet = {
|
|||
_elements: function() { return app.pages.meet.carousel._parent().querySelectorAll('.meet.item') },
|
||||
_size: function() { return app.pages.meet.carousel._elements().length },
|
||||
_onSetEvent: function(direction) {
|
||||
app.storage.set('status_meet_index',
|
||||
app.pages.meet.carousel._current);
|
||||
const current = app.pages.meet.dataCurrent();
|
||||
if (current !== null)
|
||||
app.storage.set('status_meet_index', current._id);
|
||||
app.pages.meet.carousel.setDragEvent(direction);
|
||||
},
|
||||
set: function(i) { return app.carousel.set(app.pages.meet.carousel, i) },
|
||||
|
|
Loading…
Reference in New Issue