Merge pull request #4599 from FinnStutzenstein/fixCommentSectionUpdates

Updates the cache on comment section updates. Implements missing client
This commit is contained in:
Finn Stutzenstein 2019-04-15 11:11:18 +02:00 committed by GitHub
commit de7394d1cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 6 deletions

View File

@ -75,12 +75,21 @@ export class ViewMotionCommentSection extends BaseViewModel {
*/
public updateDependencies(update: BaseViewModel): void {
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');
}
}

View File

@ -1089,6 +1089,14 @@ class MotionCommentSectionViewSet(ModelViewSet):
raise ValidationError({"detail": msg})
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):
"""