mirror of
https://github.com/koloml/philomena-tagging-assistant.git
synced 2026-05-09 15:12:21 +00:00
Refactoring how preferences classes provide access to fields inside
Instead of constantly implementing these weird methods to read or update values, there will be fields inside the preferences which contain methods to read or update them.
This commit is contained in:
@@ -24,7 +24,7 @@ Promise.allSettled([
|
||||
TaggingProfile.readAll().then(profiles => {
|
||||
taggingProfiles.set(profiles);
|
||||
}),
|
||||
preferences.resolveActiveProfileId().then(activeProfileId => {
|
||||
preferences.activeProfile.get().then(activeProfileId => {
|
||||
activeTaggingProfile.set(activeProfileId);
|
||||
})
|
||||
]).then(() => {
|
||||
@@ -40,7 +40,7 @@ Promise.allSettled([
|
||||
activeTaggingProfile.subscribe(profileId => {
|
||||
lastActiveProfileId = profileId;
|
||||
|
||||
void preferences.setActiveProfileId(profileId);
|
||||
void preferences.activeProfile.set(profileId);
|
||||
});
|
||||
|
||||
// Watch the existence of the active profile on every change.
|
||||
|
||||
@@ -6,10 +6,10 @@ export const fullScreenViewerEnabled = writable(true);
|
||||
const preferences = new MiscPreferences();
|
||||
|
||||
Promise.allSettled([
|
||||
preferences.resolveFullscreenViewerEnabled().then(v => fullScreenViewerEnabled.set(v))
|
||||
preferences.fullscreenViewer.get().then(v => fullScreenViewerEnabled.set(v))
|
||||
]).then(() => {
|
||||
fullScreenViewerEnabled.subscribe(value => {
|
||||
void preferences.setFullscreenViewerEnabled(value);
|
||||
void preferences.fullscreenViewer.set(value);
|
||||
});
|
||||
|
||||
preferences.subscribe(settings => {
|
||||
|
||||
@@ -7,12 +7,12 @@ const preferences = new TaggingProfilesPreferences();
|
||||
|
||||
Promise
|
||||
.all([
|
||||
preferences.resolveStripBlacklistedTags().then(v => stripBlacklistedTagsEnabled.set(v ?? true))
|
||||
preferences.stripBlacklistedTags.get().then(v => stripBlacklistedTagsEnabled.set(v ?? true))
|
||||
])
|
||||
.then(() => {
|
||||
preferences.subscribe(settings => {
|
||||
stripBlacklistedTagsEnabled.set(typeof settings.stripBlacklistedTags === 'boolean' ? settings.stripBlacklistedTags : true);
|
||||
});
|
||||
|
||||
stripBlacklistedTagsEnabled.subscribe(v => preferences.setStripBlacklistedTags(v));
|
||||
stripBlacklistedTagsEnabled.subscribe(v => preferences.stripBlacklistedTags.set(v));
|
||||
});
|
||||
|
||||
@@ -9,21 +9,21 @@ export const shouldReplaceTextOfTagLinks = writable(true);
|
||||
|
||||
Promise
|
||||
.allSettled([
|
||||
preferences.resolveGroupSeparation().then(value => shouldSeparateTagGroups.set(value)),
|
||||
preferences.resolveReplaceLinks().then(value => shouldReplaceLinksOnForumPosts.set(value)),
|
||||
preferences.resolveReplaceLinkText().then(value => shouldReplaceTextOfTagLinks.set(value)),
|
||||
preferences.groupSeparation.get().then(value => shouldSeparateTagGroups.set(value)),
|
||||
preferences.replaceLinks.get().then(value => shouldReplaceLinksOnForumPosts.set(value)),
|
||||
preferences.replaceLinkText.get().then(value => shouldReplaceTextOfTagLinks.set(value)),
|
||||
])
|
||||
.then(() => {
|
||||
shouldSeparateTagGroups.subscribe(value => {
|
||||
void preferences.setGroupSeparation(value);
|
||||
void preferences.groupSeparation.set(value);
|
||||
});
|
||||
|
||||
shouldReplaceLinksOnForumPosts.subscribe(value => {
|
||||
void preferences.setReplaceLinks(value);
|
||||
void preferences.replaceLinks.set(value);
|
||||
});
|
||||
|
||||
shouldReplaceTextOfTagLinks.subscribe(value => {
|
||||
void preferences.setReplaceLinkText(value);
|
||||
void preferences.replaceLinkText.set(value);
|
||||
});
|
||||
|
||||
preferences.subscribe(settings => {
|
||||
|
||||
Reference in New Issue
Block a user