Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Vanessa219 authored and tom2319273 committed Aug 3, 2024
1 parent aee3549 commit 0531c04
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
18 changes: 18 additions & 0 deletions app/src/layout/dock/Files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ export class Files extends Model {
<svg class="b3-list-item__arrow"><use xlink:href="#iconRight"></use></svg>
</span>
<span class="b3-list-item__text">${window.siyuan.languages.closeNotebook}</span>
<span class="counter fn__none" style="cursor: auto"></span>
</li>
<ul class="fn__none fn__flex-1"></ul>
</ul>`;
Expand Down Expand Up @@ -704,15 +705,24 @@ export class Files extends Model {
public init(init = true) {
let html = "";
let closeHtml = "";
let closeCounter = 0
window.siyuan.notebooks.forEach((item) => {
if (item.closed) {
closeCounter++;
closeHtml += this.genNotebook(item);
} else {
html += this.genNotebook(item);
}
});
this.element.innerHTML = html;
this.closeElement.lastElementChild.innerHTML = closeHtml;
const counterElement = this.closeElement.querySelector(".counter")
counterElement.textContent = closeCounter.toString()
if (closeCounter) {
counterElement.classList.remove("fn__none");
} else {
counterElement.classList.add("fn__none");
}
if (!init) {
return;
}
Expand Down Expand Up @@ -740,6 +750,9 @@ export class Files extends Model {
}
});
this.closeElement.lastElementChild.innerHTML = closeHTML;
const counterElement = this.closeElement.querySelector(".counter");
counterElement.textContent = (parseInt(counterElement.textContent) + 1).toString();
counterElement.classList.remove("fn__none")
}
}
});
Expand Down Expand Up @@ -784,6 +797,11 @@ export class Files extends Model {
}
const liElement = this.closeElement.querySelector(`li[data-url="${data.data.box.id}"]`) as HTMLElement;
if (liElement) {
const counterElement = this.closeElement.querySelector(".counter")
counterElement.textContent = (parseInt(counterElement.textContent) - 1).toString()
if (counterElement.textContent === "0") {
counterElement.classList.add("fn__none")
}
liElement.remove();
}
setNoteBook((notebooks: INotebook[]) => {
Expand Down
18 changes: 18 additions & 0 deletions app/src/mobile/dock/MobileFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ export class MobileFiles extends Model {
<svg class="b3-list-item__arrow"><use xlink:href="#iconRight"></use></svg>
</span>
<span class="b3-list-item__text">${window.siyuan.languages.closeNotebook}</span>
<span class="counter fn__none" style="cursor: auto"></span>
</li>
<ul class="fn__none fn__flex-1"></ul>
</ul>`;
Expand Down Expand Up @@ -292,15 +293,24 @@ export class MobileFiles extends Model {
public init(init = true) {
let html = "";
let closeHtml = "";
let closeCounter = 0;
window.siyuan.notebooks.forEach((item) => {
if (item.closed) {
closeCounter++;
closeHtml += this.genNotebook(item);
} else {
html += this.genNotebook(item);
}
});
this.element.innerHTML = html;
this.closeElement.lastElementChild.innerHTML = closeHtml;
const counterElement = this.closeElement.querySelector(".counter")
counterElement.textContent = closeCounter.toString()
if (closeCounter) {
counterElement.classList.remove("fn__none");
} else {
counterElement.classList.add("fn__none");
}
if (!init) {
return;
}
Expand Down Expand Up @@ -407,6 +417,9 @@ export class MobileFiles extends Model {
}
});
this.closeElement.lastElementChild.innerHTML = closeHTML;
const counterElement = this.closeElement.querySelector(".counter");
counterElement.textContent = (parseInt(counterElement.textContent) + 1).toString();
counterElement.classList.remove("fn__none")
}
}
});
Expand Down Expand Up @@ -461,6 +474,11 @@ export class MobileFiles extends Model {
const liElement = this.closeElement.querySelector(`li[data-url="${data.data.box.id}"]`) as HTMLElement;
if (liElement) {
liElement.remove();
const counterElement = this.closeElement.querySelector(".counter")
counterElement.textContent = (parseInt(counterElement.textContent) - 1).toString()
if (counterElement.textContent === "0") {
counterElement.classList.add("fn__none")
}
}
setNoteBook((notebooks: INotebook[]) => {
const html = this.genNotebook(data.data.box);
Expand Down

0 comments on commit 0531c04

Please sign in to comment.