1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-04-04 12:52:06 -04:00

(notepad): Update tab loading with request ID validation

This commit is contained in:
purian23
2026-03-18 00:10:35 -04:00
parent fbe8cbb23f
commit 8e047f45f5
2 changed files with 28 additions and 0 deletions

View File

@@ -102,6 +102,14 @@ Singleton {
metadataFile.setText(JSON.stringify(metadata, null, 2))
}
function getTabById(tabId) {
for (var i = 0; i < tabs.length; i++) {
if (tabs[i].id === tabId)
return tabs[i]
}
return null
}
function loadTabContent(tabIndex, callback) {
if (tabIndex < 0 || tabIndex >= tabs.length) {
callback("")
@@ -109,6 +117,7 @@ Singleton {
}
var tab = tabs[tabIndex]
var requestTabId = tab.id
var fullPath = tab.isTemporary
? baseDir + "/" + tab.filePath
: tab.filePath
@@ -123,6 +132,16 @@ Singleton {
var fileChecker = fileExistsComponent.createObject(root, {
path: fullPath,
callback: (exists) => {
var currentTab = root.getTabById(requestTabId)
var currentPath = currentTab
? (currentTab.isTemporary ? baseDir + "/" + currentTab.filePath : currentTab.filePath)
: ""
if (!currentTab || currentPath !== fullPath) {
callback("")
return
}
if (exists) {
var loader = tabFileLoaderComponent.createObject(root, {
path: fullPath,