Story 4.1 completed
This commit is contained in:
@@ -34,6 +34,9 @@ export class FoundryAdapter {
|
||||
*/
|
||||
static SETTING_WEBRTC_MODE = 'webrtcMode';
|
||||
|
||||
/** Flag scope/namespace for module-specific user flags. */
|
||||
static FLAG_SCOPE = 'video-view-manager';
|
||||
|
||||
/**
|
||||
* Creates a FoundryAdapter. Side-effect-free — no hooks or listeners registered.
|
||||
* @param {object} [game] - The FoundryVTT `game` global. Optional for legacy/test
|
||||
@@ -136,21 +139,29 @@ export class FoundryAdapter {
|
||||
/**
|
||||
* Convenience method to get a module-scoped flag.
|
||||
* @param {string} userId - The user ID to get the flag for.
|
||||
* @param {string} key - The flag key (will be scoped to 'video-view-manager').
|
||||
* @param {string} key - The flag key (will be scoped to FoundryAdapter.FLAG_SCOPE).
|
||||
* @returns {unknown|null} The flag value, or null if not found.
|
||||
*/
|
||||
getFlagModule: (userId, key) => {
|
||||
return this.getFlag(userId, 'video-view-manager', key);
|
||||
const user = g.users?.get(userId);
|
||||
if (user && typeof user.getFlag === 'function') {
|
||||
return user.getFlag(FoundryAdapter.FLAG_SCOPE, key) ?? null;
|
||||
}
|
||||
return null;
|
||||
},
|
||||
/**
|
||||
* Convenience method to set a module-scoped flag.
|
||||
* @param {string} userId - The user ID to set the flag for.
|
||||
* @param {string} key - The flag key (will be scoped to 'video-view-manager').
|
||||
* @param {string} key - The flag key (will be scoped to FoundryAdapter.FLAG_SCOPE).
|
||||
* @param {unknown} value - The flag value to set.
|
||||
* @returns {Promise<unknown>|null} The promise from user.setFlag(), or null if user not found.
|
||||
*/
|
||||
setFlagModule: (userId, key, value) => {
|
||||
return this.setFlag(userId, 'video-view-manager', key, value);
|
||||
const user = g.users?.get(userId);
|
||||
if (user && typeof user.setFlag === 'function') {
|
||||
return /** @type {Promise<unknown>} */ (user.setFlag(FoundryAdapter.FLAG_SCOPE, key, value));
|
||||
}
|
||||
return null;
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user