mirror of
https://github.com/bellingcat/datasheet-server.git
synced 2026-06-11 21:08:33 +03:00
centralise msgs in copy/en.js
plus some other fixes
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import copy from '../copy/en'
|
||||
|
||||
/**
|
||||
* Controller
|
||||
*
|
||||
@@ -23,7 +25,11 @@ class Controller {
|
||||
return this.fetchers[source].update()
|
||||
})
|
||||
).then(results => {
|
||||
return 'All sources updated'
|
||||
if (results.every(r => r)) {
|
||||
return copy.success.update
|
||||
} else {
|
||||
throw new Error(copy.errors.update)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -32,9 +38,7 @@ class Controller {
|
||||
const fetcher = this.fetchers[source]
|
||||
return fetcher.retrieve(tab, resource)
|
||||
} else {
|
||||
return Promise.resolve().then(() => {
|
||||
throw new Error(`Source ${source} not available.`)
|
||||
})
|
||||
return Promise.reject(new Error(copy.errors.noResource(source)))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,9 +47,7 @@ class Controller {
|
||||
const fetcher = this.fetchers[source]
|
||||
return fetcher.retrieveFrag(tab, resource, frag)
|
||||
} else {
|
||||
return Promise.resolve().then(() => {
|
||||
throw new Error(`Source ${source} not available.`)
|
||||
})
|
||||
return Promise.reject(new Error(copy.errors.noResource(source)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,7 +111,8 @@ class Fetcher {
|
||||
})
|
||||
)
|
||||
})
|
||||
.then(() => 'All tabs updated')
|
||||
.then(() => true)
|
||||
.catch(() => false)
|
||||
}
|
||||
|
||||
save (tab, data) {
|
||||
|
||||
Reference in New Issue
Block a user