Giter Site home page Giter Site logo

Comments (6)

uris-tools avatar uris-tools commented on August 23, 2024 1

Hi @dannysummerlin and all,

I believe I have a fix for this issue. Can't add a PR as I'm not a collaborator, but hopefully this will help:

As I understand it, due to race condition, the new createSObjectCommands() function that runs in the background, sometimes has no access to forceNavigator.serverUrl (as this value is set in the contentScript).

To fix it, I passed the value of serverUrl in the "getMetaData" message, in a similar way apiUrl and other values are passed.
The result is that the error is not happening anymore.

The changes are:
background.js:

const parseMetadata = (data, url, settings, serverUrl = {})=>{                               <----------
	if (data.length == 0 || typeof data.sobjects == "undefined") return false
	let mapKeys = Object.keys(forceNavigator.objectSetupLabelsMap)
	return data.sobjects.reduce((commands, sObjectData) => forceNavigator.createSObjectCommands(commands, sObjectData, serverUrl), {})
}

shared.js:

	"createSObjectCommands": (commands, sObjectData, serverUrl) => {             <----------
		const { labelPlural, label, name, keyPrefix } = sObjectData
		const mapKeys = Object.keys(forceNavigator.objectSetupLabelsMap)
		if (!keyPrefix || forceNavigatorSettings.skipObjects.includes(keyPrefix)) { return commands }
		let baseUrl = ""
		if (forceNavigatorSettings.lightningMode && name.endsWith("__mdt")) { baseUrl += "/lightning/setup/CustomMetadata/page?address=" }
		commands[keyPrefix + ".list"] = {
			"key": keyPrefix + ".list",
			"url": `${baseUrl}/${keyPrefix}`,
			"label": t("prefix.list") + " " + labelPlural
		}
		commands[keyPrefix + ".new"] = {
			"key": keyPrefix + ".new",
			"url": `${baseUrl}/${keyPrefix}/e`,
			"label": t("prefix.new") + " " + label
		}
		if(forceNavigatorSettings.lightningMode) {
			let targetUrl = serverUrl + "/lightning/setup/ObjectManager/" + name                 <----------
			mapKeys.forEach(key=>{
				commands[keyPrefix + "." + key] = {
					"key": keyPrefix + "." + key,
					"url": targetUrl + forceNavigator.objectSetupLabelsMap[key],
					"label": [t("prefix.setup"), label, t(key)].join(" > ")
				}
			})
		} else {
			// TODO maybe figure out how to get the url for Classic
			commands[t("prefix.setup") + label] = { "url": keyPrefix, "key": key}
		}
		return commands
	"loadCommands": (settings, force = false) => {
		if(!forceNavigator.serverInstance || (!forceNavigatorSettings.sessionIdDisabled && [forceNavigator.sessionId, forceNavigator.organizationId].includes(null))) {
			return forceNavigator.init()
		}
		if(force || Object.keys(forceNavigator.commands).length === 0)
			forceNavigator.resetCommands()
		if(!forceNavigatorSettings.sessionIdDisabled) {
			let options = {
				"sessionHash": forceNavigator.sessionHash,
				"domain": forceNavigator.serverInstance,
				"apiUrl": forceNavigator.apiUrl,
				"key": forceNavigator.organizationId,
				"force": force,
				"sessionId": forceNavigator.sessionId,
				"serverUrl" : forceNavigator.serverUrl,                               <----------
				"action": "getMetadata"
			}

-Uri

from force-navigator.

dannysummerlin avatar dannysummerlin commented on August 23, 2024 1

@uris-tools thanks for taking a look! I'm out and about today, but in the mean time you can fork the repo, make your edit, and then do a pull request, that will help keep track and highlight the exact changes even better - you only need to be a collaborator to give approval on a PR, but anyone can make one!

from force-navigator.

benji1304 avatar benji1304 commented on August 23, 2024

I'm getting the same

from force-navigator.

sap995 avatar sap995 commented on August 23, 2024

Also getting the same. Not sure if it was from the extension update, or my org moving to winter 24 as they both happened on the same date.

from force-navigator.

CamilleGuillory avatar CamilleGuillory commented on August 23, 2024

Same here

from force-navigator.

dyncan avatar dyncan commented on August 23, 2024

Encountered the same error.

from force-navigator.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.