Skip to main content

Legacy Users Package & Changes to `/users` Endpoint

This change affects any code using Devise.current_user.team.accounts or Devise.current_team.accounts.

The @shared/legacy-users package is now available. The service exposes multiple functions to get the list of users previously located at Devise.current_user.team.accounts and Devise.current_team.accounts (they were the same list). We asynchronously load this data as soon as Devise loads and populate Devise.current_user.team.accounts and Devise.current_team.accounts. Consequently, when Angular first boots, Devise.current_user.team.accounts and Devise.current_team.accounts are both empty arrays. After the network request is fulfilled, we populate Devise.current_user.team.accounts and Devise.current_team.accounts with the request payload. Practically, this has not had an effect on the system, but it is something to note.

Example

import { getLegacyUsers, useLegacyUsers } from '@shared/legacy-users'

async function getOwnerName(ownerId: number) {
const legacyUsers = await getLegacyUsers()
return legacyUsers.find((user) => user.id === ownerId)
}

function OwnerName({ ownerId }: { ownerId: number }) {
const { data: legacyUsers, isLoading } = useLegacyUsers()

if (isLoading) return null

const owner = legacyUsers.find((user) => user.id === ownerId)
return <strong>{owner.name}</strong>
}

The legacy user service is written in Typescript and can be used in JavaScript and Typescript code. New code relying on Devise.current_user.team.accounts or Devise.current_team.accounts should use this service and any existing non-Angular code should be refactored to use this service as well. Existing Angular code can be left as-is since Devise uses this service under the hood.