fix: add missing state. prefix to all bare state variable references across all modules
All checks were successful
CI / lint (push) Successful in 15s
CI / security (push) Successful in 8s
CI / test (push) Successful in 16s
CI / build (push) Successful in 2s

This commit is contained in:
Bruno Charest 2026-05-28 18:33:39 -04:00
parent 75fac8256b
commit 148b3851ae
8 changed files with 47 additions and 47 deletions

View File

@ -330,7 +330,7 @@ function initLoginForm() {
const AdminPanel = {
_modal: null,
_allVaults: [],
_state.allVaults: [],
show() {
this._createModal();
@ -378,9 +378,9 @@ const AdminPanel = {
// Also load available vaults
try {
const vaultsData = await api("/api/vaults");
this._allVaults = vaultsData.map((v) => v.name);
this._state.allVaults = vaultsData.map((v) => v.name);
} catch (e) {
this._allVaults = [];
this._state.allVaults = [];
}
this._renderUsers(users);
} catch (err) {
@ -486,8 +486,8 @@ const AdminPanel = {
document.getElementById("admin-user-form").addEventListener("submit", async (e) => {
e.preventDefault();
const form = e.target;
const allVaults = document.getElementById("admin-all-vaults").checked;
const selectedVaults = allVaults ? ["*"] : Array.from(form.querySelectorAll('input[name="vault"]:checked')).map((cb) => cb.value);
const state.allVaults = document.getElementById("admin-all-vaults").checked;
const selectedVaults = state.allVaults ? ["*"] : Array.from(form.querySelectorAll('input[name="vault"]:checked')).map((cb) => cb.value);
try {
if (isEdit) {

View File

@ -98,7 +98,7 @@ function _humanizeDelta(mtime) {
}
function _refreshRecentTimestamps() {
if (activeSidebarTab !== "recent" || !_recentFilesCache.length) return;
if (state.activeSidebarTab !== "recent" || !_recentFilesCache.length) return;
const items = document.querySelectorAll(".recent-item");
items.forEach((item, i) => {
if (i < _recentFilesCache.length) {
@ -165,7 +165,7 @@ function switchSidebarTab(tab) {
const placeholders = { vaults: "Filtrer fichiers...", tags: "Filtrer tags...", recent: "" };
filterInput.placeholder = placeholders[tab] || "";
}
const query = filterInput ? (sidebarFilterCaseSensitive ? filterInput.value.trim() : filterInput.value.trim().toLowerCase()) : "";
const query = filterInput ? (state.sidebarFilterCaseSensitive ? filterInput.value.trim() : filterInput.value.trim().toLowerCase()) : "";
if (query) {
if (tab === "vaults") performTreeSearch(query);
else if (tab === "tags") filterTagCloud(query);
@ -653,7 +653,7 @@ async function loadHiddenFilesSettings() {
function renderHiddenFilesSettings(container, allSettings) {
container.innerHTML = "";
if (!allVaults || state.allVaults.length === 0) {
if (!state.allVaults || state.allVaults.length === 0) {
container.innerHTML = '<div style="padding:12px;color:var(--text-muted)">Aucun vault configuré</div>';
return;
}

View File

@ -153,7 +153,7 @@ const DashboardRecentWidget = {
_currentFilter: "",
async load(vaultFilter = "") {
const v = vaultFilter || selectedContextVault || "all";
const v = vaultFilter || state.selectedContextVault || "all";
this._currentFilter = v;
this.showLoading();
@ -371,7 +371,7 @@ const DashboardRecentWidget = {
// Keep first option "Tous les vaults"
while (select.options.length > 1) select.remove(1);
if (typeof allVaults !== "undefined" && Array.isArray(state.allVaults)) {
if (typeof state.allVaults !== "undefined" && Array.isArray(state.allVaults)) {
state.allVaults.forEach((v) => {
const opt = document.createElement("option");
opt.value = v.name;
@ -401,7 +401,7 @@ const DashboardBookmarkWidget = {
_currentFilter: "",
async load(vaultFilter = "") {
const v = vaultFilter || selectedContextVault || "all";
const v = vaultFilter || state.selectedContextVault || "all";
this._currentFilter = v;
this.showLoading();

View File

@ -108,7 +108,7 @@ function initSearch() {
caseBtn.addEventListener("click", () => { state.searchCaseSensitive = !state.searchCaseSensitive; _updateToggleUI(); _research(); });
if (wordBtn) wordBtn.addEventListener("click", () => { state.searchWholeWord = !state.searchWholeWord; _updateToggleUI(); _research(); });
if (regexBtn) regexBtn.addEventListener("click", () => { state.searchRegex = !state.searchRegex; _updateToggleUI(); _research(); });
if (filterBtn) filterBtn.addEventListener("click", () => { state.searchFilterVisible = !state.searchFilterVisible; if (filterRow) filterRow.style.display = searchFilterVisible ? "flex" : "none"; _updateToggleUI(); });
if (filterBtn) filterBtn.addEventListener("click", () => { state.searchFilterVisible = !state.searchFilterVisible; if (filterRow) filterRow.style.display = state.searchFilterVisible ? "flex" : "none"; _updateToggleUI(); });
// Result navigation (up/down arrows + Enter)
let _searchResultIdx = -1;

View File

@ -676,7 +676,7 @@ function initSidebarFilter() {
clearBtn.style.display = hasText ? "flex" : "none";
clearTimeout(state.filterDebounce);
state.filterDebounce = setTimeout(async () => {
const q = sidebarFilterCaseSensitive ? input.value.trim() : input.value.trim().toLowerCase();
const q = state.sidebarFilterCaseSensitive ? input.value.trim() : input.value.trim().toLowerCase();
if (hasText) {
if (state.activeSidebarTab === "vaults") {
await performTreeSearch(q);
@ -696,7 +696,7 @@ function initSidebarFilter() {
caseBtn.addEventListener("click", async () => {
state.sidebarFilterCaseSensitive = !state.sidebarFilterCaseSensitive;
caseBtn.classList.toggle("active");
const q = sidebarFilterCaseSensitive ? input.value.trim() : input.value.trim().toLowerCase();
const q = state.sidebarFilterCaseSensitive ? input.value.trim() : input.value.trim().toLowerCase();
if (input.value.trim()) {
if (state.activeSidebarTab === "vaults") {
await performTreeSearch(q);
@ -742,7 +742,7 @@ async function performTreeSearch(query) {
async function restoreSidebarTree() {
await refreshSidebarForContext();
if (state.currentVault) {
focusPathInSidebar(state.currentVault, currentPath || "", { alignToTop: false }).catch(() => {});
focusPathInSidebar(state.currentVault, state.currentPath || "", { alignToTop: false }).catch(() => {});
}
}
@ -838,8 +838,8 @@ function filterSidebarTree(query) {
const matchingItems = new Set();
items.forEach((item) => {
const text = sidebarFilterCaseSensitive ? item.textContent : item.textContent.toLowerCase();
const searchQuery = sidebarFilterCaseSensitive ? query : query.toLowerCase();
const text = state.sidebarFilterCaseSensitive ? item.textContent : item.textContent.toLowerCase();
const searchQuery = state.sidebarFilterCaseSensitive ? query : query.toLowerCase();
if (text.includes(searchQuery)) {
matchingItems.add(item);
item.classList.remove("filtered-out");
@ -898,8 +898,8 @@ function showAllDescendants(container) {
function filterTagCloud(query) {
const tags = document.querySelectorAll("#tag-cloud .tag-item");
tags.forEach((tag) => {
const text = sidebarFilterCaseSensitive ? tag.textContent : tag.textContent.toLowerCase();
const searchQuery = sidebarFilterCaseSensitive ? query : query.toLowerCase();
const text = state.sidebarFilterCaseSensitive ? tag.textContent : tag.textContent.toLowerCase();
const searchQuery = state.sidebarFilterCaseSensitive ? query : query.toLowerCase();
if (!query || text.includes(searchQuery)) {
tag.classList.remove("filtered-out");
} else {

View File

@ -156,8 +156,8 @@ export const IndexUpdateManager = (() => {
try {
await Promise.all([refreshSidebarTreePreservingState(), refreshTagsForContext()]);
// Refresh current file if it was updated
if (currentVault && state.currentPath) {
const changed = (data.changes || []).some((c) => c.vault === currentVault && c.path === state.currentPath);
if (state.currentVault && state.currentPath) {
const changed = (data.changes || []).some((c) => c.vault === state.currentVault && c.path === state.currentPath);
if (changed) {
openFile(state.currentVault, state.currentPath);
}

View File

@ -36,9 +36,9 @@ export const RightSidebarManager = {
if (!sidebar) return;
if (rightSidebarVisible) {
if (state.rightSidebarVisible) {
sidebar.classList.remove("hidden");
sidebar.style.width = `${rightSidebarWidth}px`;
sidebar.style.width = `${state.rightSidebarWidth}px`;
if (handle) handle.classList.remove("hidden");
if (tocBtn) {
tocBtn.classList.add("active");
@ -67,7 +67,7 @@ export const RightSidebarManager = {
toggle() {
state.rightSidebarVisible = !state.rightSidebarVisible;
localStorage.setItem("obsigate-right-sidebar-visible", rightSidebarVisible);
localStorage.setItem("obsigate-right-sidebar-visible", state.rightSidebarVisible);
this.applyState();
},
@ -118,7 +118,7 @@ export const RightSidebarManager = {
document.body.style.cursor = "";
document.body.style.userSelect = "";
localStorage.setItem("obsigate-right-sidebar-width", rightSidebarWidth);
localStorage.setItem("obsigate-right-sidebar-width", state.rightSidebarWidth);
};
handle.addEventListener("mousedown", onMouseDown);
@ -905,10 +905,10 @@ const FileOperations = {
if (type === 'file' && state.currentVault === vault && state.currentPath === path) {
await openFile(vault, nextPath);
} else if (type === 'directory' && state.currentVault === vault && currentPath && (state.currentPath === path || currentPath.startsWith(`${path}/`))) {
} else if (type === 'directory' && state.currentVault === vault && state.currentPath && (state.currentPath === path || currentPath.startsWith(`${path}/`))) {
const suffix = state.currentPath === path ? '' : currentPath.slice(path.length);
state.currentPath = `${nextPath}${suffix}`;
await focusPathInSidebar(vault, currentPath, { alignToTop: false });
await focusPathInSidebar(vault, state.currentPath, { alignToTop: false });
}
showToast(type === 'directory' ? 'Dossier renommé' : 'Fichier renommé', 'success');
@ -992,7 +992,7 @@ const FileOperations = {
this._closeModal(overlay);
await refreshSidebarTreePreservingState();
if (state.currentVault === vault && currentPath && currentPath.startsWith(path)) {
if (state.currentVault === vault && state.currentPath && currentPath.startsWith(path)) {
showWelcome();
}
} catch (err) {
@ -1922,8 +1922,8 @@ export const TabManager = {
if (!cache) return;
// Update global state
currentVault = cache.vault;
currentPath = cache.path;
state.currentVault = cache.vault;
state.currentPath = cache.path;
syncActiveFileTreeItem(cache.vault, cache.path);
const area = document.getElementById("content-area");
@ -2098,8 +2098,8 @@ export const TabManager = {
// Refresh widgets after restoring
if (typeof DashboardStatsWidget !== "undefined") DashboardStatsWidget.load();
if (typeof DashboardConflictsWidget !== "undefined") DashboardConflictsWidget.load();
if (typeof DashboardRecentWidget !== "undefined") DashboardRecentWidget.load(selectedContextVault);
if (typeof DashboardBookmarkWidget !== "undefined") DashboardBookmarkWidget.load(selectedContextVault);
if (typeof DashboardRecentWidget !== "undefined") DashboardRecentWidget.load(state.selectedContextVault);
if (typeof DashboardBookmarkWidget !== "undefined") DashboardBookmarkWidget.load(state.selectedContextVault);
if (history.pushState) {
history.pushState(null, "", "#");
}

View File

@ -439,12 +439,12 @@ function renderFile(data) {
copyBtn.addEventListener("click", async () => {
try {
// Fetch raw content if not already cached
if (!cachedRawSource) {
if (!state.cachedRawSource) {
const rawUrl = `/api/file/${encodeURIComponent(data.vault)}/raw?path=${encodeURIComponent(data.path)}`;
const rawData = await api(rawUrl);
state.cachedRawSource = rawData.raw;
}
await navigator.clipboard.writeText(cachedRawSource);
await navigator.clipboard.writeText(state.cachedRawSource);
copyBtn.lastChild.textContent = "Copié !";
setTimeout(() => (copyBtn.lastChild.textContent = "Copier"), 1500);
} catch (err) {
@ -546,9 +546,9 @@ function renderFile(data) {
if (!rendered || !raw) return;
state.showingSource = !state.showingSource;
if (showingSource) {
if (state.showingSource) {
sourceBtn.classList.add("active");
if (!cachedRawSource) {
if (!state.cachedRawSource) {
const rawUrl = `/api/file/${encodeURIComponent(data.vault)}/raw?path=${encodeURIComponent(data.path)}`;
const rawData = await api(rawUrl);
state.cachedRawSource = rawData.raw;
@ -948,10 +948,10 @@ function showWelcome() {
DashboardConflictsWidget.load();
}
if (typeof DashboardRecentWidget !== "undefined") {
DashboardRecentWidget.load(selectedContextVault);
DashboardRecentWidget.load(state.selectedContextVault);
}
if (typeof DashboardBookmarkWidget !== "undefined") {
DashboardBookmarkWidget.load(selectedContextVault);
DashboardBookmarkWidget.load(state.selectedContextVault);
}
if (typeof DashboardSharedWidget !== "undefined") {
DashboardSharedWidget.load();
@ -1002,9 +1002,9 @@ async function loadSavedSearches() {
// Apply the saved search
const input = document.getElementById("search-input");
if (input) input.value = s.query;
searchCaseSensitive = s.case_sensitive || false;
searchWholeWord = s.whole_word || false;
searchRegex = s.regex || false;
state.searchCaseSensitive = s.case_sensitive || false;
state.searchWholeWord = s.whole_word || false;
state.searchRegex = s.regex || false;
if (typeof _updateToggleUI === "function") _updateToggleUI();
if (s.include_paths) {
const incl = document.getElementById("search-include-input");
@ -1019,7 +1019,7 @@ async function loadSavedSearches() {
AutocompleteDropdown._suppressNext = true;
const vault = s.vault || "all";
if (input) { input.dispatchEvent(new Event("input")); }
clearTimeout(searchTimeout);
clearTimeout(state.searchTimeout);
advancedSearchOffset = 0;
performAdvancedSearch(s.query, vault, null);
});
@ -1217,15 +1217,15 @@ const IndexUpdateManager = (() => {
// Toast removed: silent auto-indexing — no notification needed
// Refresh sidebar and tags if affected vault matches current context
const affectsCurrentVault = state.selectedContextVault === "all" || (data.vaults || []).includes(selectedContextVault);
const affectsCurrentVault = state.selectedContextVault === "all" || (data.vaults || []).includes(state.selectedContextVault);
if (affectsCurrentVault) {
try {
await Promise.all([refreshSidebarTreePreservingState(), refreshTagsForContext()]);
// Refresh current file if it was updated
if (currentVault && currentPath) {
const changed = (data.changes || []).some((c) => c.vault === currentVault && c.path === currentPath);
if (state.currentVault && state.currentPath) {
const changed = (data.changes || []).some((c) => c.vault === state.currentVault && c.path === state.currentPath);
if (changed) {
openFile(currentVault, currentPath);
openFile(state.currentVault, state.currentPath);
}
}
} catch (err) {
@ -1234,7 +1234,7 @@ const IndexUpdateManager = (() => {
}
// Refresh recent tab if it is active
if (activeSidebarTab === "recent") {
if (state.activeSidebarTab === "recent") {
const vaultFilter = document.getElementById("recent-vault-filter");
loadRecentFiles(vaultFilter ? vaultFilter.value || null : null);
}