Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add configurable list of tags to ignore #58

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 29 additions & 2 deletions src/options/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import TabView from "primevue/tabview";
import TabPanel from "primevue/tabpanel";
import DataTable from "primevue/datatable";
import Column from "primevue/column";
import { SzuruSiteConfig, TagCategoryColor, getDefaultTagCategories } from "~/models";
import { TagDetails, SzuruSiteConfig, TagCategoryColor, getDefaultTagCategories } from "~/models";
import SzurubooruApi from "~/api";

type StatusType = "success" | "error" | "quiet";
Expand Down Expand Up @@ -102,6 +102,14 @@ async function importTagCategoriesFromInstance() {
}
}

function addTagIgnore() {
cfg.value.tagIgnores.push(new TagDetails([""]))
}

function resetTagIgnores() {
cfg.value.tagIgnores.splice(0);
}

// For debugging
const wnd = window as any;
wnd.szc_get_config = () => JSON.parse(JSON.stringify(cfg.value));
Expand Down Expand Up @@ -289,7 +297,26 @@ wnd.szc_set_config_version = (v = 0) => (cfg.value.version = v);

<!-- TODO: Tag category colors -->

<!-- TODO: Tag ignore list -->
<div class="grid">
<DataTable :value="cfg.tagIgnores" table-class="col-12" style="width: 100%">
<Column field="names" :header="'Names'">
<template #body="{ data, field }">
<input type="text" :name="field" v-model="data[field][0]" />
</template>
</Column>

<Column field="remove">
<template #body="{ index }">
<a class="color-primary cursor-pointer" @click="() => cfg.tagIgnores.splice(index, 1)">Remove</a>
</template>
</Column>
</DataTable>

<div class="col-12 flex flex-wrap grid grid-nogutter gap-1">
<button class="primary" @click="addTagIgnore">Add tag</button>
<button class="bg-danger sm:ml-auto" @click="resetTagIgnores">Clear</button>
</div>
</div>

<!-- TODO: Category ignore list -->
</TabPanel>
Expand Down
6 changes: 6 additions & 0 deletions src/popup/pages/PopupMain.vue
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,12 @@ async function grabPost() {
vm.instanceSpecificData[site.id] = {};
}

// Remove ignored tags
// The complexity for this is quite bad but all the other ways I tried were even worse
vm.tags = vm.tags.filter(tag => cfg.value.tagIgnores.every(
ignoredTag => tag.name != ignoredTag.names[0] // no getters after deserializing
));

pop.posts.push(vm);
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/stores/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { defineStore } from "pinia";
import deepMerge from "deepmerge";
import {
type TagDetails,
getDefaultTagCategories,
type ScrapedPostDetails,
type SetPostUploadInfoData,
Expand Down Expand Up @@ -38,6 +39,7 @@ export const cfg = useStorageLocal(
showInstancePicker: true,
},
tagCategories: [] as Array<TagCategoryColor>,
tagIgnores: [] as Array<TagDetails>,
},
{
mergeDefaults(storageValue, defaults) {
Expand Down