Source fixes: avoid race and wait a minute after uploading to prevent unnecessary...
[redakcja.git] / src / redakcja / static / js / wiki / view_properties.js
index 56bd84d..51f26d5 100644 (file)
                     modal.data('target-input', input);
                     var imglist = modal.find('.modal-body');
                     imglist.html('');
-                    $.each(self.doc.galleryImages, (i, imgItem) => {
-                        img = $("<img>").attr("src", imgItem.thumb).attr('title', imgItem.url).data('url', imgItem.url).on('click', function() {
-                            imglist.find('img').removeClass('active');
-                            $(this).addClass('active');
-                        });
-                        imglist.append(img);
+
+                    self.doc.refreshImageGallery({
+                        success: function(galleryImages) {
+                            $.each(self.doc.galleryImages, (i, imgItem) => {
+                                let img = $("<img>").attr("src", imgItem.thumb).attr('title', imgItem.url).data('url', imgItem.url).on('click', function() {
+                                    imglist.find('img').removeClass('active');
+                                    $(this).addClass('active');
+                                });
+                                imglist.append(img);
+                            });
+                        }
                     });
                 })
                 $('#media-chooser .ctrl-ok').on('click', function (event) {