MCPcopy Create free account
hub / github.com/Semporia/Scripts / pickUserComponents

Function pickUserComponents

jd_factory_component.js:161–196  ·  view source on GitHub ↗
(pin, isMe)

Source from the content-addressed store, hash-verified

159}
160
161function pickUserComponents(pin, isMe) {
162 return new Promise(async resolve => {
163 $.get(taskUrl('usermaterial/GetUserComponent', `pin=${pin}`, '_time,pin,zone'), async (err, resp, data) => {
164 try {
165 const { msg, data: { componentList = [] } = {} } = JSON.parse(data);
166 $.log(`\n获取${isMe ? '自己' : '好友'}零件:${msg}\n${$.showLog ? data : ''}`);
167 if (componentList.length > 0) {
168 let statusArr = [];
169 for (let i = 0; i < componentList.length; i++) {
170 const { placeId } = componentList[i];
171 let status = [false];
172 if (!status[0]) {
173 await $.wait(2000);
174 status[0] = await pickUpComponent(placeId, pin, isMe);
175 statusArr.push(status[0]);
176 }
177 if (status[0]) {
178 break;
179 }
180 }
181 if (statusArr[statusArr.length - 1]) {
182 resolve(true);
183 } else {
184 resolve(false);
185 }
186 } else if (isMe) {
187 resolve(true);
188 }
189 } catch (e) {
190 $.logErr(e, resp);
191 } finally {
192 resolve();
193 }
194 });
195 });
196}
197
198function pickUpComponent(placeId, pin, isMe) {
199 return new Promise(async resolve => {

Callers 2

getMyComponentFunction · 0.85
getFriendsFunction · 0.85

Calls 6

pickUpComponentFunction · 0.85
taskUrlFunction · 0.70
getMethod · 0.45
logMethod · 0.45
waitMethod · 0.45
logErrMethod · 0.45

Tested by

no test coverage detected