mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-04 01:18:34 +00:00
fix bug when not logged in
This commit is contained in:
1 parent
a3b1fac6e4
commit
1f34f219e4
3 files changed
+9
-30
No files matched your search
+1
-1
@@ -67,7 +67,7 @@ class App extends React.Component<Props, State> {
|
||||
componentDidMount() {
|
||||
this.querySession();
|
||||
|
||||
setInterval(() => { this.querySession() }, 10000);
|
||||
setInterval(() => { this.querySession() }, 60000);
|
||||
// TODO: Use websockets, this is dumb
|
||||
setInterval(() => { this.pollJobs() }, 1000);
|
||||
//this.state.videoJobPoller.start();
|
||||
|
||||
@@ -8,7 +8,7 @@ export interface SessionStateResponse {
|
||||
logged_in: boolean,
|
||||
|
||||
// Extended user details (only if logged in)
|
||||
user?: UserInfo,
|
||||
user: UserInfo | undefined | null,
|
||||
}
|
||||
|
||||
export interface UserInfo {
|
||||
|
||||
@@ -51,51 +51,30 @@ export class SessionWrapper {
|
||||
}
|
||||
|
||||
public canUseTts() : boolean {
|
||||
if (this.sessionStateResponse === undefined || this.sessionStateResponse.user === undefined) {
|
||||
return true; // NB: Default true.
|
||||
}
|
||||
return this.sessionStateResponse.user.can_use_tts;
|
||||
return this.sessionStateResponse?.user?.can_use_tts || true; // NB: Default true.
|
||||
}
|
||||
|
||||
public canUseW2l() : boolean {
|
||||
if (this.sessionStateResponse === undefined || this.sessionStateResponse.user === undefined) {
|
||||
return true; // NB: Default true.
|
||||
}
|
||||
return this.sessionStateResponse.user.can_use_w2l;
|
||||
return this.sessionStateResponse?.user?.can_use_w2l || true; // NB: Default true
|
||||
}
|
||||
|
||||
public canUploadTtsModels() : boolean {
|
||||
if (this.sessionStateResponse === undefined || this.sessionStateResponse.user === undefined) {
|
||||
return false;
|
||||
}
|
||||
return this.sessionStateResponse.user.can_upload_tts_models;
|
||||
return this.sessionStateResponse?.user?.can_upload_tts_models || false;
|
||||
}
|
||||
|
||||
public canUploadW2lTemplates() : boolean {
|
||||
if (this.sessionStateResponse === undefined || this.sessionStateResponse.user === undefined) {
|
||||
return false;
|
||||
}
|
||||
return this.sessionStateResponse.user.can_upload_w2l_templates;
|
||||
return this.sessionStateResponse?.user?.can_upload_w2l_templates || false;
|
||||
}
|
||||
|
||||
public canBanUsers() : boolean {
|
||||
if (this.sessionStateResponse === undefined || this.sessionStateResponse.user === undefined) {
|
||||
return false;
|
||||
}
|
||||
return this.sessionStateResponse.user.can_ban_users;
|
||||
return this.sessionStateResponse?.user?.can_ban_users || false;
|
||||
}
|
||||
|
||||
public canEditOtherUsersData() : boolean {
|
||||
if (this.sessionStateResponse === undefined || this.sessionStateResponse.user === undefined) {
|
||||
return false;
|
||||
}
|
||||
return this.sessionStateResponse.user.can_edit_other_users_data;
|
||||
return this.sessionStateResponse?.user?.can_edit_other_users_data || false;
|
||||
}
|
||||
|
||||
public canApproveW2lTemplates() : boolean {
|
||||
if (this.sessionStateResponse === undefined || this.sessionStateResponse.user === undefined) {
|
||||
return false;
|
||||
}
|
||||
return this.sessionStateResponse.user.can_approve_w2l_templates;
|
||||
return this.sessionStateResponse?.user?.can_approve_w2l_templates || false;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user