Skip to content

Commit

Permalink
Merge pull request #1164 from AleziaKurdis/placesAppPeristentMaturity…
Browse files Browse the repository at this point in the history
…Filter

Places App.: Persisted Maturity Filter and Default value for Newbies.
  • Loading branch information
ksuprynowicz authored Oct 22, 2024
2 parents ff8c4ca + 7979366 commit 7ff372f
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 4 deletions.
16 changes: 14 additions & 2 deletions scripts/system/places/places.html
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,11 @@
if (message.channel === channel && message.action === "CURRENT_LOCATION") {
currentLocation = message.data;
displayCurrentLocation();
}
}
if (message.channel === channel && message.action === "MATURITY_FILTER") {
maturityFilter = message.filter;
displayMaturityFilter();
}
});

var goSignal = {
Expand Down Expand Up @@ -600,8 +604,16 @@
maturityFilter = arrayRemove(maturityFilter, targeted);
}
loadRecordsUpTo = NUMBER_OF_RECORDS_PER_LOAD;

var messageSent = {
"channel": channel,
"action": "SET_MATURITY_FILTER",
"filter": maturityFilter
};
EventBridge.emitWebEvent(JSON.stringify(messageSent));

displayMaturityFilter();
generateContent();
generateContent();
}

function filterSearchField(targeted) {
Expand Down
25 changes: 23 additions & 2 deletions scripts/system/places/places.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
var metaverseServers = [];
var SETTING_METAVERSE_TO_FETCH = "placesAppMetaverseToFetch";
var SETTING_PINNED_METAVERSE = "placesAppPinnedMetaverse";
var SETTING_MATURITY_FILTER = "placesAppMaturityFilter";
var DEFAULT_MATURITY = ["adult", "mature", "teen", "everyone", "unrated"];
var REQUEST_TIMEOUT = 10000; //10 seconds

var httpRequest = null;
Expand Down Expand Up @@ -78,8 +80,8 @@
if (messageObj.action === "READY_FOR_CONTENT" && (n - timestamp) > INTERCALL_DELAY) {
d = new Date();
timestamp = d.getTime();
sendPersistedMaturityFilter();
transmitPortalList();

sendCurrentLocationToUI();

} else if (messageObj.action === "TELEPORT" && (n - timestamp) > INTERCALL_DELAY) {
Expand All @@ -88,17 +90,23 @@

if (messageObj.address.length > 0) {
Window.location = messageObj.address;
}
}

} else if (messageObj.action === "GO_HOME" && (n - timestamp) > INTERCALL_DELAY) {
d = new Date();
timestamp = d.getTime();
if (LocationBookmarks.getHomeLocationAddress()) {
location.handleLookupString(LocationBookmarks.getHomeLocationAddress());
} else {
Window.location = "file:///~/serverless/tutorial.json";
}
} else if (messageObj.action === "GO_BACK" && (n - timestamp) > INTERCALL_DELAY) {
d = new Date();
timestamp = d.getTime();
location.goBack();
} else if (messageObj.action === "GO_FORWARD" && (n - timestamp) > INTERCALL_DELAY) {
d = new Date();
timestamp = d.getTime();
location.goForward();
} else if (messageObj.action === "PIN_META" && (n - timestamp) > INTERCALL_DELAY) {
d = new Date();
Expand All @@ -122,6 +130,10 @@
}
metaverseServers.push(newMs);
savePinnedMetaverseSetting();
} else if (messageObj.action === "SET_MATURITY_FILTER" && (n - timestamp) > INTERCALL_DELAY) {
d = new Date();
timestamp = d.getTime();
Settings.setValue(SETTING_MATURITY_FILTER, messageObj.filter);
}
}
}
Expand Down Expand Up @@ -224,6 +236,15 @@

};

function sendPersistedMaturityFilter() {
var messageSent = {
"channel": channel,
"action": "MATURITY_FILTER",
"filter": Settings.getValue(SETTING_MATURITY_FILTER, DEFAULT_MATURITY)
};
tablet.emitScriptEvent(messageSent);
}

function getFederationData() {
/*
//If federation.json is got from the Metaverse Server (not implemented yet)
Expand Down

0 comments on commit 7ff372f

Please sign in to comment.