Skip to content

feat(stream): autoload newer activities#2444

Open
miaulalala wants to merge 1 commit intomasterfrom
feat/405/auto-load-new-activities
Open

feat(stream): autoload newer activities#2444
miaulalala wants to merge 1 commit intomasterfrom
feat/405/auto-load-new-activities

Conversation

@miaulalala
Copy link
Collaborator

@miaulalala miaulalala commented Mar 10, 2026

Fix #405

Screencast.from.2026-03-12.14-34-11.webm

@cypress
Copy link

cypress bot commented Mar 10, 2026

Activity    Run #3457

Run Properties:  status check passed Passed #3457  •  git commit 9893f138ad: feat(stream): autoload newer activities
Project Activity
Branch Review feat/405/auto-load-new-activities
Run status status check passed Passed #3457
Run duration 02m 00s
Commit git commit 9893f138ad: feat(stream): autoload newer activities
Committer Anna
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 0
Tests that did not run due to a developer annotating a test with .skip  Pending 1
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 9
View all changes introduced in this branch ↗︎

@codecov
Copy link

codecov bot commented Mar 10, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@miaulalala miaulalala force-pushed the feat/405/auto-load-new-activities branch from d9cdd6b to 4bbbbed Compare March 12, 2026 13:36
@nextcloud-command nextcloud-command force-pushed the feat/405/auto-load-new-activities branch from 4bbbbed to a4995e1 Compare March 12, 2026 13:38
@miaulalala miaulalala marked this pull request as ready for review March 12, 2026 13:40
Copilot AI review requested due to automatic review settings March 12, 2026 13:40
@miaulalala miaulalala requested a review from artonge March 12, 2026 13:45

This comment was marked as outdated.

@miaulalala miaulalala force-pushed the feat/405/auto-load-new-activities branch from a4995e1 to 98fe59d Compare March 12, 2026 14:54
@nextcloud-command nextcloud-command force-pushed the feat/405/auto-load-new-activities branch from 98fe59d to ab0f2af Compare March 12, 2026 14:56
@miaulalala miaulalala force-pushed the feat/405/auto-load-new-activities branch from ab0f2af to 37693eb Compare March 12, 2026 17:28
@nextcloud-command nextcloud-command force-pushed the feat/405/auto-load-new-activities branch from 37693eb to 7fdaa98 Compare March 12, 2026 17:29
@miaulalala miaulalala requested a review from Copilot March 12, 2026 18:07

This comment was marked as outdated.

@miaulalala miaulalala force-pushed the feat/405/auto-load-new-activities branch from 7fdaa98 to 3d0d63e Compare March 12, 2026 19:46
@nextcloud-command nextcloud-command force-pushed the feat/405/auto-load-new-activities branch from 3d0d63e to ebd2050 Compare March 12, 2026 19:47
@miaulalala miaulalala force-pushed the feat/405/auto-load-new-activities branch from ebd2050 to 9ebdf54 Compare March 12, 2026 20:12
@miaulalala
Copy link
Collaborator Author

/compile amend

Fix #405

Signed-off-by: Anna Larch <anna@nextcloud.com>
Signed-off-by: nextcloud-command <nextcloud-command@users.noreply.github.com>
@nextcloud-command nextcloud-command force-pushed the feat/405/auto-load-new-activities branch from 9ebdf54 to 57f432c Compare March 12, 2026 20:14
const response = await ncAxios.get(generateOcsUrl('apps/activity/api/v2/activity/{filter}?format=json&previews=true&since={since}', { filter: props.filter, since }))
allActivities.value.push(...response.data.ocs.data.map((raw) => new ActivityModel(raw)))
const response = await ncAxios.get(generateOcsUrl('apps/activity/api/v2/activity/{filter}?format=json&previews=true&since={since}', { filter: props.filter, since }), { signal })
if (signal.aborted) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aborted signal should throw an error, I'm not sure it's gonna reach this code even. Please try to check whenever happening

})
} catch (error) {
if (axios.isCancel(error)) {
return
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be the correct handling for AbortController

allActivities.value.unshift(...newActivities)
} else {
// Queue for the indicator so reading position is not disrupted
pendingNewActivities.value.unshift(...newActivities)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're not at the top, prepending should not break the rendering, i think? so scroll position should remain the same

* Prepend all queued activities and scroll back to the top
*/
function loadPendingActivities() {
allActivities.value.unshift(...pendingNewActivities.value)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So button can just scroll to the top

Suggested change
allActivities.value.unshift(...pendingNewActivities.value)

class="activity-app__new-activities-indicator"
type="button"
@click="loadPendingActivities">
{{ n('activity', 'Load {count} new activity', 'Load {count} new activities', pendingNewActivities.length, { count: pendingNewActivities.length }) }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's loaded already, just not shown, until you click. Maybe just:

Suggested change
{{ n('activity', 'Load {count} new activity', 'Load {count} new activities', pendingNewActivities.length, { count: pendingNewActivities.length }) }}
{{ t('activity', 'New activities') }}

</template>
</NcEmptyContent>
<div ref="container" class="activity-app__container">
<button
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<button
<NcButton

@@ -26,6 +26,13 @@
</template>
</NcEmptyContent>
<div ref="container" class="activity-app__container">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can listen for @scroll event with a debounce and do this perhaps to hide the button?

const isNearTop = !container.value || container.value.scrollTop < 50
if (isNearTop && pendingNewActivities.value.length !== 0) {
	pendingNewActivities.value = []
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Auto refresh activities stream

3 participants