Skip to content

Commit

Permalink
add alwaysUploadAsContent option
Browse files Browse the repository at this point in the history
  • Loading branch information
shibaobun authored and neobooru committed Jan 21, 2025
1 parent 7c5c4d3 commit 9e07ee1
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
11 changes: 11 additions & 0 deletions src/options/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,17 @@ wnd.szc_set_config_version = (v = 0) => (cfg.value.version = v);
</p>
</div>

<div class="col-12 md:col-6">
<label>
<input type="checkbox" v-model="cfg.alwaysUploadAsContent" />
Always upload as content
</label>
<p class="hint">
This will always upload the image content directly, instead of
as an URL
</p>
</div>

<span class="col-12 status-quiet">{{ versionInfo }}</span>
</div>
</TabPanel>
Expand Down
15 changes: 11 additions & 4 deletions src/popup/pages/PopupMain.vue
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,12 @@ async function upload() {
try {
const post: ScrapedPostDetails = cloneDeep(pop.selectedPost)!;
// uploadMode "content" requires a content token to work. So ensure it is set.
if (post.uploadMode == "content") {
// uploadMode "content" requires a content token to work. So ensure it is
// set. Ignore fallback "Upload as URL" mode as well
if (
(cfg.value.alwaysUploadAsContent || post.uploadMode === "content")
&& post.name !== "[fallback] Upload as URL"
) {
await ensurePostHasContentToken(post);
}
Expand Down Expand Up @@ -257,7 +261,10 @@ async function ensurePostHasContentToken(post: ScrapedPostDetails) {
}
try {
let tmpRes = await selectedInstance.uploadTempFile(post.contentUrl, post.uploadMode);
const uploadMode =
cfg.value.alwaysUploadAsContent && post.name !== "[fallback] Upload as URL" ?
'content' : post.uploadMode;
let tmpRes = await selectedInstance.uploadTempFile(post.contentUrl, uploadMode);
// Save contentToken in PostViewModel so that we can reuse it when creating/uploading the post.
instanceSpecificData.contentToken = tmpRes.token;
} catch (ex) {
Expand Down Expand Up @@ -403,7 +410,7 @@ useDark();
<template>
<div class="popup-messages">
<div class="messages">
<!--
<!--
Error messages
-->

Expand Down
1 change: 1 addition & 0 deletions src/stores/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export const cfg = useStorageLocal(
{
version: 0,
addPageUrlToSource: true,
alwaysUploadAsContent: false,
autoSearchSimilar: false,
loadTagCounts: true,
fetchPostInfo: true,
Expand Down

0 comments on commit 9e07ee1

Please sign in to comment.