Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
mediaRelationships.forEach((relationship) => {
const role = get(relationship, 'role');
results[role] = results[role] || [];
results[role].addObject(get(relationship, 'destination'));
});
// sort the results by key
get() {
return get(this, '_sortingHandler') || SortingHandler.create();
}
}),
setFocusOnPanel(panel, index) {
set(this, 'focusedIndex', index);
get(this, 'panels').setEach('isFocused', false);
set(panel, 'isFocused', true);
get(panel, 'tab.element').focus();
},
get() {
return get(this, 'isHidden') ? 'true' : 'false';
}
}).readOnly(),
getNextData: task(function* () {
const nextLink = get(this, 'nextLink');
if (nextLink === undefined) {
return;
}
let model = get(this, 'model');
model = get(model, 'firstObject') || model;
let { modelName } = model.constructor;
modelName = get(this, 'modelName') || modelName;
const options = Object.assign(this._parseLink(nextLink), get(this, 'options'));
const records = yield get(this, 'store').query(modelName, options);
const links = get(records, 'links');
invokeAction(this, 'update', records, links);
return records;
}).drop(),
Object.keys(condition.filter).forEach((filter) => {
const val = condition.filter[filter];
if (storeFilter[filter] === undefined) storeFilter[filter] = [val];
else storeFilter[filter].addObject(val);
});
});
Object.keys(storeFilter).forEach((key) => {
if (storeFilter[key].length === 1) storeFilter[key] = storeFilter[key][0];
else multikey = key;
});
const filterkey = (collection.isRelationship) ? `${multikey}.id` : multikey;
return get(this, 'store').query(collection.resource, {
filter: storeFilter,
include: collection.objects.objectAt(0).include
}).then((payload) => {
collection.promises.forEach(([resolve, reject], i) => {
const filter = collection.objects[i].filter;
resolve(payload.filter(condition => filter[multikey] === get(condition, filterkey)));
});
});
},
getDataTask: task(function* (type) {
return yield get(this, 'queryCache').query(type, {
filter: { year: get(this, 'lastYear') },
sort: '-average_rating',
page: { limit: 10 }
});
}).restartable()
});
toggleFollow: task(function* () {
if (get(this, 'session.isAuthenticated') === false) {
return get(this, 'session.signUpModal')();
}
if (get(this, 'isFollowing')) {
yield get(this, 'relationship').destroyRecord().then(() => {
set(this, 'relationship', undefined);
get(this, 'queryCache').invalidateQuery('media-follow', this._getRequestOptions());
}).catch(err => get(this, 'notify').error(errorMessages(err)));
} else {
yield get(this, 'store').createRecord('media-follow', {
user: get(this, 'session.account'),
media: get(this, 'media')
}).save().then((record) => {
set(this, 'relationship', record);
get(this, 'metrics').trackEvent({
category: 'follow',
action: 'create',
label: 'media',
value: get(this, 'media.id')
});
}).catch(err => get(this, 'notify').error(errorMessages(err)));
targetEntered() {
if (get(this, 'isDestroyed')) { return; }
if (get(this, 'singleInstance') === true) {
get(this, 'epicTooltip').all().forEach(component => component.targetLeave());
}
get(this, 'tether').enable();
get(this, 'tether').position();
this.$().show();
},
i18nTitle: getter(function() {
const review = get(this, 'i18n').t('reviews.review');
const reviewLink = createLink(`/reviews/${get(this, 'review.id')}`, review);
const userLink = createLink(`/users/${get(this, 'review.user.name')}`, get(this, 'review.user.name'));
let type = modelType([get(this, 'media') || get(this, 'review.media')]);
if (!get(this, 'review.progress')) type = 'unprogressed';
return get(this, 'i18n').t(`reviews.title.${type}`, {
link: reviewLink,
user: userLink,
progress: get(this, 'review.progress')
});
}),