EvanBookmarkService

Source bookmark

Blockchain-core wrapper service to handle users favorites.

  • joinLeaveBcQueueId - QueueId: queue id for handling favorite saving

queueAddBookmark

bookmarkService.queueAddBookmark(ensAddress);

Queue a new bookmark add process.

Parameters

  1. ensAddress - string: ens address that should be added
  2. dapp - any: dapp ens description

Example

const dapp = await this.bookmarkService.getBookmarkDefinition(ensAddress)
await this
  .alertService.showSubmitAlert(
    '_dappdapps.alert.validTitle',
    {
      key: '_dappdapps.alert.dappMessage',
      translateOptions: dapp
    },
    'cancel',
    'submit'
  );
this.bookmarkService.queueAddBookmark(ensAddress, dapp))

queueRemoveBookmark

bookmarkService.queueRemoveBookmark(ensAddress);

Function description

Parameters

  1. ensAddress - string: ens address that should be removed

Returns

Promise returns void: resolved when done

Example

this.bookmarkService.queueRemoveBookmark('taskboard.evan')

addDAppBookmark

bookmarkService.addDAppBookmark(ensAddress, dapp);

Add DApp bookmark to the current profile directly without queue.

Parameters

  1. ensAddress - string: ens address that should be added
  2. dapp - any: dapp ens description

Returns

Promise returns void: resolved when done

Example

Have a look at this.queueAddBookmark

removeDappBookmark

bookmarkService.removeDappBookmark(ensAddress);

Remove bookmark from current account.

Parameters

  1. ensAddress - string: ens address that should be removed

Returns

Promise returns void: resolved when done

Example

this.bookmarkService.removeDappBookmark('taskboard.evan')

syncQueueBookmarks

bookmarkService.syncQueueBookmarks(reload);

Overwrite current bookmarks to the profile and write them to the blockchain.

Returns

Promise returns void: resolved when done

Example

await bookmarkService.syncQueueBookmarks();

getDAppBookmarks

bookmarkService.getDAppBookmarks(reload);

Reload profile data and return current bookmarked dapps.

Parameters

  1. reload - boolean (optional): Force reload of current profile and so reload the bookmarks.

Returns

Promise returns Array<any>: bookmarks for the current user

Example

const bookmarks = getDAppBookmarks();

[
  {
    ...
    "taskboard.evan": {
      "name": "taskboard",
      "description": "Create todos and manage updates.",
      "i18n": {
        "description": {
          "de": "Erstelle Aufgaben und überwache Änderungen",
          "en": "Create todos and manage updates"
        },
        "name": {
          "de": "Task Board",
          "en": "Task Board"
        }
      },
      "imgSquare": "...",
      "standalone": true,
      "primaryColor": "#e87e23",
      "secondaryColor": "#fffaf5",
      "translated": {
        "description": "Create todos and manage updates",
        "name": "Task Board"
      }
    }
  }
]

clearBookmarks

bookmarkService.clearBookmarks();

Clear bookmarks of current profile.

Returns

Promise returns void: resolved when done

Example

await bookmarkService.clearBookmarks();

setAlreadyAddedToBookmark

bookmarkService.setAlreadyAddedToBookmark(bookmark);

Checks if the bookmark is already added the current profile bookmarks.

Parameters

  1. bookmark - any: Bookmark ENS definition

Returns

Promise returns void: resolved when done

Example

const definition = await this.descriptionService.getDescription(ensAddress);

await this.setAlreadyAddedToBookmark(definition);

return definition;

getBookmarkFromDefinition

bookmarkService.getBookmarkFromDefinition(definition);

Transform ENS definition to bookmark definition.

Parameters

  1. definition - object: ENS definition to parse

Returns

Promise returns any: The bookmark from definition.

{
  name: definition.name,
  description: definition.description,
  i18n: definition.i18n,
  imgSquare: definition.imgSquare,
  imgWide: definition.imgWide,
  standalone: definition.standalone || definition.dapp.standalone,
  primaryColor: definition.primaryColor || definition.dapp.primaryColor,
  secondaryColor: definition.secondaryColor || definition.dapp.secondaryColor
}

Example

getBookmarkFromDefinition({ name: '', ... })

getBookmarkDefinition

bookmarkService.getBookmarkDefinition(ensAddress);

Loads an definition and checks the “already_added” state.

Parameters

  1. ensAddress - string: ENS addres to load the definition from

Returns

have a look at getBookmarkFromDefinition

Promise returns void: The bookmark definition.

Example

await bookmarkService.getBookmarkDefinition('taskboard.evan')

getBookmarkDefinitions

bookmarkService.getBookmarkDefinitions(ensAddresses);

Loads multiple definitions and checks the “already_added” state.

Parameters

  1. ensAddresses - Array<string: ENS addresses to load the definition from

Returns

Promise returns Array<any>: The bookmark definitions.

Example

await bookmarkService.getBookmarkDefinitions([
  'favorites'
  'mailbox',
  'contacts'
])