enh: model move to top

This commit is contained in:
Timothy J. Baek
2024-09-18 00:49:27 +02:00
parent 984e0c533e
commit 8e3ad45ce4
3 changed files with 64 additions and 0 deletions
@@ -94,6 +94,35 @@
window.addEventListener('message', messageHandler, false);
};
const moveToTopHandler = async (model) => {
let info = model.info;
if (!info) {
info = {
id: model.id,
name: model.name,
meta: {
position: 0
},
params: {}
};
}
info.meta = {
...info.meta,
position: 0
};
const res = await updateModelById(localStorage.token, info.id, info);
if (res) {
toast.success($i18n.t(`Model {{name}} is now at the top`, { name: info.id }));
}
await models.set(await getModels(localStorage.token));
_models = $models;
};
const hideModelHandler = async (model) => {
let info = model.info;
@@ -440,6 +469,9 @@
exportHandler={() => {
exportModelHandler(model);
}}
moveToTopHandler={() => {
moveToTopHandler(model);
}}
hideHandler={() => {
hideModelHandler(model);
}}