mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-07-10 11:21:36 +00:00
toast for duplicate name error caught on server
This commit is contained in:
parent
b9772a024c
commit
3d9d3687d7
1 changed files with 12 additions and 2 deletions
|
|
@ -116,6 +116,8 @@ export default {
|
||||||
this.newDevice.name = this.newDevice.name.trim()
|
this.newDevice.name = this.newDevice.name.trim()
|
||||||
this.newDevice.email = this.newDevice.email.trim()
|
this.newDevice.email = this.newDevice.email.trim()
|
||||||
|
|
||||||
|
// Only catches duplicate names for the current user
|
||||||
|
// Duplicates with other users caught on server side
|
||||||
if (!this.ereaderDevice) {
|
if (!this.ereaderDevice) {
|
||||||
if (this.existingDevices.some((d) => d.name === this.newDevice.name)) {
|
if (this.existingDevices.some((d) => d.name === this.newDevice.name)) {
|
||||||
this.$toast.error(this.$strings.ToastDeviceNameAlreadyExists)
|
this.$toast.error(this.$strings.ToastDeviceNameAlreadyExists)
|
||||||
|
|
@ -154,7 +156,11 @@ export default {
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.error('Failed to update device', error)
|
console.error('Failed to update device', error)
|
||||||
this.$toast.error(this.$strings.ToastFailedToUpdate)
|
if (error.response?.data?.toLowerCase().includes('duplicate')) {
|
||||||
|
this.$toast.error(this.$strings.ToastDeviceNameAlreadyExists)
|
||||||
|
} else {
|
||||||
|
this.$toast.error(this.$strings.ToastDeviceAddFailed)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
this.processing = false
|
this.processing = false
|
||||||
|
|
@ -180,7 +186,11 @@ export default {
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.error('Failed to add device', error)
|
console.error('Failed to add device', error)
|
||||||
this.$toast.error(this.$strings.ToastDeviceAddFailed)
|
if (error.response?.data?.toLowerCase().includes('duplicate')) {
|
||||||
|
this.$toast.error(this.$strings.ToastDeviceNameAlreadyExists)
|
||||||
|
} else {
|
||||||
|
this.$toast.error(this.$strings.ToastDeviceAddFailed)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
this.processing = false
|
this.processing = false
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue