Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F4119171
RecentItemsProvider.js
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
RecentItemsProvider.js
View Options
const
{
CommandPaletteItem
,
CommandPaletteProvider
,
CommandPaletteActionResult
}
=
require
(
'../types.js'
);
const
createRecentItems
=
require
(
'../services/recentItems.js'
);
const
{
getNavigationAction
}
=
require
(
'../utils/providerActions.js'
);
const
recentItemsService
=
createRecentItems
();
/** @type {CommandPaletteProvider} */
module
.
exports
=
{
id
:
'recent'
,
isAsync
:
false
,
// We load from localStorage, so no need to debounce
debounceMs
:
0
,
keepStaleResultsOnQueryChange
:
false
,
/**
* Determines if this provider should handle the current query.
*
* @param {string} query The search query.
* @return {boolean}
*/
canProvide
(
query
)
{
// Provides results only when the query is empty
return
!
query
;
},
/**
* Gets the recent items.
* Items are expected to conform to the CommandPaletteItem structure
* as they were saved in that format or a compatible subset (like fulltext-search).
*
* @return {Array<CommandPaletteItem>} An array of recent items.
*/
getResults
()
{
const
items
=
recentItemsService
.
getRecentItems
();
// Ensure source is added by the provider
return
Array
.
isArray
(
items
)
?
items
.
map
(
(
item
)
=>
(
{
...
item
,
source
:
this
.
id
}
)
)
:
[];
},
/**
* Handles the selection of a recent item.
* Default action is to navigate to the item's URL.
*
* @param {CommandPaletteItem} item The selected item.
* @return {Promise<CommandPaletteActionResult>} Action result for the UI.
*/
async
onResultSelect
(
item
)
{
return
getNavigationAction
(
item
);
}
};
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Aug 19, 03:12 (2 w, 1 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
a6/1a/56e7f2f8f6d5e2be76e458154380
Default Alt Text
RecentItemsProvider.js (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment