rnschedule icon indicating copy to clipboard operation
rnschedule copied to clipboard

Opening Calendar on physical device

Open eyalabadi98 opened this issue 6 years ago • 11 comments

Hello.

When I run the app with my physical device, the schedule doesnt respond.

More specifically, when I press the date button (to open the calendar view) it doesnt respond.

This doesnt happen on the simulator. I am suspecting an issue with how the Date is handeled in V8 vs chrome JS

eyalabadi98 avatar Oct 25 '18 15:10 eyalabadi98

It was an issue with Date but on my part. I guess RN doesn’t like New Date when running without a chrome debugger

eyalabadi98 avatar Oct 25 '18 18:10 eyalabadi98

Interesting. I tried to run all of the actual dates through MomentJS to deal with that sort of thing - for reasons I don't understand JS seems to just be a little janky when it comes to manipulating and working with dates. Let me know if you need anything else - or have suggestions.

wmlutz avatar Oct 25 '18 18:10 wmlutz

Actually this is still an ongoing issue.

My code:

          let teamHere = props.myschedule[i];
          console.log("TeamHere", teamHere)
          let dateStamp = teamHere['date'] + ' ' + teamHere['time'];
          let dateVa1 = moment(dateStamp).format('YYYY-MM-DD HH:mm:ss');
          let minutes = 45;
          let durationClonse = moment(dateStamp);
          let endTime = durationClonse.add(minutes, 'minutes').format('YYYY-MM-DD HH:mm:ss');
          // console.log("endTime", endTime);
          data.push({
                title: teamHere['team1']['category'] + ' ' +  teamHere['tournament']['sport'],
                subtitle: teamHere['team1']['country'] + ' ' + teamHere['team1']['number'] + ' vs. ' + teamHere['team2']['country'] + ' ' + teamHere['team2']['number'] + ' ' + teamHere['location'],
                // subtitle: teamHere['text'] + ' ' + teamHere['location'],
                start: dateVa1,
                end: endTime,
                // color: getRandomColor() + ''

            });

When I run this code with a debugger, it works fine. When I run it without, it loads very slowly

When I reduce the amount of loops from around 75 to 5-10, it works perfectly. If i remove your component from the return, the app works fine.

I am at a loss here.

eyalabadi98 avatar Oct 26 '18 05:10 eyalabadi98

@eyalabadi98 - OK got it. It sounds like a speed issue. I did use some hacky/brute force techniques when building so I could get it out faster.

First: disclaimer - I have done zero testing on the component. I hacked it together for my own project. That means that I have done no optimization for speed. In fact I'm pretty sure it's on the ReadMe as a 'to-do'.

Second: suggestion - if you need this working (or working faster at least) soonish I'd recommend doing a PR and diving in yourself. I built it and I'm the only maintainer/contributor at the moment and I my personal schedule won't let me do a ton of work on this for another week or so. Sorry about that.

wmlutz avatar Oct 26 '18 16:10 wmlutz

Were you able to reproduce this error? I want to make sure its the component, not my implementation

eyalabadi98 avatar Oct 26 '18 16:10 eyalabadi98

Thanks for the PR/help!

wmlutz avatar Oct 26 '18 18:10 wmlutz

This is actually still an issue.

The culprit here is moment-range. It makes it very slow to load items when running on the device.

Any ideas on how to go about?

eyalabadi98 avatar Oct 30 '18 10:10 eyalabadi98

I use moment-range to manage appointment overlapping in the View (ProcRows - line 7). I'm pretty sure that's the only time I used it. The right answer is to make our own "overlap" function and then remove the moment-range library.

const overlap = (appt1, appt2) => {
  // Annoying if statement.
    return true

 return false
}

wmlutz avatar Oct 30 '18 14:10 wmlutz

Ok, slightly more complicated than that, but I can work on it tonight.

wmlutz avatar Oct 30 '18 15:10 wmlutz

@eyalabadi98 - I refactored to remove moment-range as well as moment as many places as I could - reverting to JS' native date. Hopefully that improves the speed. Can you test it a bit and let me know?

wmlutz avatar Nov 02 '18 21:11 wmlutz

Hey Wmlutz! Thanks.

I think it did actually help it! Thanks for your help!

Ill be pushing also an update on the currenttime as your module displays the timenow incorrectly if the hoursize is different. You did hour * hour_size rather than divide

eyalabadi98 avatar Nov 03 '18 11:11 eyalabadi98