From c58e33b1e92de2b1b348e99926c6a7d928199dfb Mon Sep 17 00:00:00 2001 From: Christian Cueni Date: Thu, 18 Nov 2021 16:03:42 +0100 Subject: [PATCH 1/2] Send module update upon result only once --- client/src/pages/module/module.vue | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/client/src/pages/module/module.vue b/client/src/pages/module/module.vue index 5cd2a7fd..d00a547d 100644 --- a/client/src/pages/module/module.vue +++ b/client/src/pages/module/module.vue @@ -30,14 +30,13 @@ data() { return { module: {}, + updateSent: false }; }, created() { this.$log.debug('**** module.vue created ****'); this.$log.debug(`||| module id ${this.module.id} |||`); - - this.updateLastVisitedModule(this.module.id); }, mounted() { this.$log.debug('**** module.vue mounted ****'); @@ -54,10 +53,13 @@ update(data) { return this.$getRidOfEdges(data).module || {}; }, - // result({data: {module: {id}}}) { - // this.$log.debug(`=== updating result for module ${id} ===`); - // this.updateLastVisitedModule(id); - // }, + result({data: {module: {id}}}) { + if (!this.updateSent) { + this.$log.debug(`=== updating result for module ${id} ===`); + this.updateLastVisitedModule(id); + this.updateSent = true; + } + }, fetchPolicy: 'cache-first', }; }, From 6539ac88d8c454ce274771908d7b31001c922327 Mon Sep 17 00:00:00 2001 From: Christian Cueni Date: Mon, 29 Nov 2021 12:04:28 +0100 Subject: [PATCH 2/2] Make old_type optional --- .../migrations/0014_auto_20211129_1038.py | 18 ++++++++++++++++++ server/basicknowledge/models.py | 3 ++- server/rooms/wagtail_hooks.py | 3 +++ 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 server/basicknowledge/migrations/0014_auto_20211129_1038.py diff --git a/server/basicknowledge/migrations/0014_auto_20211129_1038.py b/server/basicknowledge/migrations/0014_auto_20211129_1038.py new file mode 100644 index 00000000..3eb2f9e6 --- /dev/null +++ b/server/basicknowledge/migrations/0014_auto_20211129_1038.py @@ -0,0 +1,18 @@ +# Generated by Django 2.2.24 on 2021-11-29 10:38 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('basicknowledge', '0013_auto_20211110_1140'), + ] + + operations = [ + migrations.AlterField( + model_name='basicknowledge', + name='old_type', + field=models.CharField(blank=True, choices=[('language_communication', 'Sprache & Kommunikation'), ('society', 'Gesellschaft'), ('interdisciplinary', 'Überfachliches Instrument')], max_length=100), + ), + ] diff --git a/server/basicknowledge/models.py b/server/basicknowledge/models.py index 5b5ae791..28444977 100644 --- a/server/basicknowledge/models.py +++ b/server/basicknowledge/models.py @@ -57,7 +57,8 @@ class BasicKnowledge(StrictHierarchyPage): old_type = models.CharField( max_length=100, - choices=InstrumentType.CATEGORY_CHOICES + choices=InstrumentType.CATEGORY_CHOICES, + blank=True ) content_panels = [ diff --git a/server/rooms/wagtail_hooks.py b/server/rooms/wagtail_hooks.py index 047ce7ac..7ce1475d 100644 --- a/server/rooms/wagtail_hooks.py +++ b/server/rooms/wagtail_hooks.py @@ -34,6 +34,9 @@ def get_room_blocks(page): def get_block_from_stream_data(stream_data, block_name): + if len(stream_data) == 0: + return [] + if isinstance(stream_data[0], tuple): return [block for block in stream_data if block[0] in [block_name]] if isinstance(stream_data[0], dict):