Commit 45111201 authored by nanahira's avatar nanahira

fix finish

parent 762ed254
...@@ -122,8 +122,8 @@ export default class EdgingPlugin ...@@ -122,8 +122,8 @@ export default class EdgingPlugin
async runForEachProfile<T>( async runForEachProfile<T>(
fn: (profile: EdgingProfile) => T | Promise<T>, fn: (profile: EdgingProfile) => T | Promise<T>,
action = 'run', action = 'run',
profiles = Array.from(this.profiles.values()),
) { ) {
const profiles = Array.from(this.profiles.values());
return Promise.all( return Promise.all(
profiles.map((profile) => { profiles.map((profile) => {
const wrapper = this.wrapTry( const wrapper = this.wrapTry(
...@@ -143,14 +143,17 @@ export default class EdgingPlugin ...@@ -143,14 +143,17 @@ export default class EdgingPlugin
return; return;
} }
return profile.process(); return profile.process();
}); }, 'process text');
} }
async processPics() { async processPics() {
if (!this.pics) { if (!this.pics) {
return; return;
} }
if (!Array.from(this.profiles.values()).length) { const profiles = Array.from(this.profiles.values()).filter((p) =>
p.getUsePics(),
);
if (!profiles.length) {
return; return;
} }
this.logger.info(`Processing pics...`); this.logger.info(`Processing pics...`);
...@@ -164,13 +167,19 @@ export default class EdgingPlugin ...@@ -164,13 +167,19 @@ export default class EdgingPlugin
return; return;
} }
const segment = await this.pics.getSegment(pic.url); const segment = await this.pics.getSegment(pic.url);
return this.runForEachProfile(async (profile) => { return this.runForEachProfile(
this.logger.info(`Processing pic for profile ${profile.getTarget()}...`); async (profile) => {
if (await this.checkOvertime(profile)) { this.logger.info(
return; `Processing pic for profile ${profile.getTarget()}...`,
} );
return profile.send(segment); if (await this.checkOvertime(profile)) {
}); return;
}
return profile.send(segment);
},
'process pic',
profiles,
);
} }
@OnPrivate() @OnPrivate()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment