forked from 0x2620/pandora
fix URL/UI bugs, handle the case where on page load we have an item and a query that does not match the item
This commit is contained in:
parent
e3fb12441d
commit
d7092ad856
2 changed files with 45 additions and 38 deletions
|
@ -33,18 +33,17 @@ pandora.UI = (function() {
|
||||||
}
|
}
|
||||||
Ox.print('UI SET', args)
|
Ox.print('UI SET', args)
|
||||||
self.previousUI = Ox.clone(pandora.user.ui, true);
|
self.previousUI = Ox.clone(pandora.user.ui, true);
|
||||||
Ox.forEach(args, function(val, key) {
|
if ('find' in args) {
|
||||||
if (key == 'find') {
|
|
||||||
// the challenge here is that find may change list,
|
// the challenge here is that find may change list,
|
||||||
// and list may then change listSort and listView,
|
// and list may then change listSort and listView,
|
||||||
// which we don't want to trigger, since find triggers
|
// which we don't want to trigger, since find triggers
|
||||||
var list = pandora.getListsState(val);
|
// (values we put in add will be changed, but won't trigger)
|
||||||
|
var list = pandora.getListsState(args.find);
|
||||||
pandora.user.ui._list = list;
|
pandora.user.ui._list = list;
|
||||||
pandora.user.ui._groupsState = pandora.getGroupsState(val);
|
pandora.user.ui._groupsState = pandora.getGroupsState(args.find);
|
||||||
pandora.user.ui._findState = pandora.getFindState(val);
|
pandora.user.ui._findState = pandora.getFindState(args.find);
|
||||||
if (!Ox.isEqual(val, pandora.user.ui.find)) {
|
|
||||||
if (pandora.$ui.appPanel) {
|
if (pandora.$ui.appPanel) {
|
||||||
// if find has changed and we're not on page load,
|
// if we're not on page load,
|
||||||
// switch from item view to list view
|
// switch from item view to list view
|
||||||
add['item'] = '';
|
add['item'] = '';
|
||||||
}
|
}
|
||||||
|
@ -64,9 +63,11 @@ pandora.UI = (function() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
// it is important to check for find first, so that if find
|
||||||
else if (Object.keys(listSettings).indexOf(key) > -1) {
|
// changes list, pandora.user.ui._list is correct here
|
||||||
// copy setting to list setting
|
Ox.forEach(args, function(val, key) {
|
||||||
|
if (Object.keys(listSettings).indexOf(key) > -1) {
|
||||||
|
// if applicable, copy setting to list setting
|
||||||
add['lists.' + that.encode(pandora.user.ui._list || '') + '.' + listSettings[key]] = val;
|
add['lists.' + that.encode(pandora.user.ui._list || '') + '.' + listSettings[key]] = val;
|
||||||
} else if (key == 'item' && val) {
|
} else if (key == 'item' && val) {
|
||||||
// when switching to an item, update list selection
|
// when switching to an item, update list selection
|
||||||
|
@ -82,16 +83,21 @@ pandora.UI = (function() {
|
||||||
&& ['video', 'timeline'].indexOf(val) > -1
|
&& ['video', 'timeline'].indexOf(val) > -1
|
||||||
&& !pandora.user.ui.videoPoints[pandora.user.ui.item]
|
&& !pandora.user.ui.videoPoints[pandora.user.ui.item]
|
||||||
)) {
|
)) {
|
||||||
// add default videoPoints
|
// when switching to a video view, add default videoPoints
|
||||||
add['videoPoints.' + (
|
add['videoPoints.' + (
|
||||||
key == 'item' ? val : pandora.user.ui.item
|
key == 'item' ? val : pandora.user.ui.item
|
||||||
)] = {'in': 0, out: 0, position: 0};
|
)] = {'in': 0, out: 0, position: 0};
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
[args, add].forEach(function(obj, isAdd) {
|
[args, add].forEach(function(obj, isAdd) {
|
||||||
|
Ox.print('UUU', obj)
|
||||||
Ox.forEach(obj, function(val, key) {
|
Ox.forEach(obj, function(val, key) {
|
||||||
var keys = key.replace(/([^\\])\./g, '$1\n').split('\n'),
|
// make sure to not split at escaped dots ('\.')
|
||||||
|
var keys = key.replace(/\\\./g, '\n').split('.').map(function(key) {
|
||||||
|
return key.replace(/\n/g, '.')
|
||||||
|
}),
|
||||||
ui = pandora.user.ui;
|
ui = pandora.user.ui;
|
||||||
|
Ox.print(key, '......', keys)
|
||||||
while (keys.length > 1) {
|
while (keys.length > 1) {
|
||||||
ui = ui[keys.shift()];
|
ui = ui[keys.shift()];
|
||||||
}
|
}
|
||||||
|
|
|
@ -205,9 +205,10 @@ pandora.URL = (function() {
|
||||||
|
|
||||||
///*
|
///*
|
||||||
if (state.find) {
|
if (state.find) {
|
||||||
set.find = state.find;
|
find = state.find;
|
||||||
|
set.find = find;
|
||||||
} else {
|
} else {
|
||||||
var find = pandora.user.ui.find;
|
find = pandora.user.ui.find;
|
||||||
pandora.user.ui._list = pandora.getListsState(find)
|
pandora.user.ui._list = pandora.getListsState(find)
|
||||||
pandora.user.ui._groupsState = pandora.getGroupsState(find);
|
pandora.user.ui._groupsState = pandora.getGroupsState(find);
|
||||||
pandora.user.ui._findState = pandora.getFindState(find);
|
pandora.user.ui._findState = pandora.getFindState(find);
|
||||||
|
@ -219,12 +220,12 @@ pandora.URL = (function() {
|
||||||
$(this).trigger('stop');
|
$(this).trigger('stop');
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!pandora.$ui.appPanel && state.item && pandora.user.ui.find) {
|
if (!pandora.$ui.appPanel && state.item && find) {
|
||||||
// on page load, if item is set and there is or was a query,
|
// on page load, if item is set and there is or was a query,
|
||||||
// we have to check if the item actually matches the query,
|
// we have to check if the item actually matches the query,
|
||||||
// and otherwise reset find
|
// and otherwise reset find
|
||||||
pandora.api.find({
|
pandora.api.find({
|
||||||
query: pandora.user.ui.find,
|
query: find,
|
||||||
positions: [state.item],
|
positions: [state.item],
|
||||||
sort: [{key: 'id', operator: ''}]
|
sort: [{key: 'id', operator: ''}]
|
||||||
}, function(result) {
|
}, function(result) {
|
||||||
|
|
Loading…
Reference in a new issue