From b69fe312b815d94ffc3873e5568fef7aa11e174e Mon Sep 17 00:00:00 2001 From: Michael Lange Date: Wed, 14 Feb 2018 15:41:07 -0800 Subject: [PATCH] Watch properties cancel long poll requests --- ui/app/utils/properties/watch.js | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/ui/app/utils/properties/watch.js b/ui/app/utils/properties/watch.js index b0d1391b3..3fbedbc5c 100644 --- a/ui/app/utils/properties/watch.js +++ b/ui/app/utils/properties/watch.js @@ -18,27 +18,35 @@ export function watchRecord(modelName) { } catch (e) { yield e; break; + } finally { + this.get('store') + .adapterFor(modelName) + .cancelFindRecord(modelName, id); } } - }); + }).drop(); } -export function watchRelationship(staticRelationshipName) { +export function watchRelationship(relationshipName) { return task(function*(model, throttle = 2000) { while (true) { try { yield RSVP.all([ this.get('store') .adapterFor(model.constructor.modelName) - .reloadRelationship(model, staticRelationshipName, true), + .reloadRelationship(model, relationshipName, true), wait(throttle), ]); } catch (e) { yield e; break; + } finally { + this.get('store') + .adapterFor(model.constructor.name) + .cancelReloadRelationship(model, relationshipName); } } - }); + }).drop(); } export function watchAll(modelName) { @@ -52,7 +60,11 @@ export function watchAll(modelName) { } catch (e) { yield e; break; + } finally { + this.get('store') + .adapterFor(modelName) + .cancelFindAll(modelName); } } - }); + }).drop(); }