Skip to content

Tankōbon / main/db/user-repository / UserRepository

Class: UserRepository ​

Defined in: main/db/user-repository.ts:42

The users, and the one using the app (the activeId the other repositories scope their reads and writes to). The active user is the one who was last switched to, so the app reopens on them.

Constructors ​

Constructor ​

new UserRepository(db): UserRepository

Defined in: main/db/user-repository.ts:45

Parameters ​

db ​

DatabaseSync

Returns ​

UserRepository

Methods ​

activeId() ​

activeId(): string

Defined in: main/db/user-repository.ts:64

Id of the user using the app: the last one switched to (the first user on a database that never switched).

Returns ​

string


create() ​

create(nickname): UserResult

Defined in: main/db/user-repository.ts:105

Adds a user with the default picture; they start with the default settings and no history. It doesn't switch to them.

Parameters ​

nickname ​

string

Returns ​

UserResult


get() ​

get(id): UserProfile | null

Defined in: main/db/user-repository.ts:56

One user, or null when the id is unknown.

Parameters ​

id ​

string

Returns ​

UserProfile | null


list() ​

list(): UserProfile[]

Defined in: main/db/user-repository.ts:48

Everyone, in the order they were created.

Returns ​

UserProfile[]


remove() ​

remove(id): UserResult

Defined in: main/db/user-repository.ts:145

Deletes a user and everything personal they own (progress, ratings and tags, lists, reading time, achievements, settings); the library and the other users are untouched. Refused for the last remaining user. When the removed user was the active one, the app moves to the user active before them, and the result is that user.

Parameters ​

id ​

string

Returns ​

UserResult


rename() ​

rename(id, nickname): UserResult

Defined in: main/db/user-repository.ts:117

Changes a user's nickname (trimmed, not empty, unique ignoring case).

Parameters ​

id ​

string

nickname ​

string

Returns ​

UserResult


setAvatar() ​

setAvatar(id, bytes): UserResult

Defined in: main/db/user-repository.ts:126

Stores a profile picture (PNG, JPEG or WebP, at most MAX_AVATAR_BYTES), or removes it with null.

Parameters ​

id ​

string

bytes ​

Uint8Array<ArrayBufferLike> | null

Returns ​

UserResult


switchTo() ​

switchTo(id): boolean

Defined in: main/db/user-repository.ts:75

Makes id the user using the app (and the one the app reopens on). False when the id is unknown.

Parameters ​

id ​

string

Returns ​

boolean