1
0
mirror of https://github.com/koloml/philomena-tagging-assistant.git synced 2026-09-22 20:09:39 +00:00

Merge pull request #180 from koloml/feature/store-last-user-flags

Store last seen user flags from Philomena, show warning in profiles list when user is logged off
This commit is contained in:
2026-08-29 21:39:17 -04:00
committed by GitHub
5 changed files with 64 additions and 1 deletions

View File

@@ -28,7 +28,8 @@
"*://*.furbooru.org/*"
],
"js": [
"src/content/deps/amd.ts"
"src/content/deps/amd.ts",
"src/content/user-details.ts"
]
},
{

View File

@@ -0,0 +1,14 @@
import { UserDetails } from "$lib/extension/preferences/UserDetails";
(async () => {
const userDetails = new UserDetails();
const userDataStore = document.querySelector<HTMLElement>('.js-datastore');
if (!userDataStore) {
return;
}
await userDetails.isAuthorized.set(userDataStore.dataset.userIsSignedIn === 'true');
})();

View File

@@ -0,0 +1,16 @@
import CacheablePreferences, { PreferenceField, type WithFields } from "$lib/extension/base/CacheablePreferences";
export interface UserDetailsFields {
isAuthorized: boolean;
}
export class UserDetails extends CacheablePreferences<UserDetailsFields> implements WithFields<UserDetailsFields> {
constructor() {
super('userDetails');
}
isAuthorized = new PreferenceField(this, {
field: 'isAuthorized',
defaultValue: false,
});
}

View File

@@ -5,6 +5,8 @@
import { activeTaggingProfile, taggingProfiles } from "$stores/entities/tagging-profiles";
import TaggingProfile from "$entities/TaggingProfile";
import { popupTitle } from "$stores/popup";
import { user } from "$stores/preferences/user";
import Notice from "$components/ui/Notice.svelte";
$popupTitle = 'Tagging Profiles';
@@ -28,6 +30,18 @@
<Menu>
<MenuItem href="/" icon="arrow-left">Back</MenuItem>
<MenuItem href="/features/profiles/new/edit" icon="plus">Create New</MenuItem>
</Menu>
{#if $user?.isAuthorized === false}
<Menu>
<hr>
</Menu>
<Notice level="warning">
<strong>Tagging profiles will only work when you're signed in!</strong>
<br><br>
Unauthorized users have to solve the captcha before sending any submissions to the site.
</Notice>
{/if}
<Menu>
{#if profiles.length}
<hr>
{/if}

View File

@@ -0,0 +1,18 @@
import { UserDetails, type UserDetailsFields } from "$lib/extension/preferences/UserDetails";
import { readable } from "svelte/store";
const userDetails = new UserDetails();
export const user = readable<UserDetailsFields | null>(null, set => {
userDetails.subscribe(settings => {
set({
isAuthorized: Boolean(settings.isAuthorized)
});
});
userDetails.isAuthorized.get().then(isAuthorized => {
set({
isAuthorized
});
});
});