Skip to content

Commit ed62b2c

Browse files
authored
chore: define BLOCKED_ROLE as a constant (#961)
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
1 parent 6a3bb5b commit ed62b2c

File tree

1 file changed

+29
-24
lines changed

1 file changed

+29
-24
lines changed

src/roles.js

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,33 @@ export const CREATOR_ROLE = {
9898
},
9999
}
100100

101+
/**
102+
* @type {Role<typeof BLOCKED_ROLE_ID>}
103+
*/
104+
const BLOCKED_ROLE = {
105+
roleId: BLOCKED_ROLE_ID,
106+
name: 'Blocked',
107+
docs: mapObject(currentSchemaVersions, (key) => {
108+
return [
109+
key,
110+
{
111+
readOwn: false,
112+
writeOwn: false,
113+
readOthers: false,
114+
writeOthers: false,
115+
},
116+
]
117+
}),
118+
roleAssignment: [],
119+
sync: {
120+
auth: 'blocked',
121+
config: 'blocked',
122+
data: 'blocked',
123+
blobIndex: 'blocked',
124+
blob: 'blocked',
125+
},
126+
}
127+
101128
/**
102129
* This is the role assumed for a device when no role record can be found. This
103130
* can happen when an invited device did not manage to sync with the device that
@@ -166,29 +193,7 @@ export const ROLES = {
166193
blob: 'allowed',
167194
},
168195
},
169-
[BLOCKED_ROLE_ID]: {
170-
roleId: BLOCKED_ROLE_ID,
171-
name: 'Blocked',
172-
docs: mapObject(currentSchemaVersions, (key) => {
173-
return [
174-
key,
175-
{
176-
readOwn: false,
177-
writeOwn: false,
178-
readOthers: false,
179-
writeOthers: false,
180-
},
181-
]
182-
}),
183-
roleAssignment: [],
184-
sync: {
185-
auth: 'blocked',
186-
config: 'blocked',
187-
data: 'blocked',
188-
blobIndex: 'blocked',
189-
blob: 'blocked',
190-
},
191-
},
196+
[BLOCKED_ROLE_ID]: BLOCKED_ROLE,
192197
[LEFT_ROLE_ID]: {
193198
roleId: LEFT_ROLE_ID,
194199
name: 'Left',
@@ -281,7 +286,7 @@ export class Roles extends TypedEmitter {
281286
}
282287
}
283288
if (!isRoleId(roleId)) {
284-
return ROLES[BLOCKED_ROLE_ID]
289+
return BLOCKED_ROLE
285290
}
286291
return ROLES[roleId]
287292
}

0 commit comments

Comments
 (0)