Merge remote-tracking branch 'origin/bugfix/reactivity' into release/core-0.17

This commit is contained in:
Jean-Baptiste Pasquier 2021-05-20 16:22:01 +02:00
commit 477ac838da
4 changed files with 31 additions and 19 deletions

View File

@ -14,10 +14,7 @@ export const HublReactivity = {
callback: function () {
this.subscribe();
}
},
refreshData: {
type: String,
},
}
},
async fetchData(value) {
this.resourceId = null;
@ -30,11 +27,26 @@ export const HublReactivity = {
}
this.subscribe();
},
unsubscribe(resourceId, targetSrc) {
const resourcesSub = store.subscriptionVirtualContainersIndex.get(resourceId);
const targetSub = store.subscriptionVirtualContainersIndex.get(targetSrc);
const newResourceSub = resourcesSub.filter(r => r !== targetSrc);
const newTargetSub = targetSub.filter(r => r !== resourceId);
store.subscriptionVirtualContainersIndex.set(resourceId, newResourceSub);
store.subscriptionVirtualContainersIndex.set(targetSrc, newTargetSub);
},
detached() {
this.unsubscribe(this.resourceId, this.targetSrc)
},
subscribe() {
if (this.refreshData === '') { // clears cache and re-fetch data
if (this.oldResourceId && this.oldTargetSrc && (this.oldResourceId !== this.resourceId || this.oldTargetSrc !== this.targetSrc)) {
this.unsubscribe(this.oldResourceId, this.oldTargetSrc);
}
if (this.resourceId && this.targetSrc) {
store.subscribeVirtualContainerTo(this.resourceId, this.targetSrc);
} else { // notifies components
store.subscribeResourceTo(this.resourceId, this.targetSrc);
store.subscribeVirtualContainerTo(this.targetSrc, this.resourceId);
this.oldResourceId = this.resourceId;
this.oldTargetSrc = this.targetSrc;
}
}
}

View File

@ -16,8 +16,8 @@ solid-widget(name=`hubl-admin-circle-join-button`)
hubl-reactivity(data-src=`${getComponent('circles').endpoints.get}` target-src='${value}')
hubl-reactivity(data-src=`${getComponent('circles').endpoints.get}joinable/` target-src='${value}')
hubl-reactivity(data-src=`${getComponent('circles').endpoints.post}` target-src='${value}')
hubl-reactivity(data-src=`${getComponent('circles').endpoints.post}joinable/` target-src='${value}' refresh-data)
hubl-reactivity(bind-user nested-field="circles" target-src='${value}' refresh-data)
hubl-reactivity(data-src=`${getComponent('circles').endpoints.post}joinable/` target-src='${value}')
hubl-reactivity(bind-user nested-field="circles" target-src='${value}')
include page-admin-circles.pug

View File

@ -3,8 +3,8 @@ solid-widget(name=`leave-circle-reactivity`)
hubl-reactivity(data-src=`${getComponent('circles').endpoints.get}` target-src='${value}')
hubl-reactivity(data-src=`${getComponent('circles').endpoints.get}joinable/` target-src='${value}')
hubl-reactivity(data-src=`${getComponent('circles').endpoints.post}` target-src='${value}')
hubl-reactivity(data-src=`${getComponent('circles').endpoints.post}joinable/` target-src='${value}' refresh-data)
hubl-reactivity(bind-user nested-field="circles" target-src='${value}' refresh-data)
hubl-reactivity(data-src=`${getComponent('circles').endpoints.post}joinable/` target-src='${value}')
hubl-reactivity(bind-user nested-field="circles" target-src='${value}')
solid-widget(name=`hubl-admin-circle-leave-button`)
template
@ -17,8 +17,8 @@ solid-widget(name=`hubl-admin-circle-leave-button`)
hubl-reactivity(data-src=`${getComponent('circles').endpoints.get}` target-src='${src}')
hubl-reactivity(data-src=`${getComponent('circles').endpoints.get}joinable/` target-src='${src}')
hubl-reactivity(data-src=`${getComponent('circles').endpoints.post}` target-src='${src}')
hubl-reactivity(data-src=`${getComponent('circles').endpoints.post}joinable/` target-src='${src}' refresh-data)
hubl-reactivity(bind-user nested-field="circles" target-src='${src}' refresh-data)
hubl-reactivity(data-src=`${getComponent('circles').endpoints.post}joinable/` target-src='${src}')
hubl-reactivity(bind-user nested-field="circles" target-src='${src}')
solid-display(
data-src="${src}"
fields="circle"

View File

@ -43,8 +43,8 @@ div.segment.full.padding-large.sm-padding-xsmall.sm-padding-top-medium.whitespac
hubl-reactivity(data-src=`${getComponent('projects').endpoints.get}` target-src='${value}')
hubl-reactivity(data-src=`${getComponent('projects').endpoints.get}joinable/` target-src='${value}')
hubl-reactivity(data-src=`${getComponent('projects').endpoints.post}` target-src='${value}')
hubl-reactivity(data-src=`${getComponent('projects').endpoints.post}joinable/` target-src='${value}' refresh-data)
hubl-reactivity(bind-user nested-field="projects" target-src='${value}' refresh-data)
hubl-reactivity(data-src=`${getComponent('projects').endpoints.post}joinable/` target-src='${value}')
hubl-reactivity(bind-user nested-field="projects" target-src='${value}')
solid-widget(name=`hubl-admin-project-leave-button`)
template
@ -57,8 +57,8 @@ div.segment.full.padding-large.sm-padding-xsmall.sm-padding-top-medium.whitespac
hubl-reactivity(data-src=`${getComponent('projects').endpoints.get}` target-src='${src}')
hubl-reactivity(data-src=`${getComponent('projects').endpoints.get}joinable/` target-src='${src}')
hubl-reactivity(data-src=`${getComponent('projects').endpoints.post}` target-src='${src}')
hubl-reactivity(data-src=`${getComponent('projects').endpoints.post}joinable/` target-src='${src}' refresh-data)
hubl-reactivity(bind-user nested-field="projects" target-src='${src}' refresh-data)
hubl-reactivity(data-src=`${getComponent('projects').endpoints.post}joinable/` target-src='${src}')
hubl-reactivity(bind-user nested-field="projects" target-src='${src}')
solid-display(
data-src="${src}"
fields="project"
@ -122,8 +122,8 @@ div.segment.full.padding-large.sm-padding-xsmall.sm-padding-top-medium.whitespac
hubl-reactivity(data-src=`${getComponent('projects').endpoints.get}` target-src='${value}')
hubl-reactivity(data-src=`${getComponent('projects').endpoints.get}joinable/` target-src='${value}')
hubl-reactivity(data-src=`${getComponent('projects').endpoints.post}` target-src='${value}')
hubl-reactivity(data-src=`${getComponent('projects').endpoints.post}joinable/` target-src='${value}' refresh-data)
hubl-reactivity(bind-user nested-field="projects" target-src='${value}' refresh-data)
hubl-reactivity(data-src=`${getComponent('projects').endpoints.post}joinable/` target-src='${value}')
hubl-reactivity(bind-user nested-field="projects" target-src='${value}')
solid-display(
class='table-body'