Skip to content

Commit 5760707

Browse files
committed
feat: add x to delete corresponding entry
1 parent 812df95 commit 5760707

File tree

1 file changed

+46
-14
lines changed

1 file changed

+46
-14
lines changed

src/lib/recents.js

Lines changed: 46 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -86,19 +86,36 @@ const recents = {
8686
return name;
8787
};
8888

89+
const self = this;
90+
8991
if (type === "dir" || type === "all") {
9092
let dirs = this.folders;
9193
for (let dir of dirs) {
9294
const { url } = dir;
9395

94-
all.push([
95-
{
96-
type: "dir",
97-
val: dir,
96+
const dirValue = {
97+
type: "dir",
98+
val: dir,
99+
};
100+
101+
const tailElement = tag("span", {
102+
className: "icon clearclose",
103+
dataset: {
104+
action: "clear",
105+
},
106+
});
107+
108+
all.push({
109+
value: dirValue,
110+
text: shortName(url),
111+
icon: "folder",
112+
tailElement: tailElement,
113+
ontailclick: (e) => {
114+
const $item = e.currentTarget.closest(".tile");
115+
if ($item) $item.remove();
116+
self.removeFolder(dir.url);
98117
},
99-
shortName(url),
100-
"icon folder",
101-
]);
118+
});
102119
}
103120
}
104121

@@ -107,14 +124,29 @@ const recents = {
107124
for (let file of files) {
108125
if (!file) continue;
109126
const name = shortName(Url.parse(file).url);
110-
all.push([
111-
{
112-
type: "file",
113-
val: file,
127+
128+
const fileValue = {
129+
type: "file",
130+
val: file,
131+
};
132+
const tailElement = tag("span", {
133+
className: "icon clearclose",
134+
dataset: {
135+
action: "clear",
136+
},
137+
});
138+
139+
all.push({
140+
value: fileValue,
141+
text: name,
142+
icon: helpers.getIconForFile(name),
143+
tailElement: tailElement,
144+
ontailclick: (e) => {
145+
const $item = e.currentTarget.closest(".tile");
146+
if ($item) $item.remove();
147+
self.removeFile(file);
114148
},
115-
name,
116-
helpers.getIconForFile(name),
117-
]);
149+
});
118150
}
119151
}
120152

0 commit comments

Comments
 (0)