stevencohn / OneMore

A OneNote add-in with simple, yet powerful and useful features
Mozilla Public License 2.0
2.53k stars 213 forks source link

Copy all from OM Calender doesn't always copy all items for the day #1513

Closed jasonjac2 closed 2 weeks ago

jasonjac2 commented 1 month ago

Problem to Solve

Cal in cal mode, not list mode. Did it for today and it gave me 24 entries. Did it for yesterday and it gave me 1, i.e. the last on in the list.

image in the month view. Clicked the Copy All links for day

From log: 01|10:51:47.817| Starting OneMoreCalendar 01|10:52:12.229| copying 24 hyperlinks from 30/07/2024 00:00:00 01|10:52:40.924| copying 1 hyperlinks from 29/07/2024 00:00:00 01|10:53:01.698| copying 1 hyperlinks from 29/07/2024 00:00:00 01|10:53:22.190| copying 1 hyperlinks from 29/07/2024 00:00:00

Changed the settings (to make the list refresh) went to yesterday 1st. scrolled the list for the day (more than can fit in the cell) Clicked the copy it then gave me the full list checking the log... 01|10:59:18.465| copying 44 hyperlinks from 29/07/2024 00:00:00

So it appears to be linked to the second time you click copy maybe?

Environment (if applicable)

Version 6.5.0 with OneNote 16.0.17726.20160

Additional Context

Add any other context about the problem here. Attach page XML file or the app log file as appropriate. You can find the log file here: %localappdata%\temp\OneMore.log

THE FINE PRINT This is a hobby project that I started for myself. I'm happy to take requests and will promise to consider each one carefully but offer no guarantees that I will ultimately agree to their usefulness or have time to implement any of them. If OneNote offers a "close enough" work-around then I will probably reject the request - you've been warned!

stevencohn commented 1 month ago

Has the calendar app been open for since early yesterday, before you updated those missing pages?

Haven't been able to repro this. When you navigate to a month, it captures a list of pages updated for each day. If you click Copy for a day, it does capture a cache of updated pages for that day. If you then update more pages, the cache is not updated until you navigate away from that month and then back. I can remove this cache, making it only slightly (milliseconds) to copy pages for a day. But I'm not sure I understand the exact workflow here to repro.

stevencohn commented 1 month ago

Full disclosure, the cache can be improved to fix this. I'll take that on...

jasonjac2 commented 1 month ago

I can reproduce on two machines (logged into same accounts). I have only just stumbled accross it, so testing is limited. I just tried on another machine and got the same outcome. 28th has about 10 items, 29th 44 items, 30th about 25 items.

Its like it is picking up the last entry from the day before sometimes.

It feels to me like a poorly initialised "start of list" pointer.

jasonjac2 commented 1 month ago

doing you a quick streams vid if that's ok, can't share it here though.

stevencohn commented 1 month ago

Cheers. The problem is pointed out by the comment here

That "been here before" assumption should never have been made :-(

jasonjac2 commented 1 month ago

sent you over an expiring streams link.

stevencohn commented 1 month ago

Thanks for that. I need to emulate a ton a updates. I normally update only a few pages per day.

You need a Copy Month command or export ;-)

jasonjac2 commented 1 month ago
stevencohn commented 1 month ago

day is model describing the calendar day. day.Pages is the list of pages described by a page model day.Pages.Exists looks for at least one page that matches the criteria p.Hyperlink is not null means a page that has a hyperlink set

So it's only looking for one and then stopping. The assumption made by the comment is what I described above, where you load the month view and see n pages and click Copy to load hyperlinks for those pages, then update more pages; without navigating or refreshing the view, Calendar will not attempt to load hyperlinks for the subsequently updated pages because it sees that at least one has already been loaded. Unfortunately, after seeing your video, this may be red herring and I'll have to dig deeper.

jasonjac2 commented 1 month ago

Thanks for the explanation and hope the video helped. it's the p => that got me. Is it kind of a p is a place holder to the items in the pages collection and then you it is checking the condition, a bit like "foreach pages"

stevencohn commented 1 month ago

C# has lambda expressions, just "syntactical sugar, smoke and mirrors" as Anders Hejlsberg once said.

things.Exists(x => x.foo == 123)

is roughly the same as

var found = false;
foreach (var x in things) 
{
    if (x.foo == 123) 
   {
       found = true;
       break; 
   }
}