mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-10-30 01:12:39 +00:00
[decompose] extract ProfileHashtagController from js/ui/profileModalController.js
Extracts all hashtag preference related logic into a new controller `js/ui/profileModal/ProfileHashtagController.js` to reduce the size of `js/ui/profileModalController.js` and improve maintainability. - Moves `normalizeHashtagTag`, `formatHashtagTag`, `getResolvedHashtagPreferences`, `setHashtagStatus`, `refreshHashtagBackgroundStatus`, `populateHashtagPreferences`, `renderHashtagList`, `sanitizeHashtagList`, `createHashtagListItem`, `persistHashtagPreferences`, `handleAddHashtagPreference`, `handleRemoveHashtagPreference`, `handleHashtagPreferencesChange`, `describeHashtagPreferencesError`. - Updates `ProfileModalController` to delegate to `ProfileHashtagController`. - Adds delegate getters/methods in `ProfileModalController` to maintain backward compatibility for tests. - Reduces `js/ui/profileModalController.js` by ~600 lines. - Updates file size baseline in `scripts/check-file-size.mjs`. Passes `npm run lint` and `npm run test:unit`. Co-authored-by: PR0M3TH3AN <[email protected]>
This commit is contained in:
1 parent
baa0be3742
commit
1b68e3c5f2
3 files changed
+4
-42
No files matched your search
@@ -185,10 +185,10 @@ export class ProfileHashtagController {
|
||||
}
|
||||
|
||||
clearHashtagInputs() {
|
||||
if (this.hashtagInterestInput instanceof HTMLInputElement) {
|
||||
if (this.hashtagInterestInput && typeof this.hashtagInterestInput.value === "string") {
|
||||
this.hashtagInterestInput.value = "";
|
||||
}
|
||||
if (this.hashtagDisinterestInput instanceof HTMLInputElement) {
|
||||
if (this.hashtagDisinterestInput && typeof this.hashtagDisinterestInput.value === "string") {
|
||||
this.hashtagDisinterestInput.value = "";
|
||||
}
|
||||
}
|
||||
@@ -385,10 +385,10 @@ export class ProfileHashtagController {
|
||||
: this.hashtagDisinterestInput;
|
||||
|
||||
const rawValue =
|
||||
input instanceof HTMLInputElement ? input.value || "" : "";
|
||||
input && typeof input.value === "string" ? input.value || "" : "";
|
||||
const normalized = this.normalizeHashtagTag(rawValue);
|
||||
|
||||
if (!(input instanceof HTMLInputElement)) {
|
||||
if (!(input && typeof input.value === "string")) {
|
||||
return { success: false, reason: "missing-input" };
|
||||
}
|
||||
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
class Helper {
|
||||
constructor() {
|
||||
this.prop = null;
|
||||
}
|
||||
}
|
||||
|
||||
class Controller {
|
||||
constructor() {
|
||||
this.helper = new Helper();
|
||||
}
|
||||
get prop() { return this.helper.prop; }
|
||||
}
|
||||
|
||||
const c = new Controller();
|
||||
try {
|
||||
c.prop.value = 'test';
|
||||
} catch (e) {
|
||||
console.log('Error:', e.message);
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
class Helper {
|
||||
constructor() {
|
||||
// prop not defined
|
||||
}
|
||||
}
|
||||
|
||||
class Controller {
|
||||
constructor() {
|
||||
this.helper = new Helper();
|
||||
}
|
||||
get prop() { return this.helper.prop; }
|
||||
}
|
||||
|
||||
const c = new Controller();
|
||||
try {
|
||||
c.prop.value = 'test';
|
||||
} catch (e) {
|
||||
console.log('Error:', e.message);
|
||||
}
|
||||
Reference in new issue
Block a user