mirror of
https://github.com/koloml/philomena-tagging-assistant.git
synced 2026-06-24 02:32: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:
@@ -17,8 +17,8 @@ export class BlockCommunication extends BaseComponent {
|
||||
|
||||
protected init() {
|
||||
Promise.all([
|
||||
BlockCommunication.#preferences.resolveReplaceLinks(),
|
||||
BlockCommunication.#preferences.resolveReplaceLinkText(),
|
||||
BlockCommunication.#preferences.replaceLinks.get(),
|
||||
BlockCommunication.#preferences.replaceLinkText.get(),
|
||||
]).then(([replaceLinks, replaceLinkText]) => {
|
||||
this.#onReplaceLinkSettingResolved(
|
||||
replaceLinks,
|
||||
|
||||
@@ -54,7 +54,7 @@ export class FullscreenViewer extends BaseComponent {
|
||||
this.#sizeSelectorElement.addEventListener('click', event => event.stopPropagation());
|
||||
|
||||
FullscreenViewer.#preferences
|
||||
.resolveFullscreenViewerPreviewSize()
|
||||
.fullscreenViewerSize.get()
|
||||
.then(this.#onSizeResolved.bind(this))
|
||||
.then(this.#watchForSizeSelectionChanges.bind(this));
|
||||
}
|
||||
@@ -202,7 +202,7 @@ export class FullscreenViewer extends BaseComponent {
|
||||
}
|
||||
|
||||
lastActiveSize = targetSize;
|
||||
void FullscreenViewer.#preferences.setFullscreenViewerPreviewSize(targetSize);
|
||||
void FullscreenViewer.#preferences.fullscreenViewerSize.set(targetSize as FullscreenViewerSize);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ export class ImageShowFullscreenButton extends BaseComponent {
|
||||
this.on('click', this.#onButtonClicked.bind(this));
|
||||
|
||||
if (ImageShowFullscreenButton.#preferences) {
|
||||
ImageShowFullscreenButton.#preferences.resolveFullscreenViewerEnabled()
|
||||
ImageShowFullscreenButton.#preferences.fullscreenViewer.get()
|
||||
.then(isEnabled => {
|
||||
this.#isFullscreenButtonEnabled = isEnabled;
|
||||
this.#updateFullscreenButtonVisibility();
|
||||
|
||||
@@ -214,7 +214,7 @@ export class MaintenancePopup extends BaseComponent {
|
||||
|
||||
let maybeTagsAndAliasesAfterUpdate;
|
||||
|
||||
const shouldAutoRemove = await MaintenancePopup.#preferences.resolveStripBlacklistedTags();
|
||||
const shouldAutoRemove = await MaintenancePopup.#preferences.stripBlacklistedTags.get();
|
||||
|
||||
try {
|
||||
maybeTagsAndAliasesAfterUpdate = await MaintenancePopup.#scrapedAPI.updateImageTags(
|
||||
@@ -359,13 +359,11 @@ export class MaintenancePopup extends BaseComponent {
|
||||
|
||||
lastActiveProfileId = settings.activeProfile;
|
||||
|
||||
this.#preferences
|
||||
.resolveActiveProfileAsObject()
|
||||
this.#preferences.activeProfile.asObject()
|
||||
.then(callback);
|
||||
});
|
||||
|
||||
this.#preferences
|
||||
.resolveActiveProfileAsObject()
|
||||
this.#preferences.activeProfile.asObject()
|
||||
.then(profileOrNull => {
|
||||
if (profileOrNull) {
|
||||
lastActiveProfileId = profileOrNull.id;
|
||||
|
||||
@@ -179,7 +179,7 @@ export class TagDropdownWrapper extends BaseComponent {
|
||||
});
|
||||
|
||||
await profile.save();
|
||||
await TagDropdownWrapper.#preferences.setActiveProfileId(profile.id);
|
||||
await TagDropdownWrapper.#preferences.activeProfile.set(profile.id);
|
||||
}
|
||||
|
||||
async #onToggleInExistingClicked() {
|
||||
@@ -219,7 +219,7 @@ export class TagDropdownWrapper extends BaseComponent {
|
||||
lastActiveProfile = settings.activeProfile ?? null;
|
||||
|
||||
this.#preferences
|
||||
.resolveActiveProfileAsObject()
|
||||
.activeProfile.asObject()
|
||||
.then(onActiveProfileChange);
|
||||
});
|
||||
|
||||
@@ -232,7 +232,7 @@ export class TagDropdownWrapper extends BaseComponent {
|
||||
});
|
||||
|
||||
this.#preferences
|
||||
.resolveActiveProfileAsObject()
|
||||
.activeProfile.asObject()
|
||||
.then(activeProfile => {
|
||||
lastActiveProfile = activeProfile?.id ?? null;
|
||||
onActiveProfileChange(activeProfile);
|
||||
|
||||
@@ -44,7 +44,7 @@ export class TagsListBlock extends BaseComponent {
|
||||
}
|
||||
|
||||
init() {
|
||||
this.#preferences.resolveGroupSeparation().then(this.#onTagSeparationChange.bind(this));
|
||||
this.#preferences.groupSeparation.get().then(this.#onTagSeparationChange.bind(this));
|
||||
this.#preferences.subscribe(settings => {
|
||||
this.#onTagSeparationChange(Boolean(settings.groupSeparation))
|
||||
});
|
||||
@@ -103,7 +103,7 @@ export class TagsListBlock extends BaseComponent {
|
||||
|
||||
#onToggleGroupingClicked(event: Event) {
|
||||
event.preventDefault();
|
||||
void this.#preferences.setGroupSeparation(!this.#shouldDisplaySeparation);
|
||||
void this.#preferences.groupSeparation.set(!this.#shouldDisplaySeparation);
|
||||
}
|
||||
|
||||
#handleTagGroupChanges(tagGroup: TagGroup) {
|
||||
|
||||
Reference in New Issue
Block a user