feat: reduce the sha hash size when the tag is too long

This commit is contained in:
Joxit 2020-05-21 00:47:11 +02:00
parent 00fe443a7c
commit 06d6293e79
No known key found for this signature in database
GPG Key ID: F526592B8E012263
2 changed files with 5 additions and 1 deletions

View File

@ -28,7 +28,7 @@
if (chars >= 70) {
self.display_id = self.digest;
self.title = '';
} else if (chars === 0) {
} else if (chars <= 0) {
self.display_id = '';
self.title = self.digest;
} else {

View File

@ -93,6 +93,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
// window.innerWidth is a blocking access, cache its result.
const innerWidth = window.innerWidth;
var chars = 0;
var max = registryUI.taglist.tags.reduce(function(acc, e) {
return e.tag.length > acc ? e.tag.length : acc;
}, 0);
if (innerWidth >= 1440) {
chars = 71;
} else if (innerWidth < 1024) {
@ -101,6 +104,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
// SHA256:12345678 + scaled between 1024 and 1440px
chars = 15 + 56 * ((innerWidth - 1024) / 416);
}
if (max > 20) chars -= (max - 20);
registryUI.taglist.tags.map(function (image) {
image.trigger('content-digest-chars', chars);
});