CroudTech / vue-fullcalendar

FullCalendar Wrapper for vue
MIT License
483 stars 100 forks source link

rebuild-sources should use removeEventSources ? #99

Closed smingam closed 6 years ago

smingam commented 6 years ago

Hello again ! I've noticed some, imho, wrong behavior when using a computed as event-sources Because rebuild-sources only remove events from the calendar instead of removing sources, every time the computed event-sources is triggered by a change, you end up with a cumulative display of all the sources since the first load. But that line is more than a year old, so I'm wondering what if I'm doing something wrong or if it's a bug.

For the story, I'm trying to fix my source toggling that doesn't work anymore:

 availabilityMask: function (val) { 
            this.$refs.calendar.fireMethod('removeEventSources') 
            if (val) { 
                this.$refs.calendar.fireMethod('addEventSource', this.fcEventMask) 
            } else { 
                this.$refs.calendar.fireMethod('addEventSource', this.fcEventComp) 
            }
  }

For some reason, it removes and add the new source, but doesn't fetch anything anymore (even with a setInterval that I use for 5sec refresh of the calendar). So I tried to use a computed property that depend on availabilityMask that now trigger the rebuild-sources in the watch, with the effect noticed above...

Thanks for your support!

BrockReece commented 6 years ago

I think you are right, it's not a part of the codebase I use this too often. Could I ask you to test if I put a PR in for it?

Have you tried refetchEvents to fix your original issue?

smingam commented 6 years ago

Yes like I said, I have a timer that call this.$refs.calendar.$emit('refetch-events') every 5 seconds to refresh the calendar, and it doesn't works after the first toggle (so even toggling back to fcEventComp doesn't do anything too). Because of webpack & stuff, I'm having an hard time debugging that if...else... for some reason I can't set a breakpoint on it, but looking directly into fullcalendar.js, I can see it looks like it's doing what it should be, which is puzzling. It just doesn't do an HTTP call anymore.

I've tested the removeEventSources in rebuild-sources it works perfectly in my case. (atm as a workaround, I just call this.$refs.calendar.fireMethod('removeEventSources') in my toggle watcher and your eventSources watcher do the rest) You want me to do a PR? I've never done one on github (!) but there is always a start :)

BrockReece commented 6 years ago

Sure, make a PR and I will review it, always happy to help anyone with their first PR 👍