Fix slider value update bug in firefox

This commit is contained in:
Johannes Zellner
2025-06-26 17:40:12 +02:00
parent 26d18031f2
commit 016bfcddad

View File

@@ -1,6 +1,6 @@
<script setup>
import { ref, onMounted, computed } from 'vue';
import { ref, onMounted, computed, nextTick } from 'vue';
import { Button, FormGroup, TagInput } from 'pankow';
import { prettyBinarySize } from 'pankow/utils';
import AppsModel from '../../models/AppsModel.js';
@@ -86,19 +86,23 @@ onMounted(async () => {
devices.value = Object.keys(props.app.devices);
currentDevices.value = Object.keys(props.app.devices);
memoryLimit.value = props.app.memoryLimit || props.app.manifest.memoryLimit || (256 * 1024 * 1024);
currentMemoryLimit.value = memoryLimit.value;
const tmpMemoryLimit = props.app.memoryLimit || props.app.manifest.memoryLimit || (256 * 1024 * 1024);
// create ticks starting from manifest memory limit. the memory limit here is just RAM
memoryTicks.value = [];
// we max system memory and current app memory for the case where the user configured the app on another server with more resources
const nearest256m = Math.ceil(Math.max(result.memory, memoryLimit.value) / (256*1024*1024)) * 256 * 1024 * 1024;
const nearest256m = Math.ceil(Math.max(result.memory, tmpMemoryLimit) / (256*1024*1024)) * 256 * 1024 * 1024;
const startTick = props.app.manifest.memoryLimit || (256 * 1024 * 1024);
// code below ensure we atleast have 2 ticks to keep the slider usable
memoryTicks.value.push(startTick); // start tick
for (var i = startTick * 2; i < nearest256m; i *= 2) memoryTicks.value.push(i);
memoryTicks.value.push(nearest256m); // end tick
// we need to wait to set slider value until next DOM tick for firefox to pick it up!
await nextTick();
memoryLimit.value = tmpMemoryLimit;
currentMemoryLimit.value = tmpMemoryLimit;
});
</script>