diff options
Diffstat (limited to 'static/api/images.js')
| -rw-r--r-- | static/api/images.js | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/static/api/images.js b/static/api/images.js index 4bdac1f..aa783e9 100644 --- a/static/api/images.js +++ b/static/api/images.js @@ -52,15 +52,27 @@ export async function upload_to_timeline() { }) } -export async function upload_to_profile() { +export async function upload_to_profile(id) { const input = Input.new({ type: 'file', multiple: false, accept: 'image/jpeg', }) input.click(); + + return new Promise((resolve) => { + input.onchange = () => { + resolve(new FileUploader(`/api/profile/image/upload/${id}`, [...input.files])); + } + }) } export function list() { - return rest.get('/api/image/list').then(r => r.images); + return rest.get('/api/image/list') + .then(r => { + r.images.forEach(i => { + i.date = new Date(i.date * 1000) + }); + return r.images; + }); } |