nextcloud / activity

:zap: Activity app for Nextcloud
115 stars 65 forks source link

[stable29 only]: Comments attached to the wrong file if details sidebar left open #1772

Closed carpediem-av closed 1 month ago

carpediem-av commented 9 months ago

⚠️ This issue respects the following points: ⚠️

Bug description

I discovered the following bug in Nextcloud v28.0.1. Steps to reproduce the bug:

  1. Open the Activities tab for the PDF file and leave a comment.
  2. Without closing the Activities tab, close the PDF viewer.
  3. Open another PDF file from the same folder and try to leave a comment. The comment is not left, but is included in the list of comments in the first file. This bug already existed before in older versions (approximately in versions 17-20), and now you have introduced it again. This is very sad, my users wrote dozens of comments to the wrong files, all the work was ruined.

Steps to reproduce

  1. Open the Activities tab for the PDF file and leave a comment.
  2. Without closing the Activities tab, close the PDF viewer.
  3. Open another PDF file from the same folder and try to leave a comment. The comment is not left, but is included in the list of comments in the first file.

Expected behavior

The comment should have been left on the second file

Installation method

Community Manual installation with Archive

Nextcloud Server version

28

Operating system

Debian/Ubuntu

PHP engine version

PHP 8.2

Web server

Apache (supported)

Database engine version

MariaDB

Is this bug present after an update or on a fresh install?

Upgraded to a MAJOR version (ex. 22 to 23)

Are you using the Nextcloud Server Encryption module?

None

What user-backends are you using?

Configuration report

No response

List of activated Apps

No response

Nextcloud Signing status

No response

Nextcloud Logs

No response

Additional info

No response

joshtrichards commented 9 months ago
Bronson-Brown-deVost commented 9 months ago

I don't know if further debugging help is needed here, but I did a little. The problem is certainly in the Javascript for the website.

After checking the POST request for adding comments, I see it has the wrong ID: I add a comment to a file with ID 148264 in the database. The website makes a post request to https:// ... /remote.php/dav/comments/files/148254. The file as listed in the browser has the apparently the correct ID data-cy-files-list-row-fileid="148264" in its HTML:

<tr data-cy-files-list-row="" data-cy-files-list-row-fileid="148264" data-cy-files-list-row-name="Monger, 4Q216 and the Jubilees Creation Account.pdf" draggable="true" class="files-list__row" index="1">

<!----> <td class="files-list__row-checkbox"><span data-v-87511acb="" class="checkbox-radio-switch checkbox-radio-switch-checkbox" style="--icon-size: 24px;"><input data-v-87511acb="" id="checkbox-radio-switch-lwbhm" aria-label="Toggle selection for file &quot;Monger, 4Q216 and the Jubilees Creation Account.pdf&quot;" type="checkbox" class="checkbox-radio-switch__input" value=""><label data-v-bc42acb7="" data-v-87511acb="" for="checkbox-radio-switch-lwbhm" class="checkbox-content checkbox-radio-switch__content checkbox-content-checkbox"><span data-v-bc42acb7="" aria-hidden="true" class="checkbox-content__icon checkbox-radio-switch__icon"><span data-v-bc42acb7="" aria-hidden="true" role="img" class="material-design-icon checkbox-blank-outline-icon"><svg fill="currentColor" width="24" height="24" viewBox="0 0 24 24" class="material-design-icon__svg"><path d="M19,3H5C3.89,3 3,3.89 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V5C21,3.89 20.1,3 19,3M19,5V19H5V5H19Z"><!----></path></svg></span></span><span data-v-bc42acb7="" class="checkbox-content__text checkbox-radio-switch__text"></span></label></span></td> <td data-cy-files-list-row-name="" class="files-list__row-name"><span class="files-list__row-icon"><img alt="" loading="lazy" src="https://share.qumran-digital.org/index.php/core/preview?fileId=148264&amp;x=32&amp;y=32&amp;mimeFallback=true&amp;a=0" class="files-list__row-icon-preview files-list__row-icon-preview--loaded"> <!----> <!----></span> <a data-cy-files-list-row-name-link="" title="View" tabindex="0" class="files-list__row-name-link" role="button"><span class="files-list__row-name-text"><span class="files-list__row-name-">Monger, 4Q216 and the Jubilees Creation Account</span> <span class="files-list__row-name-ext">.pdf</span></span></a></td> <td data-v-3daa457a="" data-cy-files-list-row-actions="" class="files-list__row-actions files-list__row-actions--482749712"> <div data-v-377272aa="" data-v-3daa457a="" class="action-items action-item--tertiary"><button data-v-8f4e0666="" data-v-377272aa="" aria-label="" type="button" data-cy-files-list-row-action="sharing-status" title="Show sharing options" class="button-vue button-vue--icon-only button-vue--vue-tertiary action-item action-item--single files-list__row-action-sharing-status"><span data-v-8f4e0666="" class="button-vue__wrapper"><span data-v-8f4e0666="" aria-hidden="true" class="button-vue__icon"><span data-v-6176f396="" data-v-3daa457a="" role="img" aria-hidden="true" class="icon-vue" data-v-8f4e0666=""><svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M15,14C12.33,14 7,15.33 7,18V20H23V18C23,15.33 17.67,14 15,14M6,10V7H4V10H1V12H4V15H6V12H9V10M15,12A4,4 0 0,0 19,8A4,4 0 0,0 15,4A4,4 0 0,0 11,8A4,4 0 0,0 15,12Z"></path></svg></span></span></span></button><div data-v-377272aa="" class="action-item"><div data-v-377272aa="" class="v-popper v-popper--theme-dropdown"><button data-v-8f4e0666="" data-v-377272aa="" aria-label="Actions" type="button" aria-haspopup="menu" aria-expanded="false" class="button-vue button-vue--icon-only button-vue--vue-tertiary action-item__menutoggle"><span data-v-8f4e0666="" class="button-vue__wrapper"><span data-v-8f4e0666="" aria-hidden="true" class="button-vue__icon"><span data-v-377272aa="" aria-hidden="true" role="img" class="material-design-icon dots-horizontal-icon" data-v-8f4e0666=""><svg fill="currentColor" width="20" height="20" viewBox="0 0 24 24" class="material-design-icon__svg"><path d="M16,12A2,2 0 0,1 18,10A2,2 0 0,1 20,12A2,2 0 0,1 18,14A2,2 0 0,1 16,12M10,12A2,2 0 0,1 12,10A2,2 0 0,1 14,12A2,2 0 0,1 12,14A2,2 0 0,1 10,12M4,12A2,2 0 0,1 6,10A2,2 0 0,1 8,12A2,2 0 0,1 6,14A2,2 0 0,1 4,12Z"><!----></path></svg></span></span></span></button></div></div></div></td> <td data-cy-files-list-row-size="" class="files-list__row-size" style="color: color-mix(in srgb, var(--color-main-text) 1%, var(--color-text-maxcontrast));"><span>906 KB</span></td> <td data-cy-files-list-row-mtime="" class="files-list__row-mtime" style="color: color-mix(in srgb, var(--color-main-text) 95%, var(--color-text-maxcontrast));"><span data-timestamp="Wed Jan 31 2024 23:22:58 GMT+0100 (Central European Standard Time)" title="31.01.24, 23:22:58" class="nc-datetime">vorgestern</span></td> </tr>

I did not test further yet, but I would note that the ID in the POST request (148254) is the ID of the file directly before the file I am trying to comment on.

Bronson-Brown-deVost commented 9 months ago

I did a test on another file and the comment was again POSTed to https:// ... /remote.php/dav/comments/files/148254 even though the file I commented on has an ID of 148279.

I notice that 148254 is ID of the first file in my list of files.

I am using: Nextcloud v28.0.2 Postgres 14.10 Apache with PHP 8.1

nikobe123 commented 9 months ago

Thank you for linking this. We have many other issues with the comments, hopefully they will be fixed as well soon. See forum

carpediem-av commented 7 months ago

It's sad to see that a serious bug has not yet been fixed by the developer. Apparently I need to take matters into my own hands. I'm not a developer and I don't know much about web development. I did this in the Sidebar.vue file to fix the bug:

line 467:   async open(path) {
            //!!! BUGFIX >>>
            this.close();
            //!!! BUGFIX <<<

            if (!path || path.trim() === '') {
                throw new Error(`Invalid path '${path}'`)
            }

            // Only focus the tab when the selected file/tab is changed in already opened sidebar
            // Focusing the sidebar on first file open is handled by NcAppSidebar
            const focusTabAfterLoad = !!this.Sidebar.file

            // update current opened file
            this.Sidebar.file = path

            // reset data, keep old fileInfo to not reload all tabs and just hide them
            this.error = null
            this.loading = true

            try {
                this.fileInfo = await FileInfo(this.davPath)
                // adding this as fallback because other apps expect it
                this.fileInfo.dir = this.file.split('/').slice(0, -1).join('/')

                // DEPRECATED legacy views
                // TODO: remove
                this.views.forEach(view => {
                    view.setFileInfo(this.fileInfo)
                })

                await this.$nextTick()

                this.setActiveTab(this.Sidebar.activeTab || this.tabs[0].id)

                this.loading = false

                await this.$nextTick()

                if (focusTabAfterLoad) {
                    this.$refs.sidebar.focusActiveTabContent()
                }
            } catch (error) {
                this.loading = false
                this.error = t('files', 'Error while loading the file data')
                console.error('Error while loading the file data', error)

                throw new Error(error)
            }
        },

The decision is controversial, but now comments are published on the correct files.

PW-RTR commented 3 months ago

This bug happens not only in Nextcloud 28 but also in Nextcloud 29.0.4

solracsf commented 3 months ago

Cc @susnux does https://github.com/nextcloud/server/pull/44868 fix this?

susnux commented 2 months ago

Yes I think this is fixed now

JoergTheHipp commented 2 months ago

I just made the update to nc 29.0.5 to see whether this bug is fixed. Sorry to say that - it is NOT FIXED, the same behaviour still exists.

susnux commented 2 months ago

Confirmed

edward-ly commented 2 months ago

I just made the update to nc 29.0.5 to see whether this bug is fixed. Sorry to say that - it is NOT FIXED, the same behaviour still exists.

Confirmed

I haven't been able to reproduce the issue myself, though, even on a fresh development instance running 29.0.5. @JoergTheHipp @susnux Have either of you refreshed your browser cache, or perhaps there is something else that hasn't been mentioned here yet?

susnux commented 2 months ago

Seems to be fixed with latest changes:

Bildschirmaufnahme_20240828_192540.webm

olive-spore-734 commented 2 months ago

It is still an issue on 29.0.6, it happens on folders aswell.

edward-ly commented 2 months ago

It is still an issue on 29.0.6, it happens on folders aswell.

@olive-spore-734 If that's the case, please provide us the steps to reproduce it (in as much detail as possible).

olive-spore-734 commented 2 months ago

It is still an issue on 29.0.6, it happens on folders aswell.

@olive-spore-734 If that's the case, please provide us the steps to reproduce it (in as much detail as possible).

My bad, here you go:

  1. Open activities tab of a file (pdf, folder, doc - i didnt test others)
  2. Write a comment
  3. Switch to a different file without closing the sidebar
  4. Write a comment
  5. Comment does not show up on the second file, but the first one

Closing the sidebar inbetween commenting on different files resolves the issue This bug seemed to appear around the time the comments tab was combined with the activity tab - but i am unsure if that has had anything to do with it, so dont read too much into it.

PHP: 8.2.20 DB: MySQL: 10.11.6

susnux commented 2 months ago

I can reproduce this, but only on 29, not on 30 or master.

joshtrichards commented 1 month ago

Fixed in #1771