fix: Fixed issue where adding child tag to note would also add all parent tags even though the related setting was turned off
This commit is contained in:
@@ -2,7 +2,15 @@ import { destroyAllObjectProperties } from '@/Utils'
|
|||||||
import { confirmDialog, PIN_NOTE_COMMAND, STAR_NOTE_COMMAND } from '@standardnotes/ui-services'
|
import { confirmDialog, PIN_NOTE_COMMAND, STAR_NOTE_COMMAND } from '@standardnotes/ui-services'
|
||||||
import { StringEmptyTrash, Strings, StringUtils } from '@/Constants/Strings'
|
import { StringEmptyTrash, Strings, StringUtils } from '@/Constants/Strings'
|
||||||
import { MENU_MARGIN_FROM_APP_BORDER } from '@/Constants/Constants'
|
import { MENU_MARGIN_FROM_APP_BORDER } from '@/Constants/Constants'
|
||||||
import { SNNote, NoteMutator, ContentType, SNTag, TagMutator, InternalEventBus } from '@standardnotes/snjs'
|
import {
|
||||||
|
SNNote,
|
||||||
|
NoteMutator,
|
||||||
|
ContentType,
|
||||||
|
SNTag,
|
||||||
|
InternalEventBus,
|
||||||
|
PrefKey,
|
||||||
|
ApplicationEvent,
|
||||||
|
} from '@standardnotes/snjs'
|
||||||
import { makeObservable, observable, action, computed, runInAction } from 'mobx'
|
import { makeObservable, observable, action, computed, runInAction } from 'mobx'
|
||||||
import { WebApplication } from '../../Application/Application'
|
import { WebApplication } from '../../Application/Application'
|
||||||
import { AbstractViewController } from '../Abstract/AbstractViewController'
|
import { AbstractViewController } from '../Abstract/AbstractViewController'
|
||||||
@@ -10,8 +18,10 @@ import { SelectedItemsController } from '../SelectedItemsController'
|
|||||||
import { ItemListController } from '../ItemList/ItemListController'
|
import { ItemListController } from '../ItemList/ItemListController'
|
||||||
import { NavigationController } from '../Navigation/NavigationController'
|
import { NavigationController } from '../Navigation/NavigationController'
|
||||||
import { NotesControllerInterface } from './NotesControllerInterface'
|
import { NotesControllerInterface } from './NotesControllerInterface'
|
||||||
|
import { PrefDefaults } from '@/Constants/PrefDefaults'
|
||||||
|
|
||||||
export class NotesController extends AbstractViewController implements NotesControllerInterface {
|
export class NotesController extends AbstractViewController implements NotesControllerInterface {
|
||||||
|
shouldLinkToParentFolders: boolean
|
||||||
lastSelectedNote: SNNote | undefined
|
lastSelectedNote: SNNote | undefined
|
||||||
contextMenuOpen = false
|
contextMenuOpen = false
|
||||||
contextMenuPosition: { top?: number; left: number; bottom?: number } = {
|
contextMenuPosition: { top?: number; left: number; bottom?: number } = {
|
||||||
@@ -59,6 +69,11 @@ export class NotesController extends AbstractViewController implements NotesCont
|
|||||||
unselectNotes: action,
|
unselectNotes: action,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
this.shouldLinkToParentFolders = application.getPreference(
|
||||||
|
PrefKey.NoteAddToParentFolders,
|
||||||
|
PrefDefaults[PrefKey.NoteAddToParentFolders],
|
||||||
|
)
|
||||||
|
|
||||||
this.disposers.push(
|
this.disposers.push(
|
||||||
this.application.keyboardService.addCommandHandler({
|
this.application.keyboardService.addCommandHandler({
|
||||||
command: PIN_NOTE_COMMAND,
|
command: PIN_NOTE_COMMAND,
|
||||||
@@ -72,6 +87,12 @@ export class NotesController extends AbstractViewController implements NotesCont
|
|||||||
this.toggleStarSelectedNotes()
|
this.toggleStarSelectedNotes()
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
this.application.addSingleEventObserver(ApplicationEvent.PreferencesChanged, async () => {
|
||||||
|
this.shouldLinkToParentFolders = this.application.getPreference(
|
||||||
|
PrefKey.NoteAddToParentFolders,
|
||||||
|
PrefDefaults[PrefKey.NoteAddToParentFolders],
|
||||||
|
)
|
||||||
|
}),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -339,15 +360,9 @@ export class NotesController extends AbstractViewController implements NotesCont
|
|||||||
|
|
||||||
async addTagToSelectedNotes(tag: SNTag): Promise<void> {
|
async addTagToSelectedNotes(tag: SNTag): Promise<void> {
|
||||||
const selectedNotes = this.getSelectedNotesList()
|
const selectedNotes = this.getSelectedNotesList()
|
||||||
const parentChainTags = this.application.items.getTagParentChain(tag)
|
|
||||||
const tagsToAdd = [...parentChainTags, tag]
|
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
tagsToAdd.map(async (tag) => {
|
selectedNotes.map(async (note) => {
|
||||||
await this.application.mutator.changeItem<TagMutator>(tag, (mutator) => {
|
await this.application.items.addTagToNote(note, tag, this.shouldLinkToParentFolders)
|
||||||
for (const note of selectedNotes) {
|
|
||||||
mutator.addNote(note)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
this.application.sync.sync().catch(console.error)
|
this.application.sync.sync().catch(console.error)
|
||||||
|
|||||||
Reference in New Issue
Block a user