Merge pull request #180 from php-flasher/fix/issue-176

fix: Ensure global timeout setting applies to all requests
This commit is contained in:
Younes ENNAJI
2024-05-22 23:16:26 +01:00
committed by GitHub
5 changed files with 12 additions and 12 deletions
+2 -2
View File
@@ -7,7 +7,7 @@ import { AbstractPlugin } from './plugin'
export default class FlasherPlugin extends AbstractPlugin {
private theme: Theme
private options = {
timeout: 5000,
timeout: null,
timeouts: {
success: 5000,
info: 5000,
@@ -31,7 +31,7 @@ export default class FlasherPlugin extends AbstractPlugin {
const render = () =>
envelopes.forEach((envelope) => {
// @ts-expect-error
const typeTimeout = this.options.timeouts[envelope.type] ?? this.options.timeout
const typeTimeout = this.options.timeout ?? this.options.timeouts[envelope.type] ?? 5000;
const options = {
...this.options,
...envelope.options,
+4 -4
View File
@@ -80,7 +80,7 @@ class FlasherPlugin extends AbstractPlugin {
constructor(theme) {
super();
this.options = {
timeout: 5000,
timeout: null,
timeouts: {
success: 5000,
info: 5000,
@@ -97,9 +97,9 @@ class FlasherPlugin extends AbstractPlugin {
}
renderEnvelopes(envelopes) {
const render = () => envelopes.forEach((envelope) => {
var _a, _b;
const typeTimeout = (_a = this.options.timeouts[envelope.type]) !== null && _a !== void 0 ? _a : this.options.timeout;
const options = Object.assign(Object.assign(Object.assign({}, this.options), envelope.options), { timeout: (_b = envelope.options.timeout) !== null && _b !== void 0 ? _b : typeTimeout });
var _a, _b, _c;
const typeTimeout = (_b = (_a = this.options.timeout) !== null && _a !== void 0 ? _a : this.options.timeouts[envelope.type]) !== null && _b !== void 0 ? _b : 5000;
const options = Object.assign(Object.assign(Object.assign({}, this.options), envelope.options), { timeout: (_c = envelope.options.timeout) !== null && _c !== void 0 ? _c : typeTimeout });
this.addToContainer(this.createContainer(options), envelope, options);
});
document.readyState === 'loading' ? document.addEventListener('DOMContentLoaded', render) : render();
+4 -4
View File
@@ -86,7 +86,7 @@
constructor(theme) {
super();
this.options = {
timeout: 5000,
timeout: null,
timeouts: {
success: 5000,
info: 5000,
@@ -103,9 +103,9 @@
}
renderEnvelopes(envelopes) {
const render = () => envelopes.forEach((envelope) => {
var _a, _b;
const typeTimeout = (_a = this.options.timeouts[envelope.type]) !== null && _a !== void 0 ? _a : this.options.timeout;
const options = Object.assign(Object.assign(Object.assign({}, this.options), envelope.options), { timeout: (_b = envelope.options.timeout) !== null && _b !== void 0 ? _b : typeTimeout });
var _a, _b, _c;
const typeTimeout = (_b = (_a = this.options.timeout) !== null && _a !== void 0 ? _a : this.options.timeouts[envelope.type]) !== null && _b !== void 0 ? _b : 5000;
const options = Object.assign(Object.assign(Object.assign({}, this.options), envelope.options), { timeout: (_c = envelope.options.timeout) !== null && _c !== void 0 ? _c : typeTimeout });
this.addToContainer(this.createContainer(options), envelope, options);
});
document.readyState === 'loading' ? document.addEventListener('DOMContentLoaded', render) : render();
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long