Skip to main content

User Settings

Overview

This store is used to manage the user settings. It is used to store the user's preferences and settings, such as the language, the theme, and the highlights.

Basic features

initialize()

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

initialize(): Promise<void>

reset()

Resets the user settings 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>
ParameterTypeDescription
bookmarksUserSettings['bookmarks']The new bookmarks to be updated in the store.
auditEventsAuditEventsOptional. Events to be logged for auditing purposes.

bookmark()

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

bookmark(article: Article, queryName?: string): Promise<void>
ParameterTypeDescription
articleArticleThe article to be bookmarked.
queryNamestringOptional. The name of the query associated with the article.

unbookmark()

Removes a bookmark by its ID.

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

isBookmarked()

Checks if the given article is bookmarked.

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

toggleBookmark()

Toggles the bookmark status of a given article.

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

Recent Searches features

deleteRecentSearch()

Deletes a recent search entry from the user's recent searches list.

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

updateRecentSearches()

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

updateRecentSearches(recentSearches: UserSettings['recentSearches'], auditEvents?: AuditEvents): Promise<void>
ParameterTypeDescription
recentSearchesUserSettings['recentSearches']The new recent searches to be updated in the store.
auditEventsAuditEventsOptional. Events to be logged for auditing purposes.

addCurrentSearch()

Adds the current search to the recent searches list.

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

Saved Searches features

deleteSavedSearch()

Deletes a saved search entry from the user's saved searches list.

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

updateSavedSearches()

Updates the user's saved searches in the store.

updateSavedSearches(savedSearches: UserSettings['savedSearches']): Promise<void>
ParameterTypeDescription
savedSearchesUserSettings['savedSearches']The new saved searches to be updated in the store.

Baskets features

deleteBasket()

Deletes a basket from the user's baskets list.

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

createBasket()

Adds a basket to the user's baskets list.

createBasket(basket: Basket): Promise<void>
ParameterTypeDescription
basketBasketThe basket to add to the baskets list.

updateBaskets()

Updates the user's baskets in the store.

updateBaskets(baskets: UserSettings['baskets']): Promise<void>
ParameterTypeDescription
basketsUserSettings['baskets']The new baskets to be updated.

updateBasket()

Updates the basket at a specific index.

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

addToBasket()

Adds one or multiple records' id into a basket.

addToBasket(name: string, ids: string | string[]): Promise<void>
ParameterTypeDescription
namestringThe basket name.
idsstring | string[]The id(s) to add to it.

removeFromBasket()

Removes one or multiple records' id from a basket.

removeFromBasket(name: string, ids: string | string[]): Promise<void>
ParameterTypeDescription
namestringThe basket name.
idsstring | string[]The id(s) to remove from it.

Alert features

deleteAlert()

Deletes an alert from the user's alerts list.

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

createAlert()

Adds an alert to the user's alerts list.

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

updateAlert()

Updates the alert at a specific index.

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

updateAlerts()

Updates the user's alerts in the store.

updateAlerts(alerts: Alert[]): Promise<void>
ParameterTypeDescription
alertsAlert[]The new alerts to be updated.

Assistant features

updateAssistantSettings()

Updates the user's assistant settings in the store.

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

updateLanguage()

Update the user's language and optionally logs audit events.

updateLanguage(language: UserSettings['language'], auditEvents?: AuditEvents): Promise<void>
ParameterTypeDescription
languageUserSettings['language']The language to update with.
auditEventsAuditEventsOptional. Events to be logged.

updateAssistantCollapsed()

Update the user's assistant collapsed status and optionally logs audit events.

updateAssistantCollapsed(collapseAssistant: UserSettings['collapseAssistant'], auditEvents?: AuditEvents): Promise<void>
ParameterTypeDescription
collapseAssistantUserSettings['collapseAssistant']The collapse status.
auditEventsAuditEventsOptional. Events to be logged.