Skip to content

Commit 7baa4a1

Browse files
committed
Fix checkSubjectTaken
1 parent e566c4a commit 7baa4a1

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

lib/src/store.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,12 +144,22 @@ export class Store {
144144

145145
/** Checks if a subject is free to use */
146146
public async checkSubjectTaken(subject: string): Promise<boolean> {
147-
const r = await this.getResourceAsync(subject);
147+
const r = this.resources.get(subject);
148148

149-
if (r.isReady()) {
149+
if (r?.isReady() && !r.new) {
150150
return true;
151151
}
152152

153+
try {
154+
const resp = await this.fetchResourceFromServer(subject);
155+
156+
if (resp.isReady()) {
157+
return true;
158+
}
159+
} catch (e) {
160+
// If the resource doesn't exist, we can use it
161+
}
162+
153163
return false;
154164
}
155165

0 commit comments

Comments
 (0)