Small fixes in the merge posts feature.

gh-actions
neobooru 2023-05-28 17:43:09 +02:00
parent d2416d829d
commit 1376ea8fd5
4 changed files with 40 additions and 19 deletions

View File

@ -28,6 +28,7 @@
"dependencies": {
"axios": "^1.2.2",
"basscss": "^8.1.0",
"deepmerge": "^4.3.1",
"lodash": "^4.17.21",
"markdown-it": "^13.0.1",
"neo-scraper": "^0.5.8",

View File

@ -20,6 +20,7 @@ specifiers:
chokidar: ^3.5.3
cross-env: ^7.0.3
crx: ^5.0.1
deepmerge: ^4.3.1
eslint: ^8.32.0
eslint-plugin-vue: ^9.9.0
esno: ^0.16.3
@ -48,6 +49,7 @@ specifiers:
dependencies:
axios: 1.4.0
basscss: 8.1.0
deepmerge: 4.3.1
lodash: 4.17.21
markdown-it: 13.0.1
neo-scraper: 0.5.8
@ -2192,7 +2194,6 @@ packages:
/deepmerge/4.3.1:
resolution: {integrity: sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==}
engines: {node: '>=0.10.0'}
dev: true
/defaults/1.0.4:
resolution: {integrity: sha512-eFuaLoy/Rxalv2kr+lqMlUnrDWV+3j4pljOIJgLIhI058IQfWJ7vXhyEIHu+HtC738klGALYxOKDO0bQP3tg8A==}

View File

@ -2,6 +2,7 @@
import { isEqual, cloneDeep } from "lodash";
import SzurubooruApi from "~/api";
import { Post, UpdatePostRequest } from "~/api/models";
import { isMobile } from "~/env";
import { BrowserCommand, PostUpdateCommandData, TagDetails } from "~/models";
import { cfg, useMergeStore, usePopupStore } from "~/stores";
import { emptyPost, getUrl } from "~/utils";
@ -146,6 +147,12 @@ async function mergeChanges() {
return;
}
merge.uploadInfo.push({
instanceId: szuruConfig.id,
postId: `merge-${existingPostRo.id}`,
info: { state: "uploading", instancePostId: existingPostRo.id },
});
const cmdData = new PostUpdateCommandData(existingPostRo.id, req, szuruConfig);
const cmd = new BrowserCommand("update_post", cmdData);
await browser.runtime.sendMessage(cmd);
@ -194,7 +201,13 @@ watch(
);
onMounted(async () => {
// Clear upload info and error.
merge.uploadInfo.splice(0);
merge.genericError = undefined;
// Load existing post data.
existingPostRo = await szuru?.getPost(props.postId);
if (existingPostRo) {
post.value = cloneDeep(existingPostRo);
if (cfg.value.merge.appendSource) appendSources();
@ -237,8 +250,7 @@ onMounted(async () => {
</div>
</div>
<!-- <div class="popup-columns" :class="{ mobile: isMobile }"> -->
<div class="popup-columns">
<div class="popup-columns" :class="{ mobile: isMobile }">
<div class="popup-left">
<div class="popup-section">
<div style="display: flex; flex-direction: column; gap: 5px">

View File

@ -1,25 +1,32 @@
import { defineStore } from "pinia";
import deepMerge from "deepmerge";
import { SzuruSiteConfig } from "~/config";
import type { ScrapedPostDetails, SetPostUploadInfoData } from "~/models";
import { useStorageLocal } from "~/composables/useStorageLocal";
export const cfg = useStorageLocal("config", {
addPageUrlToSource: true,
autoSearchSimilar: false,
loadTagCounts: true,
useContentTokens: true,
sites: [] as Array<SzuruSiteConfig>,
selectedSiteId: undefined as string | undefined,
addTagImplications: true,
merge: {
expandOptions: true,
expandExistingTags: false,
expandAddTags: true,
addMissingTags: true,
appendSource: true,
mergeSafety: true,
export const cfg = useStorageLocal(
"config",
{
addPageUrlToSource: true,
autoSearchSimilar: false,
loadTagCounts: true,
useContentTokens: true,
sites: [] as Array<SzuruSiteConfig>,
selectedSiteId: undefined as string | undefined,
addTagImplications: true,
merge: {
expandOptions: true,
expandExistingTags: false,
expandAddTags: true,
addMissingTags: true,
appendSource: true,
mergeSafety: true,
},
},
});
{
mergeDefaults: (storageValue, defaults) => deepMerge(defaults, storageValue),
}
);
export const usePopupStore = defineStore("popup", {
state: () => ({