From 3fbcf5b6ef8ae5ba74709c9dac27585e3caacf6f Mon Sep 17 00:00:00 2001 From: pa Date: Wed, 18 Mar 2026 21:20:19 +0900 Subject: [PATCH] add "Add age-restricted instance display logic to Location component" (#1629) --- src/components/Location.vue | 58 ++++++++++++++--------- src/components/__tests__/Location.test.js | 37 ++++++++++++++- src/localization/en.json | 2 + 3 files changed, 73 insertions(+), 24 deletions(-) diff --git a/src/components/Location.vue b/src/components/Location.vue index da87d5d5..330d0795 100644 --- a/src/components/Location.vue +++ b/src/components/Location.vue @@ -2,29 +2,39 @@
-
-
- -
- - - {{ text }} - {{ - ` · #${instanceName}` - }} - - ({{ groupName }}) + +
@@ -56,7 +66,7 @@ const { verifyShortName } = useSearchStore(); const { cachedInstances } = useInstanceStore(); const { lastInstanceApplied } = storeToRefs(useInstanceStore()); - const { showInstanceIdInLocation } = storeToRefs(useAppearanceSettingsStore()); + const { showInstanceIdInLocation, isAgeGatedInstancesVisible } = storeToRefs(useAppearanceSettingsStore()); const props = defineProps({ location: String, @@ -86,11 +96,13 @@ const text = ref(''); const region = ref(''); const strict = ref(false); + const ageGate = ref(false); const isTraveling = ref(false); const groupName = ref(''); const isClosed = ref(false); const instanceName = ref(''); + const isAgeRestricted = computed(() => !isAgeGatedInstancesVisible.value && ageGate.value); const isLocationLink = computed(() => props.link && props.location !== 'private' && props.location !== 'offline'); const locationClasses = computed(() => [ 'x-location', @@ -135,6 +147,7 @@ text.value = ''; region.value = ''; strict.value = false; + ageGate.value = false; isTraveling.value = false; groupName.value = ''; isClosed.value = false; @@ -166,6 +179,7 @@ updateGroupName(L, instanceId); updateRegion(L); strict.value = L.strict; + ageGate.value = L.ageGate; } /** diff --git a/src/components/__tests__/Location.test.js b/src/components/__tests__/Location.test.js index 45bf5bc3..b8c1dd3b 100644 --- a/src/components/__tests__/Location.test.js +++ b/src/components/__tests__/Location.test.js @@ -126,7 +126,7 @@ const stubs = { AlertTriangle: { template: '' } }; -function mountLocation(props = {}) { +function mountLocation(props = {}, appearanceOverrides = {}) { return mount(Location, { props, global: { @@ -139,7 +139,9 @@ function mountLocation(props = {}) { World: {}, Search: {}, AppearanceSettings: { - showInstanceIdInLocation: false + showInstanceIdInLocation: false, + isAgeGatedInstancesVisible: false, + ...appearanceOverrides }, Group: {} } @@ -150,6 +152,7 @@ function mountLocation(props = {}) { }); } + describe('Location.vue', () => { beforeEach(() => { vi.clearAllMocks(); @@ -342,4 +345,34 @@ describe('Location.vue', () => { expect(wrapper.text()).toContain('Second Name'); }); }); + + describe('age-restricted display', () => { + test('shows Restricted with lock when ageGate instance and setting is hidden', () => { + const wrapper = mountLocation( + { location: 'wrld_12345:67890~ageGate', hint: 'Test World' }, + { isAgeGatedInstancesVisible: false } + ); + expect(wrapper.text()).toContain('Restricted'); + expect(wrapper.find('.lucide-lock').exists()).toBe(true); + expect(wrapper.text()).not.toContain('Test World'); + }); + + test('shows normal location when ageGate instance and setting is visible', () => { + const wrapper = mountLocation( + { location: 'wrld_12345:67890~ageGate', hint: 'Test World' }, + { isAgeGatedInstancesVisible: true } + ); + expect(wrapper.text()).toContain('Test World'); + expect(wrapper.text()).not.toContain('Restricted'); + }); + + test('shows normal location for non-ageGate instance even when setting is hidden', () => { + const wrapper = mountLocation( + { location: 'wrld_12345:67890', hint: 'Normal World' }, + { isAgeGatedInstancesVisible: false } + ); + expect(wrapper.text()).toContain('Normal World'); + expect(wrapper.text()).not.toContain('Restricted'); + }); + }); }); diff --git a/src/localization/en.json b/src/localization/en.json index 601e9fcb..a8920e27 100644 --- a/src/localization/en.json +++ b/src/localization/en.json @@ -1342,6 +1342,8 @@ "vrcplus_hides_avatar": "When a VRC+ profile photo is set, avatar info is hidden. This also hides avatar changes in the feed", "instance_full": "full", "instance_closed": "Instance closed", + "instance_age_restricted": "Restricted", + "instance_age_restricted_tooltip": "In an age-restricted instance", "close_instance": "Close Instance", "instance_age_gated": "Age Gated", "open_previous_instance": "Open Previous Instances",