Skip to content

Commit

Permalink
fix: deleting inline file should delete file in the list as well [ch1…
Browse files Browse the repository at this point in the history
…8037] (#412)
  • Loading branch information
seavan authored Jan 4, 2019
1 parent 478155a commit 461f286
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
11 changes: 10 additions & 1 deletion app/components/files/file-state.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,16 @@ class FileState extends RoutedState {
}

@action
async deleteFile(file) {
async deleteFile(fileInfo) {
const id = fileInfo.fileId;
let file = fileStore.getById(id);
if (!file) {
file = await fileStore.loadKegByFileId(id);
if (!file) {
console.error(`could not resolve a file ${id}`);
return Promise.resolve();
}
}
const isOwner = file.owner === User.current.username;
const title = isOwner ? tx('dialog_confirmDeleteFile') : tx('title_confirmRemoveFile');
let subtitle = '';
Expand Down
7 changes: 6 additions & 1 deletion app/components/files/file-upload-action-sheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ import ActionSheetLayout from '../layout/action-sheet-layout';

async function doUpload(sourceFunction, inline) {
const uploader = inline ? fileState.uploadInline : fileState.uploadInFiles;
const source = observable(await sourceFunction());
const uploadInfo = await sourceFunction();
if (!uploadInfo) {
console.log(`no upload info provided. skipping upload`);
return;
}
const source = observable(uploadInfo);
if (inline) {
const userSelection = await FileSharePreview.popup(source.url, source.fileName);
if (!userSelection) return;
Expand Down
4 changes: 4 additions & 0 deletions app/components/helpers/imagepicker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ async function processResponse(functor, params?) {
if (!response.path && response.uri) {
response.path = response.uri;
}
if (!response.path) {
console.log(`user cancelled image selection. no path returned`);
return null;
}
// if it's a HEIF or HEIC file, it would still give you path to JPG asset
// for the sake of compatibility
const ext = fileHelpers
Expand Down

0 comments on commit 461f286

Please sign in to comment.