Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion app/src/main/java/com/astralquarks/notes/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,16 @@ fun MainAppContent(
Intent.ACTION_VIEW -> {
val noteId = current.getStringExtra(QuickNoteWidgetProvider.EXTRA_NOTE_ID)
if (!noteId.isNullOrBlank()) {
currentScreen = Screen.EditNote(noteId, "")
scope.launch {
val n = viewModel.repository.getNoteById(noteId)
if (n != null) {
if (n.isLocked && !isVaultUnlocked) {
Toast.makeText(activity, "Note is locked. Please unlock the vault first.", Toast.LENGTH_SHORT).show()
} else {
currentScreen = Screen.EditNote(noteId, "")
}
}
}
}
}
}
Expand Down
14 changes: 14 additions & 0 deletions app/src/main/java/com/astralquarks/notes/model/Note.kt
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,21 @@ data class Note(
// If decryption key does not match, retain placeholder without crashing
title = "[Encrypted Note]"
content = "Unable to decrypt content with current vault key."
tags = emptyList()
imageUrls = emptyList()
}
} else if (isEncrypted) {
// If it is encrypted but no key was provided or payload is missing, clear tags to avoid leak
title = "[Locked Note]"
content = "Unlock your private vault to view this encrypted note."
tags = emptyList()
imageUrls = emptyList()
} else if (isLocked && secretKey == null) {
// Also protect tags for legacy format or unexpected states if vault is locked
title = "[Locked Note]"
content = "Unlock your private vault to view this encrypted note."
tags = emptyList()
imageUrls = emptyList()
}

return Note(
Expand Down
6 changes: 3 additions & 3 deletions web/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,7 @@ class AstralNotesApp {

const allTags = new Set<string>();
this.notes.forEach(n => {
if (!n.isTrash && !n.isDeleted) {
if (!n.isTrash && !n.isDeleted && (!n.isLocked || vaultManager.isUnlocked())) {
n.tags.forEach(t => allTags.add(t));
}
});
Expand Down Expand Up @@ -1434,14 +1434,14 @@ class AstralNotesApp {

let totalWords = 0;
this.notes.forEach(n => {
if (!n.isTrash && !n.isDeleted) {
if (!n.isTrash && !n.isDeleted && (!n.isLocked || vaultManager.isUnlocked())) {
totalWords += n.content.trim().split(/\s+/).filter(Boolean).length;
}
});

const allTags = new Set<string>();
this.notes.forEach(n => {
if (!n.isTrash && !n.isDeleted) {
if (!n.isTrash && !n.isDeleted && (!n.isLocked || vaultManager.isUnlocked())) {
n.tags.forEach(t => allTags.add(t));
}
});
Expand Down