Skip to content

Commit

Permalink
fix progress
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric committed Jun 15, 2023
1 parent 1947741 commit 581847b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
23 changes: 15 additions & 8 deletions src/midjourney.message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,7 @@ export class MidjourneyMessage {
item.components.length === 0
) {
this.log(`content`, item.content);
const regex = /\(([^)]+)\)/; // matches the value inside the first parenthesis
const match = item.content.match(regex);
let progress = "wait";
if (match) {
progress = match[1];
} else {
this.log("No match found");
}
const progress = this.content2progress(item.content);
loading?.(imageUrl, progress);
break;
}
Expand All @@ -83,6 +76,20 @@ export class MidjourneyMessage {
}
return null;
}
protected content2progress(content: string) {
const spcon = content.split("**");
if (spcon.length < 3) {
return "";
}
content = spcon[2];
const regex = /\(([^)]+)\)/; // matches the value inside the first parenthesis
const match = content.match(regex);
let progress = "";
if (match) {
progress = match[1];
}
return progress;
}
UriToHash(uri: string) {
return uri.split("_").pop()?.split(".")[0] ?? "";
}
Expand Down
5 changes: 5 additions & 0 deletions src/ws.message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,11 @@ export class WsMessage {
}

protected content2progress(content: string) {
const spcon = content.split("**");
if (spcon.length < 3) {
return "";
}
content = spcon[2];
const regex = /\(([^)]+)\)/; // matches the value inside the first parenthesis
const match = content.match(regex);
let progress = "";
Expand Down

0 comments on commit 581847b

Please sign in to comment.