wrong diffusion
This commit is contained in:
		@ -255,7 +255,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _for
 | 
				
			|||||||
  \*********************/
 | 
					  \*********************/
 | 
				
			||||||
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
 | 
					/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */   \"default\": function() { return /* binding */ Live; }\n/* harmony export */ });\n/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils */ \"./src/utils.js\");\n/* harmony import */ var _model__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./model */ \"./src/model.js\");\n\n\nclass Live {\n  constructor({\n    url,\n    timeout = 10,\n    src = \"\"\n  } = {}) {\n    this.url = url;\n    this.timeout = timeout;\n    this.src = src;\n    this.interval = null;\n    this.promise = null;\n    this.items = [];\n    this.current = null;\n  } //-- data refreshing\n\n\n  drop() {\n    this.promise = null;\n  }\n  /**\n   * Fetch data from server.\n   *\n   * @param {Object} options\n   * @param {Function} options.then: call this method on fetch, `this` passed as argument.\n   * @return {Promise} Promise resolving to fetched items.\n   */\n\n\n  fetch({\n    then = null\n  } = {}) {\n    const promise = fetch(this.url).then(response => response.ok ? response.json() : Promise.reject(response)).then(data => {\n      this.items = data;\n      let item = this.items && this.items[this.items.length - 1];\n\n      if (item) {\n        item.src = this.src;\n        this.current = new _model__WEBPACK_IMPORTED_MODULE_1__[\"default\"](item);\n      } else this.current = null;\n\n      if (then) then(this);\n      return this.items;\n    });\n    this.promise = promise;\n    return promise;\n  }\n\n  _refresh(options = {}) {\n    const promise = this.fetch(options);\n    promise.then(() => {\n      if (promise != this.promise) return [];\n    });\n    return promise;\n  }\n  /**\n   * Refresh live info every `this.timeout`.\n   * @param {Object} options: arguments passed to `this.fetch`.\n   */\n\n\n  refresh(options = {}) {\n    if (this.interval !== null) return;\n\n    this._refresh(options);\n\n    this.interval = (0,_utils__WEBPACK_IMPORTED_MODULE_0__.setEcoInterval)(() => this._refresh(options), this.timeout * 1000);\n    return this.interval;\n  }\n\n  stopRefresh() {\n    this.interval !== null && clearInterval(this.interval);\n  }\n\n}\n\n//# sourceURL=webpack://aircox-assets/./src/live.js?");
 | 
					eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */   \"default\": function() { return /* binding */ Live; }\n/* harmony export */ });\n/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils */ \"./src/utils.js\");\n/* harmony import */ var _model__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./model */ \"./src/model.js\");\n\n\nclass Live {\n  constructor({\n    url,\n    timeout = 10,\n    src = \"\"\n  } = {}) {\n    this.url = url;\n    this.timeout = timeout;\n    this.src = src;\n    this.interval = null;\n    this.promise = null;\n    this.items = [];\n    this.current = null;\n  } //-- data refreshing\n\n\n  drop() {\n    this.promise = null;\n  }\n  /**\n   * Fetch data from server.\n   *\n   * @param {Object} options\n   * @param {Function} options.then: call this method on fetch, `this` passed as argument.\n   * @return {Promise} Promise resolving to fetched items.\n   */\n\n\n  fetch({\n    then = null\n  } = {}) {\n    const promise = fetch(this.url).then(response => response.ok ? response.json() : Promise.reject(response)).then(data => {\n      data.forEach(item => {\n        if (item.start) item.start = new Date(item.start);\n        if (item.end) item.end = new Date(item.end);\n      });\n      this.items = data;\n      const now = new Date();\n      const item = data.find(it => it.start && it.start <= now < it.end);\n\n      if (item) {\n        item.src = this.src;\n        this.current = new _model__WEBPACK_IMPORTED_MODULE_1__[\"default\"](item);\n      } else this.current = null;\n\n      if (then) then(this);\n      return this.items;\n    });\n    this.promise = promise;\n    return promise;\n  }\n\n  _refresh(options = {}) {\n    const promise = this.fetch(options);\n    promise.then(() => {\n      if (promise != this.promise) return [];\n    });\n    return promise;\n  }\n  /**\n   * Refresh live info every `this.timeout`.\n   * @param {Object} options: arguments passed to `this.fetch`.\n   */\n\n\n  refresh(options = {}) {\n    if (this.interval !== null) return;\n\n    this._refresh(options);\n\n    this.interval = (0,_utils__WEBPACK_IMPORTED_MODULE_0__.setEcoInterval)(() => this._refresh(options), this.timeout * 1000);\n    return this.interval;\n  }\n\n  stopRefresh() {\n    this.interval !== null && clearInterval(this.interval);\n  }\n\n}\n\n//# sourceURL=webpack://aircox-assets/./src/live.js?");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/***/ }),
 | 
					/***/ }),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -30,9 +30,14 @@ export default class Live {
 | 
				
			|||||||
            response.ok ? response.json()
 | 
					            response.ok ? response.json()
 | 
				
			||||||
                        : Promise.reject(response)
 | 
					                        : Promise.reject(response)
 | 
				
			||||||
        ).then(data => {
 | 
					        ).then(data => {
 | 
				
			||||||
 | 
					            data.forEach(item => {
 | 
				
			||||||
 | 
					                if(item.start) item.start = new Date(item.start)
 | 
				
			||||||
 | 
					                if(item.end) item.end = new Date(item.end)
 | 
				
			||||||
 | 
					            })
 | 
				
			||||||
            this.items = data
 | 
					            this.items = data
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            let item = this.items && this.items[this.items.length-1]
 | 
					            const now = new Date()
 | 
				
			||||||
 | 
					            const item = data.find(it => it.start && (it.start <= now < it.end))
 | 
				
			||||||
            if(item) {
 | 
					            if(item) {
 | 
				
			||||||
                item.src = this.src
 | 
					                item.src = this.src
 | 
				
			||||||
                this.current = new Model(item)
 | 
					                this.current = new Model(item)
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user