Skip to main content
Version: 11.14.0

User Settings

The UserSettingsStore manages user preferences and settings, including language, theme, bookmarks, recent searches, saved searches, baskets, and alerts. It persists state to the backend API and keeps the store in sync.

Methods

initialize()

Initializes the store by fetching user settings from the backend API and patching the store.

initialize(): Promise<void>

reset()

Resets the store to its initial state.

reset(): Promise<void>

Bookmark features

updateBookmarks()

Updates the user's bookmarks in the store and optionally logs audit events.

updateBookmarks(bookmarks: UserSettings['bookmarks'], auditEvents?: AuditEvents): Promise<void>
NameTypeRequiredDescription
bookmarksUserSettings['bookmarks']The new bookmarks to store.
auditEventsAuditEventsOptional audit events to log.

bookmark()

Adds an article to the bookmarks if it is not already bookmarked.

bookmark(article: Article, queryName?: string): Promise<void>
NameTypeRequiredDescription
articleArticleThe article to bookmark.
queryNamestringThe query name associated with the article.

unbookmark()

Removes a bookmark by its ID.

unbookmark(id: string): Promise<void>
NameTypeRequiredDescription
idstringThe ID of the bookmark to remove.

isBookmarked()

Checks whether the given article is bookmarked.

isBookmarked(article: Partial<Article>): boolean
NameTypeRequiredDescription
articlePartial<Article>The article to check.

Returns booleantrue if the article is bookmarked.

toggleBookmark()

Toggles the bookmark status of a given article.

toggleBookmark(article: Article): Promise<void>
NameTypeRequiredDescription
articleArticleThe article whose bookmark status to toggle.

Recent Searches features

deleteRecentSearch()

Deletes a recent search entry by its index.

deleteRecentSearch(index: number): Promise<void>
NameTypeRequiredDescription
indexnumberThe index of the recent search to delete.

updateRecentSearches()

Updates the user's recent searches and optionally logs audit events.

updateRecentSearches(recentSearches: UserSettings['recentSearches'], auditEvents?: AuditEvents): Promise<void>
NameTypeRequiredDescription
recentSearchesUserSettings['recentSearches']The new recent searches to store.
auditEventsAuditEventsOptional audit events to log.

addCurrentSearch()

Adds the current search to the recent searches list.

addCurrentSearch(queryParams: QueryParams): Promise<void>
NameTypeRequiredDescription
queryParamsQueryParamsThe parameters of the current search.

Saved Searches features

deleteSavedSearch()

Deletes a saved search entry by its index.

deleteSavedSearch(index: number): Promise<void>
NameTypeRequiredDescription
indexnumberThe index of the saved search to delete.

updateSavedSearches()

Updates the user's saved searches in the store.

updateSavedSearches(savedSearches: UserSettings['savedSearches']): Promise<void>
NameTypeRequiredDescription
savedSearchesUserSettings['savedSearches']The new saved searches to store.

Baskets features

deleteBasket()

Deletes a basket by its index.

deleteBasket(index: number): Promise<void>
NameTypeRequiredDescription
indexnumberThe index of the basket to delete.

createBasket()

Adds a basket to the user's baskets list.

createBasket(basket: Basket): Promise<void>
NameTypeRequiredDescription
basketBasketThe basket to add.

updateBaskets()

Replaces the full baskets list in the store.

updateBaskets(baskets: UserSettings['baskets']): Promise<void>
NameTypeRequiredDescription
basketsUserSettings['baskets']The new baskets to store.

updateBasket()

Updates the basket at a specific index.

updateBasket(basket: Basket, index: number): Promise<void>
NameTypeRequiredDescription
basketBasketThe updated basket data.
indexnumberThe index of the basket to update.

addToBasket()

Adds one or multiple record IDs to a named basket.

addToBasket(name: string, ids: string | string[]): Promise<void>
NameTypeRequiredDescription
namestringThe basket name.
idsstring | string[]The record ID(s) to add.

removeFromBasket()

Removes one or multiple record IDs from a named basket.

removeFromBasket(name: string, ids: string | string[]): Promise<void>
NameTypeRequiredDescription
namestringThe basket name.
idsstring | string[]The record ID(s) to remove.

Alert features

deleteAlert()

Deletes an alert by its index.

deleteAlert(index: number): Promise<void>
NameTypeRequiredDescription
indexnumberThe index of the alert to delete.

createAlert()

Adds an alert to the user's alerts list.

createAlert(alert: Alert): Promise<void>
NameTypeRequiredDescription
alertAlertThe alert to add.

updateAlert()

Updates the alert at a specific index.

updateAlert(alert: Alert, index: number): Promise<void>
NameTypeRequiredDescription
alertAlertThe updated alert data.
indexnumberThe index of the alert to update.

updateAlerts()

Replaces the full alerts list in the store.

updateAlerts(alerts: Alert[]): Promise<void>
NameTypeRequiredDescription
alertsAlert[]The new alerts to store.

Assistant features

updateAssistantSettings()

Updates the user's assistant settings in the store.

updateAssistantSettings(assistantSettings: UserSettings['assistants']): Promise<void>
NameTypeRequiredDescription
assistantSettingsUserSettings['assistants']The new assistant settings.

updateLanguage()

Updates the user's language preference and optionally logs audit events.

updateLanguage(language: UserSettings['language'], auditEvents?: AuditEvents): Promise<void>
NameTypeRequiredDescription
languageUserSettings['language']The language to set.
auditEventsAuditEventsOptional audit events to log.

updateAssistantCollapsed()

Updates the assistant's collapsed state and optionally logs audit events.

updateAssistantCollapsed(collapseAssistant: UserSettings['collapseAssistant'], auditEvents?: AuditEvents): Promise<void>
NameTypeRequiredDescription
collapseAssistantUserSettings['collapseAssistant']The new collapsed state.
auditEventsAuditEventsOptional audit events to log.