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": { "dependencies": {
"axios": "^1.2.2", "axios": "^1.2.2",
"basscss": "^8.1.0", "basscss": "^8.1.0",
"deepmerge": "^4.3.1",
"lodash": "^4.17.21", "lodash": "^4.17.21",
"markdown-it": "^13.0.1", "markdown-it": "^13.0.1",
"neo-scraper": "^0.5.8", "neo-scraper": "^0.5.8",

View File

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

View File

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

View File

@ -1,9 +1,12 @@
import { defineStore } from "pinia"; import { defineStore } from "pinia";
import deepMerge from "deepmerge";
import { SzuruSiteConfig } from "~/config"; import { SzuruSiteConfig } from "~/config";
import type { ScrapedPostDetails, SetPostUploadInfoData } from "~/models"; import type { ScrapedPostDetails, SetPostUploadInfoData } from "~/models";
import { useStorageLocal } from "~/composables/useStorageLocal"; import { useStorageLocal } from "~/composables/useStorageLocal";
export const cfg = useStorageLocal("config", { export const cfg = useStorageLocal(
"config",
{
addPageUrlToSource: true, addPageUrlToSource: true,
autoSearchSimilar: false, autoSearchSimilar: false,
loadTagCounts: true, loadTagCounts: true,
@ -19,7 +22,11 @@ export const cfg = useStorageLocal("config", {
appendSource: true, appendSource: true,
mergeSafety: true, mergeSafety: true,
}, },
}); },
{
mergeDefaults: (storageValue, defaults) => deepMerge(defaults, storageValue),
}
);
export const usePopupStore = defineStore("popup", { export const usePopupStore = defineStore("popup", {
state: () => ({ state: () => ({