<% if (['image', 'animation'].includes(ctx.post.type)) { %> - + <% } else if (ctx.post.type === 'flash') { %> - + +
Your browser does not support Flash.
<% } else if (ctx.post.type === 'video') { %> From 096b6bc61ea318f0f39431be916721b63e7c7366 Mon Sep 17 00:00:00 2001 From: Eva Date: Fri, 26 May 2023 08:30:58 +0200 Subject: [PATCH 16/18] client/css: fix overextended broken thumbnail --- client/css/core-general.styl | 1 + 1 file changed, 1 insertion(+) diff --git a/client/css/core-general.styl b/client/css/core-general.styl index 942ca3d0c..b3a2c7ee1 100644 --- a/client/css/core-general.styl +++ b/client/css/core-general.styl @@ -287,6 +287,7 @@ nav background-size: contain background-position: center display: inline-block + overflow: hidden width: 20px height: 20px &.empty From a496e8980fce447e018cd380fb3bf65e09820a18 Mon Sep 17 00:00:00 2001 From: Eva Date: Thu, 28 Mar 2024 03:41:35 +0100 Subject: [PATCH 17/18] server/rest: allow files with empty content --- server/szurubooru/rest/context.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/szurubooru/rest/context.py b/server/szurubooru/rest/context.py index 40ba0bcb5..393a37e2e 100644 --- a/server/szurubooru/rest/context.py +++ b/server/szurubooru/rest/context.py @@ -51,7 +51,7 @@ def get_file( use_video_downloader: bool = False, allow_tokens: bool = True, ) -> bytes: - if name in self._files and self._files[name]: + if name in self._files: return self._files[name] if name + "Url" in self._params: From 7972c34448a14614952b04dc3f749a742940f835 Mon Sep 17 00:00:00 2001 From: Eva Date: Thu, 28 Mar 2024 03:39:33 +0100 Subject: [PATCH 18/18] client/posts: make discard thumbnail link delete existing custom thumb I can see the intent, sadly this was always broken in the case where the post already has a custom thumbnail from initial load, and we don't drag any new files. It did not actually remove the existing thumbnail. Before 12c4542bb2482fac89aae9a04b15984a56bb8fb0 it would actually crash, but this now makes it behave as expected. Also properly syncs internal state with what's displayed to the user. --- client/js/api.js | 9 ++++++-- client/js/controllers/post_main_controller.js | 8 ++----- .../js/controls/post_edit_sidebar_control.js | 22 +++++++++++++------ 3 files changed, 24 insertions(+), 15 deletions(-) diff --git a/client/js/api.js b/client/js/api.js index 5bde6d810..d3f74c267 100644 --- a/client/js/api.js +++ b/client/js/api.js @@ -294,11 +294,16 @@ class Api extends events.EventTarget { // transform the request: upload each file, then make the request use // its tokens. data = Object.assign({}, data); + let fileData = {}; let abortFunction = () => {}; let promise = Promise.resolve(); if (files) { for (let key of Object.keys(files)) { const file = files[key]; + if (file === null) { + fileData[key] = null; + continue; + } const fileId = this._getFileId(file); if (fileTokens[fileId]) { data[key + "Token"] = fileTokens[fileId]; @@ -324,7 +329,7 @@ class Api extends events.EventTarget { url, requestFactory, data, - {}, + fileData, options ); abortFunction = () => requestPromise.abort(); @@ -388,7 +393,7 @@ class Api extends events.EventTarget { if (files) { for (let key of Object.keys(files)) { const value = files[key]; - if (value.constructor === String) { + if (value !== null && value.constructor === String) { data[key + "Url"] = value; } else { req.attach(key, value || new Blob()); diff --git a/client/js/controllers/post_main_controller.js b/client/js/controllers/post_main_controller.js index 95cfdb52f..0634069ac 100644 --- a/client/js/controllers/post_main_controller.js +++ b/client/js/controllers/post_main_controller.js @@ -178,15 +178,11 @@ class PostMainController extends BasePostController { if (e.detail.relations !== undefined) { post.relations = e.detail.relations; } - if (e.detail.content !== undefined) { - post.newContent = e.detail.content; - } - if (e.detail.thumbnail !== undefined) { - post.newThumbnail = e.detail.thumbnail; - } if (e.detail.source !== undefined) { post.source = e.detail.source; } + post.newContent = e.detail.content; + post.newThumbnail = e.detail.thumbnail; post.save().then( () => { this._view.sidebarControl.showSuccess("Post saved."); diff --git a/client/js/controls/post_edit_sidebar_control.js b/client/js/controls/post_edit_sidebar_control.js index 3f31f76f7..9f2d37da2 100644 --- a/client/js/controls/post_edit_sidebar_control.js +++ b/client/js/controls/post_edit_sidebar_control.js @@ -138,10 +138,7 @@ class PostEditSidebarControl extends events.EventTarget { this._thumbnailRemovalLinkNode.addEventListener("click", (e) => this._evtRemoveThumbnailClick(e) ); - this._thumbnailRemovalLinkNode.style.display = this._post - .customThumbnailUrl - ? "block" - : "none"; + this._thumbnailRemovalLinkUpdate(this._post); } if (this._addNoteLinkNode) { @@ -249,12 +246,25 @@ class PostEditSidebarControl extends events.EventTarget { this._poolsExpander.title = `Pools (${this._post.pools.length})`; } + _thumbnailRemovalLinkUpdate(post) { + if (this._thumbnailRemovalLinkNode) { + this._thumbnailRemovalLinkNode.style.display = post + .customThumbnailUrl + ? "block" + : "none"; + } + } + _evtPostContentChange(e) { this._contentFileDropper.reset(); + this._thumbnailRemovalLinkUpdate(e.detail.post); + this._newPostContent = null; } _evtPostThumbnailChange(e) { this._thumbnailFileDropper.reset(); + this._thumbnailRemovalLinkUpdate(e.detail.post); + this._newPostThumbnail = undefined; } _evtRemoveThumbnailClick(e) { @@ -427,9 +437,7 @@ class PostEditSidebarControl extends events.EventTarget { : undefined, thumbnail: - this._newPostThumbnail !== undefined - ? this._newPostThumbnail - : undefined, + this._newPostThumbnail, source: this._sourceInputNode ? this._sourceInputNode.value