Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Nextcloud
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TeDomum
Nextcloud
Commits
8bd39fcc
Unverified
Commit
8bd39fcc
authored
4 years ago
by
Roeland Jago Douma
Browse files
Options
Downloads
Patches
Plain Diff
Have the CommentsPropertiesPlugin use the new fancy method
Signed-off-by:
Roeland Jago Douma
<
roeland@famdouma.nl
>
parent
ede75108
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
apps/dav/lib/Connector/Sabre/CommentPropertiesPlugin.php
+27
-18
27 additions, 18 deletions
apps/dav/lib/Connector/Sabre/CommentPropertiesPlugin.php
with
27 additions
and
18 deletions
apps/dav/lib/Connector/Sabre/CommentPropertiesPlugin.php
+
27
−
18
View file @
8bd39fcc
...
...
@@ -47,8 +47,6 @@ class CommentPropertiesPlugin extends ServerPlugin {
private
$cachedUnreadCount
=
[];
private
$cachedFolders
=
[];
public
function
__construct
(
ICommentsManager
$commentsManager
,
IUserSession
$userSession
)
{
$this
->
commentsManager
=
$commentsManager
;
$this
->
userSession
=
$userSession
;
...
...
@@ -70,6 +68,31 @@ class CommentPropertiesPlugin extends ServerPlugin {
$this
->
server
->
on
(
'propFind'
,
[
$this
,
'handleGetProperties'
]);
}
private
function
cacheDirectory
(
Directory
$directory
)
{
$children
=
$directory
->
getChildren
();
$ids
=
[];
foreach
(
$children
as
$child
)
{
if
(
!
(
$child
instanceof
File
||
$child
instanceof
Directory
))
{
continue
;
}
$id
=
$child
->
getId
();
if
(
$id
===
null
)
{
continue
;
}
$ids
[]
=
(
string
)
$id
;
}
$ids
[]
=
(
string
)
$directory
->
getId
();
$unread
=
$this
->
commentsManager
->
getNumberOfUnreadCommentsForObjects
(
'files'
,
$ids
,
$this
->
userSession
->
getUser
());
foreach
(
$unread
as
$id
=>
$count
)
{
$this
->
cachedUnreadCount
[(
int
)
$id
]
=
$count
;
}
}
/**
* Adds tags and favorites properties to the response,
* if requested.
...
...
@@ -91,11 +114,7 @@ class CommentPropertiesPlugin extends ServerPlugin {
&&
$propFind
->
getDepth
()
!==
0
&&
!
is_null
(
$propFind
->
getStatus
(
self
::
PROPERTY_NAME_UNREAD
))
)
{
$unreadCounts
=
$this
->
commentsManager
->
getNumberOfUnreadCommentsForFolder
(
$node
->
getId
(),
$this
->
userSession
->
getUser
());
$this
->
cachedFolders
[]
=
$node
->
getPath
();
foreach
(
$unreadCounts
as
$id
=>
$count
)
{
$this
->
cachedUnreadCount
[
$id
]
=
$count
;
}
$this
->
cacheDirectory
(
$node
);
}
$propFind
->
handle
(
self
::
PROPERTY_NAME_COUNT
,
function
()
use
(
$node
)
{
...
...
@@ -109,18 +128,8 @@ class CommentPropertiesPlugin extends ServerPlugin {
$propFind
->
handle
(
self
::
PROPERTY_NAME_UNREAD
,
function
()
use
(
$node
)
{
if
(
isset
(
$this
->
cachedUnreadCount
[
$node
->
getId
()]))
{
return
$this
->
cachedUnreadCount
[
$node
->
getId
()];
}
else
{
list
(
$parentPath
,)
=
\Sabre\Uri\split
(
$node
->
getPath
());
if
(
$parentPath
===
''
)
{
$parentPath
=
'/'
;
}
// if we already cached the folder this file is in we know there are no comments for this file
if
(
array_search
(
$parentPath
,
$this
->
cachedFolders
)
===
false
)
{
return
0
;
}
else
{
return
$this
->
getUnreadCount
(
$node
);
}
}
return
$this
->
getUnreadCount
(
$node
);
});
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment