don't load content for notes list in web browser
This commit is contained in:
parent
487a10ba59
commit
ed38f8c12d
|
@ -55,7 +55,7 @@ class NotesController extends Controller {
|
|||
* @NoAdminRequired
|
||||
*/
|
||||
public function index() {
|
||||
return new DataResponse($this->notesService->getAll($this->userId));
|
||||
return new DataResponse($this->notesService->getAll($this->userId, true));
|
||||
}
|
||||
|
||||
|
||||
|
|
16
db/note.php
16
db/note.php
|
@ -56,14 +56,16 @@ class Note extends Entity {
|
|||
* @param File $file
|
||||
* @return static
|
||||
*/
|
||||
public static function fromFile(File $file, Folder $notesFolder, $tags=[]){
|
||||
public static function fromFile(File $file, Folder $notesFolder, $tags=[], $onlyMeta=false) {
|
||||
$note = new static();
|
||||
$note->setId($file->getId());
|
||||
$fileContent=$file->getContent();
|
||||
if($fileContent===false){
|
||||
throw new FileNotFoundException("File not found");
|
||||
if(!$onlyMeta) {
|
||||
$fileContent=$file->getContent();
|
||||
if($fileContent===false){
|
||||
throw new FileNotFoundException("File not found");
|
||||
}
|
||||
$note->setContent(self::convertEncoding($fileContent));
|
||||
}
|
||||
$note->setContent(self::convertEncoding($fileContent));
|
||||
$note->setModified($file->getMTime());
|
||||
$note->setTitle(pathinfo($file->getName(),PATHINFO_FILENAME)); // remove extension
|
||||
$subdir = substr(dirname($file->getPath()), strlen($notesFolder->getPath())+1);
|
||||
|
@ -72,7 +74,9 @@ class Note extends Entity {
|
|||
$note->setFavorite(true);
|
||||
//unset($tags[array_search(\OC\Tags::TAG_FAVORITE, $tags)]);
|
||||
}
|
||||
$note->updateETag();
|
||||
if(!$onlyMeta) {
|
||||
$note->updateETag();
|
||||
}
|
||||
$note->resetUpdatedFields();
|
||||
return $note;
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ class NotesService {
|
|||
* @param string $userId
|
||||
* @return array with all notes in the current directory
|
||||
*/
|
||||
public function getAll ($userId){
|
||||
public function getAll ($userId, $onlyMeta=false) {
|
||||
$notesFolder = $this->getFolderForUser($userId);
|
||||
$notes = $this->gatherNoteFiles($notesFolder);
|
||||
$filesById = [];
|
||||
|
@ -76,7 +76,7 @@ class NotesService {
|
|||
|
||||
$notes = [];
|
||||
foreach($filesById as $id=>$file) {
|
||||
$notes[] = $this->getNote($file, $notesFolder, array_key_exists($id, $tags) ? $tags[$id] : []);
|
||||
$notes[] = $this->getNote($file, $notesFolder, array_key_exists($id, $tags) ? $tags[$id] : [], $onlyMeta);
|
||||
}
|
||||
|
||||
return $notes;
|
||||
|
@ -104,21 +104,22 @@ class NotesService {
|
|||
}
|
||||
return array_key_exists($id, $tags) ? $tags[$id] : [];
|
||||
}
|
||||
private function getNote($file,$notesFolder,$tags=[]){
|
||||
|
||||
private function getNote($file, $notesFolder, $tags=[], $onlyMeta=false) {
|
||||
$id=$file->getId();
|
||||
|
||||
try{
|
||||
$note=Note::fromFile($file, $notesFolder, $tags);
|
||||
}catch(FileNotFoundException $e){
|
||||
try {
|
||||
$note=Note::fromFile($file, $notesFolder, $tags, $onlyMeta);
|
||||
} catch(FileNotFoundException $e){
|
||||
$note = Note::fromException($this->l10n->t('File error').': ('.$file->getName().') '.$e->getMessage(), $file, $notesFolder, array_key_exists($id, $tags) ? $tags[$id] : []);
|
||||
}catch(DecryptionFailedException $e){
|
||||
} catch(DecryptionFailedException $e) {
|
||||
$note = Note::fromException($this->l10n->t('Encryption Error').': ('.$file->getName().') '.$e->getMessage(), $file, $notesFolder, array_key_exists($id, $tags) ? $tags[$id] : []);
|
||||
}catch(\Exception $e){
|
||||
} catch(\Exception $e) {
|
||||
$note = Note::fromException($this->l10n->t('Error').': ('.$file->getName().') '.$e->getMessage(), $file, $notesFolder, array_key_exists($id, $tags) ? $tags[$id] : []);
|
||||
}
|
||||
return $note;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a note and returns the empty note
|
||||
* @param string $userId
|
||||
|
|
Loading…
Reference in New Issue