1- using System . Linq ;
2- using Microsoft . CommandPalette . Extensions . Toolkit ;
3- using Microsoft . CommandPalette . Extensions ;
4-
5- using CmdPalNotionExtension . Notion ;
1+ using CmdPalNotionExtension . Helpers ;
62using CmdPalNotionExtension . ListItems ;
3+ using CmdPalNotionExtension . Notion ;
4+ using Microsoft . CommandPalette . Extensions ;
5+ using Microsoft . CommandPalette . Extensions . Toolkit ;
6+ using System . Collections . Generic ;
7+ using System . Linq ;
78
89namespace CmdPalNotionExtension . Controls . Pages ;
910
1011internal sealed partial class RecentPagesPage : ListPage
1112{
1213 private readonly NotionDataProvider _dataProvider ;
1314 private readonly ListItemFactory _listItemFactory ;
15+ private readonly Resources _resources ;
16+
17+ private string ? _cursor = string . Empty ;
18+ private List < IListItem > _currentPages = new List < IListItem > ( ) ;
1419
15- public RecentPagesPage ( NotionDataProvider dataProvider , ListItemFactory listItemFactory )
20+ public RecentPagesPage (
21+ NotionDataProvider dataProvider ,
22+ ListItemFactory listItemFactory ,
23+ Resources resources )
1624 {
1725 _dataProvider = dataProvider ;
1826 _listItemFactory = listItemFactory ;
27+ _resources = resources ;
1928
20- Title = "Recent Pages" ;
29+ Title = _resources . GetResource ( "Pages_Recent_Pages_Title" ) ;
2130 Icon = new ( "\uE823 " ) ;
2231 }
2332
2433 public override IListItem [ ] GetItems ( )
2534 {
26- var res = _dataProvider . GetRecentNotionPagesAsync ( ) . GetAwaiter ( ) . GetResult ( ) ;
35+ var res = _dataProvider . GetRecentNotionPagesAsync ( _cursor ) . GetAwaiter ( ) . GetResult ( ) ;
36+
37+ if ( res != null )
38+ {
39+ _cursor = res . NextCursor ;
40+ _currentPages . AddRange ( res . Results . Select ( s => _listItemFactory . Create ( s ) ) ) ;
41+ }
2742
28- return res . Select ( item => _listItemFactory . Create ( item ) ) . ToArray ( ) ;
43+ return _currentPages . ToArray ( ) ;
2944 }
3045
3146 public CommandItem ToCommandItem ( )
3247 {
3348 return new CommandItem ( this )
3449 {
35- Title = "Recent Pages" ,
36- Subtitle = "Recently viewed pages" ,
50+ Title = _resources . GetResource ( "Pages_Recent_Pages_Title" ) ,
51+ Subtitle = _resources . GetResource ( "Pages_Recent_Pages_SubTitle" ) ,
52+ Icon = NotionHelper . Icon
3753 } ;
3854 }
3955}
0 commit comments