Options
All
  • Public
  • Public/Protected
  • All
Menu

A class that represents a clipboard entry

Hierarchy

  • ClipItem

Index

Constructors

constructor

  • new ClipItem(text: string, date: number, fav: boolean, remote: boolean, device: string, labelsId?: number[], labels?: Label[]): ClipItem
  • Parameters

    • text: string
    • date: number
    • fav: boolean
    • remote: boolean
    • device: string
    • Default value labelsId: number[] = []
    • Default value labels: Label[] = []

    Returns ClipItem

Properties

_id

_id: number

database PK

date

date: number

created date

device

device: string

remote source device

fav

fav: boolean

favorite item state

labels

labels: Label[] = []

array of Label objects

labelsId

labelsId: number[] = []

array of Label PK's

remote

remote: boolean

from remote source state

text

text: string

text

Methods

addLabel

  • addLabel(label: Label): Promise<void>

Protected addLabelNoSave

  • addLabelNoSave(label: Label): void

Protected addOrUpdate

  • addOrUpdate(): Promise<number>

Protected clearLabelsNoSave

  • clearLabelsNoSave(): void

delete

  • delete(): Promise<void>

Protected getId

  • getId(): Promise<undefined | number>
  • Get our PK

    Returns Promise<undefined | number>

    database PK, undefined if not found

getLabelNames

  • getLabelNames(): string[]

hasLabel

  • hasLabel(name: string): boolean

Protected removeLabelNoSave

  • removeLabelNoSave(id: number): boolean

Protected safeSave

  • safeSave(): Promise<number>

save

  • save(): Promise<number>

Protected saveOrDeleteOldest

  • saveOrDeleteOldest(): Promise<undefined | number>
  • Save to the database or delete oldest non favorite if there is no room

    Returns Promise<undefined | number>

    database PK if saved, undefined otherwise

setLabels

  • setLabels(labelNames: string[]): Promise<number>
  • Set our Label objects

    Parameters

    • labelNames: string[]

      names of labels

    Returns Promise<number>

    our database PK

update

  • update(changes: any): Promise<number>
  • Update the database

    Parameters

    • changes: any

      properties to change

    Returns Promise<number>

    number of ClipItem objects changed

Static add

  • add(text: string, date: number, fav: boolean, remote: boolean, device: string, keepState?: boolean): Promise<ClipItem>
  • Add new ClipItem to storage

    Parameters

    • text: string

      The text of the clip

    • date: number

      Time in milliSecs from epoch

    • fav: boolean

      true if this has been marked as a favorite

    • remote: boolean

      true if this came from a device other than ours

    • device: string

      A String representing the source device

    • Default value keepState: boolean = false

      if true keep labels and fav if true

    Returns Promise<ClipItem>

Static bulkPut

Static deleteAll

  • deleteAll(): Promise<void>

Static deleteOld

  • deleteOld(): Promise<boolean>
  • Delete items older than the storageDuration setting

    Returns Promise<boolean>

    true if items were deleted

Static Protected deleteOlderThan

  • deleteOlderThan(time: number): Promise<boolean>
  • Delete non-favorite ClipItem objects older than the given time

    Parameters

    • time: number

      time in millis since epoch

    Returns Promise<boolean>

    true if items were deleted

Static Protected deleteOldest

  • deleteOldest(): Promise<void>

Static get

  • get(text: string): Promise<undefined | ClipItem>

Static loadAll

  • loadAll(labelName?: string): Promise<ClipItem[]>

Static remove

  • remove(keys: number[] | number): Promise<void>
  • Remove the given keys from the database

    Parameters

    • keys: number[] | number

      array of PK's to delete

    Returns Promise<void>

Static removeLabel

  • removeLabel(labelId: number): Promise<void>

Static updateLabel

  • updateLabel(newName: string, oldName: string): Promise<void>

Object literals

Static Protected ERR

ERR: object

Error messages

DB_FULL

DB_FULL: string = "Database is full. Please delete unused items."

EMPTY_TEXT

EMPTY_TEXT: string = "Text is only whitespace"

NO_LABEL

NO_LABEL: string = "Label not found."

REMOVE_FAILED

REMOVE_FAILED: string = "Failed to delete item(s)."

Generated using TypeDoc