Skeudenn / main/db/user-repository / UserRepository
Class: UserRepository ​
Defined in: src/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: src/main/db/user-repository.ts:45
Parameters ​
db ​
DatabaseSync
Returns ​
UserRepository
Methods ​
activeId() ​
activeId():
string
Defined in: src/main/db/user-repository.ts:68
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: src/main/db/user-repository.ts:110
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 ​
get() ​
get(
id):UserProfile|null
Defined in: src/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: src/main/db/user-repository.ts:48
Everyone, in the order they were created.
Returns ​
remove() ​
remove(
id):UserResult
Defined in: src/main/db/user-repository.ts:150
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 ​
rename() ​
rename(
id,nickname):UserResult
Defined in: src/main/db/user-repository.ts:122
Changes a user's nickname (trimmed, not empty, unique ignoring case).
Parameters ​
id ​
string
nickname ​
string
Returns ​
setAvatar() ​
setAvatar(
id,bytes):UserResult
Defined in: src/main/db/user-repository.ts:131
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 ​
switchTo() ​
switchTo(
id):boolean
Defined in: src/main/db/user-repository.ts:80
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