feat: starred notes (#1813)
This commit is contained in:
@@ -13,6 +13,7 @@ export interface ItemContent {
|
||||
trashed?: boolean
|
||||
pinned?: boolean
|
||||
archived?: boolean
|
||||
starred?: boolean
|
||||
locked?: boolean
|
||||
appData?: AppData
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ export class DecryptedItem<C extends ItemContent = ItemContent>
|
||||
public readonly pinned: boolean = false
|
||||
public readonly archived: boolean = false
|
||||
public readonly locked: boolean = false
|
||||
public readonly starred: boolean = false
|
||||
|
||||
constructor(payload: DecryptedPayloadInterface<C>) {
|
||||
super(payload)
|
||||
@@ -32,6 +33,7 @@ export class DecryptedItem<C extends ItemContent = ItemContent>
|
||||
this.updatedAtString = dateToLocalizedString(this.userModifiedDate)
|
||||
this.protected = useBoolean(this.payload.content.protected, false)
|
||||
this.trashed = useBoolean(this.payload.content.trashed, false)
|
||||
this.starred = useBoolean(this.payload.content.starred, false)
|
||||
this.pinned = this.getAppDomainValueWithDefault(AppDataField.Pinned, false)
|
||||
this.archived = this.getAppDomainValueWithDefault(AppDataField.Archived, false)
|
||||
this.locked = this.getAppDomainValueWithDefault(AppDataField.Locked, false)
|
||||
|
||||
@@ -22,6 +22,7 @@ export interface DecryptedItemInterface<C extends ItemContent = ItemContent>
|
||||
readonly pinned: boolean
|
||||
readonly archived: boolean
|
||||
readonly locked: boolean
|
||||
readonly starred: boolean
|
||||
readonly userModifiedDate: Date
|
||||
readonly references: ContentReference[]
|
||||
|
||||
|
||||
@@ -78,6 +78,10 @@ export class DecryptedItemMutator<C extends ItemContent = ItemContent> extends I
|
||||
this.mutableContent.trashed = trashed
|
||||
}
|
||||
|
||||
set starred(starred: boolean) {
|
||||
this.mutableContent.starred = starred
|
||||
}
|
||||
|
||||
public set pinned(pinned: boolean) {
|
||||
this.setAppDataItem(AppDataField.Pinned, pinned)
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ export enum SystemViewId {
|
||||
ArchivedNotes = 'archived-notes',
|
||||
TrashedNotes = 'trashed-notes',
|
||||
UntaggedNotes = 'untagged-notes',
|
||||
StarredNotes = 'starred-notes',
|
||||
}
|
||||
|
||||
export interface SmartViewContent extends ItemContent {
|
||||
|
||||
@@ -74,10 +74,22 @@ export function BuildSmartViews(
|
||||
}),
|
||||
)
|
||||
|
||||
const starred = new SmartView(
|
||||
new DecryptedPayload({
|
||||
uuid: SystemViewId.StarredNotes,
|
||||
content_type: ContentType.SmartView,
|
||||
...PayloadTimestampDefaults(),
|
||||
content: FillItemContent<SmartViewContent>({
|
||||
title: 'Starred',
|
||||
predicate: starredNotesPredicate(options).toJson(),
|
||||
}),
|
||||
}),
|
||||
)
|
||||
|
||||
if (supportsFileNavigation) {
|
||||
return [notes, files, archived, trash, untagged]
|
||||
return [notes, starred, files, archived, trash, untagged]
|
||||
} else {
|
||||
return [notes, archived, trash, untagged]
|
||||
return [notes, starred, archived, trash, untagged]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -177,3 +189,22 @@ function untaggedNotesPredicate(options: FilterDisplayOptions) {
|
||||
|
||||
return predicate
|
||||
}
|
||||
|
||||
function starredNotesPredicate(options: FilterDisplayOptions) {
|
||||
const subPredicates: Predicate<SNNote>[] = [
|
||||
new Predicate('starred', '=', true),
|
||||
new Predicate('content_type', '=', ContentType.Note),
|
||||
]
|
||||
if (options.includeTrashed === false) {
|
||||
subPredicates.push(new Predicate('trashed', '=', false))
|
||||
}
|
||||
if (options.includeProtected === false) {
|
||||
subPredicates.push(new Predicate('protected', '=', false))
|
||||
}
|
||||
if (options.includePinned === false) {
|
||||
subPredicates.push(new Predicate('pinned', '=', false))
|
||||
}
|
||||
const predicate = new CompoundPredicate('and', subPredicates)
|
||||
|
||||
return predicate
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user