Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto-refresh #31

Open
2 tasks
georgehrke opened this issue Sep 17, 2016 · 15 comments · May be fixed by #2917
Open
2 tasks

Auto-refresh #31

georgehrke opened this issue Sep 17, 2016 · 15 comments · May be fixed by #2917
Assignees
Labels
1. to develop Accepted and waiting to be taken care of enhancement New feature request skill:frontend Issues and PRs that require JavaScript/Vue/styling development skills

Comments

@georgehrke
Copy link
Member

georgehrke commented Sep 17, 2016

We should implement this in two steps:

  • periodically check for updates of event in known calendars
  • periodically check for new or updated calendars

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@georgehrke georgehrke added 1. to develop Accepted and waiting to be taken care of enhancement New feature request skill:frontend Issues and PRs that require JavaScript/Vue/styling development skills good first issue Small tasks with clear documentation about how and in which place you need to fix things in. labels Sep 17, 2016
@georgehrke georgehrke added this to the 1.5-current milestone Sep 17, 2016
@georgehrke georgehrke added 2. developing Work in progress and removed 1. to develop Accepted and waiting to be taken care of labels Oct 22, 2016
@georgehrke georgehrke self-assigned this Oct 22, 2016
@georgehrke
Copy link
Member Author

requires #209

@georgehrke georgehrke modified the milestones: 1.6.0-next, 1.5.0-current Jan 16, 2017
@georgehrke georgehrke removed the good first issue Small tasks with clear documentation about how and in which place you need to fix things in. label Mar 25, 2017
@georgehrke
Copy link
Member Author

Let's implement #40 first.

Otherwise stuff like keeping events being edited locked will be a huge pain.

@georgehrke georgehrke modified the milestones: 1.7.0-next, 1.6.0-current May 17, 2017
@georgehrke georgehrke added 1. to develop Accepted and waiting to be taken care of and removed 2. developing Work in progress labels Nov 5, 2018
@cl4x
Copy link

cl4x commented Jul 11, 2019

no news on this features? in 1.7.0 the autorefresh do not work

@georgehrke
Copy link
Member Author

in 1.7.0 the autorefresh do not work

Not surprising, since this issue is still open 😉

Please check the information on the right. It contains all the information you need:
A1E77917-B021-414C-96EC-E55A044874C6

@cl4x
Copy link

cl4x commented Jul 11, 2019

ok sorry, i have see this
immagine

@vchrizz
Copy link

vchrizz commented Nov 1, 2019

using following workaround until this issue is fixed:
in file core/templates/layout.user.php add after <title>

                <?php
			// if loaded app is calendar, add html meta tag to refresh page every 60 seconds
			if ($_['appid']=='calendar') {
				print '<meta http-equiv="refresh" content="60">';
			}
		?>

@georgehrke
Copy link
Member Author

I would strongly advise anyone against using that workaround, because it just reloads the calendar app every 60 seconds, no matter whether you are just creating / editing an event or not. Definitely not a solution.

@vchrizz
Copy link

vchrizz commented Nov 1, 2019

correct, thanks for pointing that out, i should have mentioned that!
as i do not use the app via webbrowser, but manage my events via smartphone (synced from another calendar app), this is not a problem in my case.
for explanation: i use a tablet on a wall to display the nextcloud calendar (in a webbrowser) and for that it is not practical to be forced to manually refresh the page to see the recent calendar status.
(if 60 seconds is too fast, you may also set it to some higher value like 300 seconds for a refresh every 5 minutes)

@dev-zero
Copy link

dev-zero commented Mar 6, 2020

Will the tasks app automatically profit from the implementation in the calendar app or should I open a separate feature request there if I would like to see automatically refreshed task lists?

@georgehrke
Copy link
Member Author

@dev-zero No, this issue is only about the calendar app. The tasks app will need to implement this separately.

@georgehrke georgehrke mentioned this issue Apr 17, 2020
3 tasks
@georgehrke georgehrke modified the milestones: 2.1.0, 2.2.0 Sep 4, 2020
@JonathanTreffler
Copy link
Contributor

It would be nice if this feature would also be implemented for the Dashboard Widget of the Calendar App.

@piiskop
Copy link

piiskop commented Feb 22, 2021

The client app should create a connection to the server so that every time something will be changed the server sends out the signal to all the clients and only the changed part will be updated.

@azul
Copy link
Contributor

azul commented Feb 22, 2021

I investigated this some. Here's my findings:

Calendars

The app keeps track of the calendars in display in a vue store module called calendars.
Calendars can be removed and added - but this does not trigger a reload of the unerlying data.

TimeRanges

The only loads the events it currently has to display. It uses TimeRanges to keep track of these. If you move to the next timespan (day, week, month) the calendar indicator will spin to indicate it's loading. If you move back and forth it will use the cached data and not query the server.
One can clear those TimeRanges with:

$store.commit('clearFetchedTimeRanges')

This will trigger requests when navigating to previously visited timespans.

CalendarObjects

However even though these request will display new events it contains it will not update existing events. That's because when parsing the data it is turned into CalendarObjects which are stored indexed by their id and will not be updated if an object with the same id already exists:

// src/store/calendarObjects.js
	/**
	 * Adds an array of calendar-objects to the store
	 *
	 * @param {Object} state The store data
	 * @param {Object} data The destructuring object
	 * @param {Object[]} data.calendarObjects Calendar-objects to add
	 */
	appendCalendarObjects(state, { calendarObjects = [] }) {
		for (const calendarObject of calendarObjects) {
			if (!state.calendarObjects[calendarObject.id]) {
				Vue.set(state.calendarObjects, calendarObject.id, calendarObject)
			}
		}
	},

This is the function called from getEventsFromCalendarInTimeRange when the calendars are displayed.
So even if the TimeRange has been removed and therefore reloaded the calendar in the view will not update because hte old data structure is not replaced.

So in order to effectively reload a calendar I need to take these steps from the console (assuming Vue Dev tools are installed and active and the Calendar component is selected as $vm0:

$vm0.$store.commit('deleteCalendarObject',  {
  calendarObject: {
    id: $vm0.$store.getters.enabledCalendars[0].calendarObjects[0]
  }
})
// ... repeat this for all calendar objects
$vm0.$store.commit('deleteCalendarObject',  {
  calendarObject: {
    id: $vm0.$store.getters.enabledCalendars[0].calendarObjects[3]
  }
})
$vm0.$store.commit('clearFetchedTimeRanges')
$vm0.$store.commit('deleteCalendar', {calendar: $vm0.$store.getters.enabledCalendars[0]})
$vm0.$store.dispatch('getPublicCalendars', {tokens: $vm0.$route.params.tokens.split("-")})

@azul
Copy link
Contributor

azul commented Feb 22, 2021

Looks like the calendar itself has a ctag property that will tell us if anything in the calendar was updated. That seems very useful in order to avoid invalidating the caches without needs.

After reading the sabredav docs some more it seems like sync tokens are what we want to use:

  • Remember the sync token when loading the calendar initially.
  • Query for syncs using the sync token regularly.
  • If there was an update compare the ids of the changed objects and the objects that have been loaded already.
  • Fetch the updates from the server for the intersection of the two sets - objects that have been updated and were loaded already.
  • cleanup the objects that were removed.

@azul
Copy link
Contributor

azul commented Feb 23, 2021

Looks like the sync token approach would require at least some work on nextcloud/cdav-library#9.

azul added a commit that referenced this issue Feb 25, 2021
Fetch the open calendars every 20 seconds
and check if they have changed since they were loaded.

If a calendar changed remove all it's data from the store
and thereby effectively trigger a reload.

This is a fairly brute force approach as it drops all known data
rather than fetching only the data that changed via the caldav sync API.

However Caldav sync is yet to be implemented. (nextcloud/cdav-library#9)
So this serves as a workaround for the time being.

See #31.
azul added a commit that referenced this issue Feb 25, 2021
Fetch the open calendars every 20 seconds
and check if they have changed since they were loaded.

If a calendar changed remove all it's data from the store
and thereby effectively trigger a reload.

This is a fairly brute force approach as it drops all known data
rather than fetching only the data that changed via the caldav sync API.

However Caldav sync is yet to be implemented. (nextcloud/cdav-library#9)
So this serves as a workaround for the time being.

See #31.

Signed-off-by: Azul <azul@riseup.net>
@azul azul linked a pull request Feb 25, 2021 that will close this issue
13 tasks
azul added a commit that referenced this issue Feb 26, 2021
Fetch the open calendars every 20 seconds
and check if they have changed since they were loaded.

If a calendar changed remove all it's data from the store
and thereby effectively trigger a reload.

This is a fairly brute force approach as it drops all known data
rather than fetching only the data that changed via the caldav sync API.

However Caldav sync is yet to be implemented. (nextcloud/cdav-library#9)
So this serves as a workaround for the time being.

See #31.

Signed-off-by: Azul <azul@riseup.net>
azul added a commit that referenced this issue Feb 26, 2021
* Add new calendars to the list as they show up.
* Reload non-public calendars if they are updated on the server.

Fixes #31.

This works but it is not an optimal solution:
* If a calendar changes it reloads the current view
  no matter wether anyting in the view changed or not.
* If a calendar changes it drops all cached events
  even if they did not change.
* If an event is added to the calendar or moved
  this calendar will also be reloaded because the new event
  changed the syncToken on the server.
* If a calendar changed
  it will be added to the bottom of the list of calendars.

I would be fine with most of these but the last one needs to be fixed.

Signed-off-by: Azul <azul@riseup.net>
azul added a commit that referenced this issue Feb 26, 2021
Fetch the open calendars every 20 seconds
and check if they have changed since they were loaded.

If a calendar changed remove all it's data from the store
and thereby effectively trigger a reload.

This is a fairly brute force approach as it drops all known data
rather than fetching only the data that changed via the caldav sync API.

However Caldav sync is yet to be implemented. (nextcloud/cdav-library#9)
So this serves as a workaround for the time being.

See #31.

Signed-off-by: Azul <azul@riseup.net>
azul added a commit that referenced this issue Feb 26, 2021
* Add new calendars to the list as they show up.
* Reload non-public calendars if they are updated on the server.

Fixes #31.

This works but it is not an optimal solution:
* If a calendar changes it reloads the current view
  no matter wether anyting in the view changed or not.
* If a calendar changes it drops all cached events
  even if they did not change.
* If an event is added to the calendar or moved
  this calendar will also be reloaded because the new event
  changed the syncToken on the server.
* If a calendar changed
  it will be added to the bottom of the list of calendars.

I would be fine with most of these but the last one needs to be fixed.

Signed-off-by: Azul <azul@riseup.net>
@ChristophWurst ChristophWurst modified the milestones: 2.2.0, 2.3.0 Mar 24, 2021
@ChristophWurst ChristophWurst modified the milestones: v2.3.0, v2.4.0 Jun 24, 2021
@ChristophWurst ChristophWurst modified the milestones: v2.4.0, v2.4.1 Nov 25, 2021
@tcitworld tcitworld removed this from the v2.4.1 milestone Dec 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1. to develop Accepted and waiting to be taken care of enhancement New feature request skill:frontend Issues and PRs that require JavaScript/Vue/styling development skills
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants