Merge pull request #1164 from AleziaKurdis/placesAppPeristentMaturityFilter

Places App.: Persisted Maturity Filter and Default value for Newbies.
This commit is contained in:
ksuprynowicz 2024-10-22 14:15:49 +02:00 committed by GitHub
commit 7ff372fa4c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 37 additions and 4 deletions

View file

@ -150,7 +150,11 @@
if (message.channel === channel && message.action === "CURRENT_LOCATION") { if (message.channel === channel && message.action === "CURRENT_LOCATION") {
currentLocation = message.data; currentLocation = message.data;
displayCurrentLocation(); displayCurrentLocation();
} }
if (message.channel === channel && message.action === "MATURITY_FILTER") {
maturityFilter = message.filter;
displayMaturityFilter();
}
}); });
var goSignal = { var goSignal = {
@ -600,8 +604,16 @@
maturityFilter = arrayRemove(maturityFilter, targeted); maturityFilter = arrayRemove(maturityFilter, targeted);
} }
loadRecordsUpTo = NUMBER_OF_RECORDS_PER_LOAD; loadRecordsUpTo = NUMBER_OF_RECORDS_PER_LOAD;
var messageSent = {
"channel": channel,
"action": "SET_MATURITY_FILTER",
"filter": maturityFilter
};
EventBridge.emitWebEvent(JSON.stringify(messageSent));
displayMaturityFilter(); displayMaturityFilter();
generateContent(); generateContent();
} }
function filterSearchField(targeted) { function filterSearchField(targeted) {

View file

@ -19,6 +19,8 @@
var metaverseServers = []; var metaverseServers = [];
var SETTING_METAVERSE_TO_FETCH = "placesAppMetaverseToFetch"; var SETTING_METAVERSE_TO_FETCH = "placesAppMetaverseToFetch";
var SETTING_PINNED_METAVERSE = "placesAppPinnedMetaverse"; 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 REQUEST_TIMEOUT = 10000; //10 seconds
var httpRequest = null; var httpRequest = null;
@ -78,8 +80,8 @@
if (messageObj.action === "READY_FOR_CONTENT" && (n - timestamp) > INTERCALL_DELAY) { if (messageObj.action === "READY_FOR_CONTENT" && (n - timestamp) > INTERCALL_DELAY) {
d = new Date(); d = new Date();
timestamp = d.getTime(); timestamp = d.getTime();
sendPersistedMaturityFilter();
transmitPortalList(); transmitPortalList();
sendCurrentLocationToUI(); sendCurrentLocationToUI();
} else if (messageObj.action === "TELEPORT" && (n - timestamp) > INTERCALL_DELAY) { } else if (messageObj.action === "TELEPORT" && (n - timestamp) > INTERCALL_DELAY) {
@ -88,17 +90,23 @@
if (messageObj.address.length > 0) { if (messageObj.address.length > 0) {
Window.location = messageObj.address; Window.location = messageObj.address;
} }
} else if (messageObj.action === "GO_HOME" && (n - timestamp) > INTERCALL_DELAY) { } else if (messageObj.action === "GO_HOME" && (n - timestamp) > INTERCALL_DELAY) {
d = new Date();
timestamp = d.getTime();
if (LocationBookmarks.getHomeLocationAddress()) { if (LocationBookmarks.getHomeLocationAddress()) {
location.handleLookupString(LocationBookmarks.getHomeLocationAddress()); location.handleLookupString(LocationBookmarks.getHomeLocationAddress());
} else { } else {
Window.location = "file:///~/serverless/tutorial.json"; Window.location = "file:///~/serverless/tutorial.json";
} }
} else if (messageObj.action === "GO_BACK" && (n - timestamp) > INTERCALL_DELAY) { } else if (messageObj.action === "GO_BACK" && (n - timestamp) > INTERCALL_DELAY) {
d = new Date();
timestamp = d.getTime();
location.goBack(); location.goBack();
} else if (messageObj.action === "GO_FORWARD" && (n - timestamp) > INTERCALL_DELAY) { } else if (messageObj.action === "GO_FORWARD" && (n - timestamp) > INTERCALL_DELAY) {
d = new Date();
timestamp = d.getTime();
location.goForward(); location.goForward();
} else if (messageObj.action === "PIN_META" && (n - timestamp) > INTERCALL_DELAY) { } else if (messageObj.action === "PIN_META" && (n - timestamp) > INTERCALL_DELAY) {
d = new Date(); d = new Date();
@ -122,6 +130,10 @@
} }
metaverseServers.push(newMs); metaverseServers.push(newMs);
savePinnedMetaverseSetting(); 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);
} }
} }
} }
@ -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() { function getFederationData() {
/* /*
//If federation.json is got from the Metaverse Server (not implemented yet) //If federation.json is got from the Metaverse Server (not implemented yet)