Skip to content

Commit

Permalink
chore: define BLOCKED_ROLE as a constant
Browse files Browse the repository at this point in the history
This change should have no impact on functionality, and is a minor
change.

In [an upcoming change][0], I plan to make several references to the
blocked role. This defines the `BLOCKED_ROLE` constant for this purpose.

[0]: #188
  • Loading branch information
EvanHahn committed Nov 14, 2024
1 parent 6a3bb5b commit b6b305a
Showing 1 changed file with 29 additions and 24 deletions.
53 changes: 29 additions & 24 deletions src/roles.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,33 @@ export const CREATOR_ROLE = {
},
}

/**
* @type {Role<typeof BLOCKED_ROLE_ID>}
*/
const BLOCKED_ROLE = {
roleId: BLOCKED_ROLE_ID,
name: 'Blocked',
docs: mapObject(currentSchemaVersions, (key) => {
return [
key,
{
readOwn: false,
writeOwn: false,
readOthers: false,
writeOthers: false,
},
]
}),
roleAssignment: [],
sync: {
auth: 'blocked',
config: 'blocked',
data: 'blocked',
blobIndex: 'blocked',
blob: 'blocked',
},
}

/**
* This is the role assumed for a device when no role record can be found. This
* can happen when an invited device did not manage to sync with the device that
Expand Down Expand Up @@ -166,29 +193,7 @@ export const ROLES = {
blob: 'allowed',
},
},
[BLOCKED_ROLE_ID]: {
roleId: BLOCKED_ROLE_ID,
name: 'Blocked',
docs: mapObject(currentSchemaVersions, (key) => {
return [
key,
{
readOwn: false,
writeOwn: false,
readOthers: false,
writeOthers: false,
},
]
}),
roleAssignment: [],
sync: {
auth: 'blocked',
config: 'blocked',
data: 'blocked',
blobIndex: 'blocked',
blob: 'blocked',
},
},
[BLOCKED_ROLE_ID]: BLOCKED_ROLE,
[LEFT_ROLE_ID]: {
roleId: LEFT_ROLE_ID,
name: 'Left',
Expand Down Expand Up @@ -281,7 +286,7 @@ export class Roles extends TypedEmitter {
}
}
if (!isRoleId(roleId)) {
return ROLES[BLOCKED_ROLE_ID]
return BLOCKED_ROLE
}
return ROLES[roleId]
}
Expand Down

0 comments on commit b6b305a

Please sign in to comment.