2018-10-02
REFACTORING
Today I started extracting and refactoring the nightmare which is the FileInput in Patchcore. Great news is that it's significantly tidier, you can check out the work so far here : https://github.com/ssbc/patchbay-thread/blob/master/views/components/composer-attachments.js
I reworked the flow to use pull-streams, so that the core of the logic now looks like this :
pull(
pull.values(files),
pull.asyncMap(buildFileDoc),
pull.asyncMap(imageProcess({ stripExif, resize })), // NOTE this also blobifies the data
pull.drain(
(doc) => AttachFile(doc, ev),
(err) => {
if (err) console.error(err)
}
)
)
SO CLEAN
BONUS
this refactoring enabled MULTIPLE FILE ATTACHMENT
e.g. select 5 photos from your adventuring. BOOM, attached
pull-streams meant this only took swapping file[0]
for files
on one line