Merge pull request #6152 from JonnyTischbein/issue_delete_from_saved_folder

Fix deleting last element and displaying empty saved folder
This commit is contained in:
Hypolite Petovan 2018-11-17 11:59:24 -05:00 committed by GitHub
commit 22fedc9a1a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 7 deletions

View file

@ -14,7 +14,7 @@ function filerm_content(App $a)
} }
$term = XML::unescape(trim($_GET['term'])); $term = XML::unescape(trim($_GET['term']));
$cat = XML::unescape(trim($_GET['cat'])); $cat = XML::unescape(trim(defaults($_GET, 'cat', '')));
$category = (($cat) ? true : false); $category = (($cat) ? true : false);
@ -25,12 +25,17 @@ function filerm_content(App $a)
$item_id = (($a->argc > 1) ? intval($a->argv[1]) : 0); $item_id = (($a->argc > 1) ? intval($a->argv[1]) : 0);
Logger::log('filerm: tag ' . $term . ' item ' . $item_id); Logger::log('filerm: tag ' . $term . ' item ' . $item_id . ' category ' . ($category ? 'true' : 'false'));
if ($item_id && strlen($term)) if ($item_id && strlen($term)) {
{ if (FileTag::unsaveFile(local_user(), $item_id, $term, $category)) {
FileTag::unsaveFile(local_user(), $item_id, $term, $category); info('Item removed');
}
}
else {
info('Item was not deleted');
} }
$a->internalRedirect('/network?f=&file=' . $term);
killme(); killme();
} }

View file

@ -346,6 +346,11 @@ function networkConversation(App $a, $items, Pager $pager, $mode, $update, $orde
// Set this so that the conversation function can find out contact info for our wall-wall items // Set this so that the conversation function can find out contact info for our wall-wall items
$a->page_contact = $a->contact; $a->page_contact = $a->contact;
if (!is_array($items)) {
Logger::log("Expecting items to be an array. Got " . print_r($items, true));
$items = [];
}
$o = conversation($a, $items, $pager, $mode, $update, false, $ordering, local_user()); $o = conversation($a, $items, $pager, $mode, $update, false, $ordering, local_user());
if (!$update) { if (!$update) {
@ -389,6 +394,10 @@ function network_content(App $a, $update = 0, $parent = 0)
$o = networkThreadedView($a, $update, $parent); $o = networkThreadedView($a, $update, $parent);
} }
if ($o === '') {
info("No items found");
}
return $o; return $o;
} }
@ -463,6 +472,9 @@ function networkFlatView(App $a, $update = 0)
} }
DBA::close($result); DBA::close($result);
if (count($posts) == 0) {
return '';
}
$condition = ['uid' => local_user(), 'id' => $posts]; $condition = ['uid' => local_user(), 'id' => $posts];
} else { } else {
$condition = ['uid' => local_user()]; $condition = ['uid' => local_user()];

View file

@ -291,6 +291,7 @@ class FileTag
} }
$fields = ['file' => str_replace($pattern, '', $item['file'])]; $fields = ['file' => str_replace($pattern, '', $item['file'])];
Item::update($fields, ['id' => $item_id]); Item::update($fields, ['id' => $item_id]);
$r = q("SELECT `oid` FROM `term` WHERE `term` = '%s' AND `otype` = %d AND `type` = %d AND `uid` = %d", $r = q("SELECT `oid` FROM `term` WHERE `term` = '%s' AND `otype` = %d AND `type` = %d AND `uid` = %d",

View file

@ -832,7 +832,7 @@ class Item extends BaseObject
$files = $fields['file']; $files = $fields['file'];
$fields['file'] = null; $fields['file'] = null;
} else { } else {
$files = ''; $files = null;
} }
$delivery_data = ['postopts' => defaults($fields, 'postopts', ''), $delivery_data = ['postopts' => defaults($fields, 'postopts', ''),
@ -911,7 +911,7 @@ class Item extends BaseObject
} }
} }
if (!empty($files)) { if (!is_null($files)) {
Term::insertFromFileFieldByItemId($item['id'], $files); Term::insertFromFileFieldByItemId($item['id'], $files);
if (!empty($item['file'])) { if (!empty($item['file'])) {
DBA::update('item', ['file' => ''], ['id' => $item['id']]); DBA::update('item', ['file' => ''], ['id' => $item['id']]);