Commit 45111201 authored by nanahira's avatar nanahira

fix finish

parent 762ed254
......@@ -122,8 +122,8 @@ export default class EdgingPlugin
async runForEachProfile<T>(
fn: (profile: EdgingProfile) => T | Promise<T>,
action = 'run',
profiles = Array.from(this.profiles.values()),
) {
const profiles = Array.from(this.profiles.values());
return Promise.all(
profiles.map((profile) => {
const wrapper = this.wrapTry(
......@@ -143,14 +143,17 @@ export default class EdgingPlugin
return;
}
return profile.process();
});
}, 'process text');
}
async processPics() {
if (!this.pics) {
return;
}
if (!Array.from(this.profiles.values()).length) {
const profiles = Array.from(this.profiles.values()).filter((p) =>
p.getUsePics(),
);
if (!profiles.length) {
return;
}
this.logger.info(`Processing pics...`);
......@@ -164,13 +167,19 @@ export default class EdgingPlugin
return;
}
const segment = await this.pics.getSegment(pic.url);
return this.runForEachProfile(async (profile) => {
this.logger.info(`Processing pic for profile ${profile.getTarget()}...`);
if (await this.checkOvertime(profile)) {
return;
}
return profile.send(segment);
});
return this.runForEachProfile(
async (profile) => {
this.logger.info(
`Processing pic for profile ${profile.getTarget()}...`,
);
if (await this.checkOvertime(profile)) {
return;
}
return profile.send(segment);
},
'process pic',
profiles,
);
}
@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