Skip to content

Commit

Permalink
Fix unable to forget a shared note deleted by the owner. Issue #72
Browse files Browse the repository at this point in the history
  • Loading branch information
matiasdelellis committed May 31, 2022
1 parent 38860f7 commit 073a8db
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 12 deletions.
2 changes: 1 addition & 1 deletion appinfo/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
],
// Share
[
'name' => 'share#destroy',
'name' => 'share#forget',
'url' => '/share/{noteId}',
'verb' => 'DELETE'
],
Expand Down
2 changes: 1 addition & 1 deletion js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ View.prototype = {
self._notes.forgetShare(note).done(function () {
if (self._notes.length() > 0) {
self._isotope.remove(gridnote.parent())
selg._isotope.layout();
self._isotope.layout();
self.showAll();
self.renderNavigation();
} else {
Expand Down
9 changes: 3 additions & 6 deletions lib/Controller/ShareController.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,9 @@ public function __construct($AppName,
*
* @param int $noteId
*/
public function destroy(int $noteId): JSONResponse {
if ($this->noteShareMapper->forgetShareByNoteIdAndSharedUser($noteId, $this->userId)) {
return new JSONResponse([], Http::STATUS_OK);
} else {
return new JSONResponse([], Http::STATUS_NOT_FOUND);
}
public function forget(int $noteId): JSONResponse {
$this->noteShareMapper->forgetShareByNoteIdAndSharedUser($noteId, $this->userId);
return new JSONResponse([]);
}

}
4 changes: 2 additions & 2 deletions lib/Dashboard/NotesWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

class NotesWidget implements IWidget {

private IURLGenerator $url;
private IL10N $l10n;
private $url;
private $l10n;

public function __construct(IURLGenerator $url,
IL10N $l10n)
Expand Down
4 changes: 2 additions & 2 deletions lib/Db/NoteShareMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function forgetSharesByNoteId(int $noteId): void {
->execute();
}

public function forgetShareByNoteIdAndSharedUser(int $noteId, string $userId) {
public function forgetShareByNoteIdAndSharedUser(int $noteId, string $userId): bool {
try {
$noteShare = $this->findSharesByNoteIsAndSharedUser($noteId, $userId);
} catch (DoesNotExistException $e) {
Expand All @@ -86,7 +86,7 @@ public function forgetShareByNoteIdAndSharedUser(int $noteId, string $userId) {
/**
* @return bool
*/
public function existsByNoteAndSharedUser(int $noteId, string $userId) {
public function existsByNoteAndSharedUser(int $noteId, string $userId): bool {
try {
$this->findSharesByNoteIsAndSharedUser($noteId, $userId);
} catch (DoesNotExistException $e) {
Expand Down

0 comments on commit 073a8db

Please sign in to comment.