Skip to content

Commit a8c3dd2

Browse files
committed
New star node for featured items
Signed-off-by: worksofliam <[email protected]>
1 parent 7c338d0 commit a8c3dd2

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/views/queryHistoryView/index.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ export class queryHistory implements TreeDataProvider<any> {
124124
let pastWeekQueries: PastQueryNode[] = [];
125125
let pastMonthQueries: PastQueryNode[] = [];
126126
let olderQueries: PastQueryNode[] = [];
127+
const starredQueries = currentList.filter(queryItem => queryItem.starred);
128+
const hasStarredQueries = starredQueries.length > 0;
127129

128130
currentList.forEach(queryItem => {
129131
// The smaller the unix value, the older it is
@@ -140,8 +142,11 @@ export class queryHistory implements TreeDataProvider<any> {
140142

141143
let nodes: TimePeriodNode[] = [];
142144

145+
if (hasStarredQueries) {
146+
nodes.push(new TimePeriodNode(`Starred`, starredQueries.map(q => new PastQueryNode(q)), {expanded: true, stars: true}));
147+
}
143148
if (pastDayQueries.length > 0) {
144-
nodes.push(new TimePeriodNode(`Past day`, pastDayQueries, true));
149+
nodes.push(new TimePeriodNode(`Past day`, pastDayQueries, {expanded: !hasStarredQueries}));
145150
}
146151
if (pastWeekQueries.length > 0) {
147152
nodes.push(new TimePeriodNode(`Past week`, pastWeekQueries));
@@ -163,11 +168,11 @@ export class queryHistory implements TreeDataProvider<any> {
163168
}
164169

165170
class TimePeriodNode extends TreeItem {
166-
constructor(public period: string, private nodes: PastQueryNode[], expanded = false) {
167-
super(period, expanded ? TreeItemCollapsibleState.Expanded : TreeItemCollapsibleState.Collapsed);
171+
constructor(title: string, private nodes: PastQueryNode[], opts: { expanded?: boolean, stars?: boolean } = {}) {
172+
super(title, opts.expanded ? TreeItemCollapsibleState.Expanded : TreeItemCollapsibleState.Collapsed);
168173
this.contextValue = `timePeriod`;
169174

170-
this.iconPath = new ThemeIcon(`calendar`);
175+
this.iconPath = new ThemeIcon(opts.stars ? `star-full` : `calendar`);
171176
}
172177

173178
getChildren() {

0 commit comments

Comments
 (0)