Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
45 lines
977 B
Plaintext
45 lines
977 B
Plaintext
import { sanitizeID } from '@payloadcms/ui/shared';
|
|
export const getDocPreferences = async ({
|
|
id,
|
|
collectionSlug,
|
|
globalSlug,
|
|
payload,
|
|
user
|
|
}) => {
|
|
let preferencesKey;
|
|
if (collectionSlug && id) {
|
|
preferencesKey = `collection-${collectionSlug}-${id}`;
|
|
}
|
|
if (globalSlug) {
|
|
preferencesKey = `global-${globalSlug}`;
|
|
}
|
|
if (preferencesKey) {
|
|
const preferencesResult = await payload.find({
|
|
collection: 'payload-preferences',
|
|
depth: 0,
|
|
limit: 1,
|
|
where: {
|
|
and: [{
|
|
key: {
|
|
equals: preferencesKey
|
|
}
|
|
}, {
|
|
'user.relationTo': {
|
|
equals: user.collection
|
|
}
|
|
}, {
|
|
'user.value': {
|
|
equals: sanitizeID(user.id)
|
|
}
|
|
}]
|
|
}
|
|
});
|
|
if (preferencesResult?.docs?.[0]?.value) {
|
|
return preferencesResult.docs[0].value;
|
|
}
|
|
}
|
|
return {
|
|
fields: {}
|
|
};
|
|
};
|
|
//# sourceMappingURL=getDocPreferences.js.map |