Merge pull request #4599 from FinnStutzenstein/fixCommentSectionUpdates
Updates the cache on comment section updates. Implements missing client
This commit is contained in:
commit
de7394d1cc
@ -75,12 +75,21 @@ export class ViewMotionCommentSection extends BaseViewModel {
|
|||||||
*/
|
*/
|
||||||
public updateDependencies(update: BaseViewModel): void {
|
public updateDependencies(update: BaseViewModel): void {
|
||||||
if (update instanceof ViewGroup) {
|
if (update instanceof ViewGroup) {
|
||||||
this.updateGroup(update);
|
if (this.section.read_groups_id.includes(update.id)) {
|
||||||
|
const groupIndex = this.read_groups.findIndex(group => group.id === update.id);
|
||||||
|
if (groupIndex < 0) {
|
||||||
|
this.read_groups.push(update);
|
||||||
|
} else {
|
||||||
|
this.read_groups[groupIndex] = update;
|
||||||
|
}
|
||||||
|
} else if (this.section.write_groups_id.includes(update.id)) {
|
||||||
|
const groupIndex = this.write_groups.findIndex(group => group.id === update.id);
|
||||||
|
if (groupIndex < 0) {
|
||||||
|
this.write_groups.push(update);
|
||||||
|
} else {
|
||||||
|
this.write_groups[groupIndex] = update;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Implement updating of groups
|
|
||||||
public updateGroup(group: ViewGroup): void {
|
|
||||||
console.log('implement update group of motion comment section');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1089,6 +1089,14 @@ class MotionCommentSectionViewSet(ModelViewSet):
|
|||||||
raise ValidationError({"detail": msg})
|
raise ValidationError({"detail": msg})
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
def update(self, *args, **kwargs):
|
||||||
|
response = super().update(*args, **kwargs)
|
||||||
|
# Update all affected motioncomments to update their `read_groups_id` field,
|
||||||
|
# which is taken from the updated section.
|
||||||
|
section = self.get_object()
|
||||||
|
inform_changed_data(MotionComment.objects.filter(section=section))
|
||||||
|
return response
|
||||||
|
|
||||||
|
|
||||||
class StatuteParagraphViewSet(ModelViewSet):
|
class StatuteParagraphViewSet(ModelViewSet):
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user