handle name duplicates and remove helper func

This commit is contained in:
Austin Spencer 2024-10-17 08:08:00 -04:00
parent 9ccdf305fe
commit b9772a024c
No known key found for this signature in database
2 changed files with 22 additions and 18 deletions

View file

@ -174,20 +174,5 @@ class EmailSettings {
getEReaderDevice(deviceName) {
return this.ereaderDevices.find((d) => d.name === deviceName)
}
/**
* Update the ereader devices that belong to a specific user
*
* @param {import('../../models/User')} user
* @param {EreaderDeviceObject[]} userEReaderDevices
* @returns {boolean}
*/
updateUserEReaderDevices(user, userEReaderDevices) {
// Filter to get all devices the user can't access separate
// then merge with the updated user devices
const otherDevices = this.ereaderDevices.filter((device) => !this.checkUserCanAccessDevice(device, user))
const ereaderDevices = otherDevices.concat(userEReaderDevices)
return this.update({ ereaderDevices })
}
}
module.exports = EmailSettings