@lvce-editor/activity-bar-worker 5.7.0 → 6.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1118,7 +1118,6 @@ const create$2 = rpcId => {
1118
1118
  };
1119
1119
 
1120
1120
  const {
1121
- invoke: invoke$1,
1122
1121
  set: set$2
1123
1122
  } = create$2(6010);
1124
1123
 
@@ -1320,7 +1319,7 @@ const {
1320
1319
  // TODO parentUid might ot be needed
1321
1320
  const create = (id, uri, x, y, width, height, args, parentUid, platform = 0) => {
1322
1321
  const state = {
1323
- accountEnabled: false,
1322
+ accountEnabled: true,
1324
1323
  activityBarItems: [],
1325
1324
  currentViewletId: '',
1326
1325
  filteredItems: [],
@@ -1454,20 +1453,23 @@ const getKeyBindings = () => {
1454
1453
  }];
1455
1454
  };
1456
1455
 
1457
- const getMenuEntriesAccount = state => {
1456
+ const getMenuEntriesAccountLoggedIn = state => {
1458
1457
  const {
1459
1458
  userLoginState
1460
1459
  } = state;
1461
- const signInLabel = userLoginState === 'logging in' ? 'Signing In...' : 'Sign In';
1462
1460
  const signOutLabel = userLoginState === 'logging out' ? 'Signing Out...' : 'Sign Out';
1463
- if (userLoginState === 'logged in' || userLoginState === 'logging out') {
1464
- return [{
1465
- command: 'ActivityBar.handleClickSignOut',
1466
- flags: None,
1467
- id: 'signOut',
1468
- label: signOutLabel
1469
- }];
1470
- }
1461
+ return [{
1462
+ command: 'ActivityBar.handleClickSignOut',
1463
+ flags: None,
1464
+ id: 'signOut',
1465
+ label: signOutLabel
1466
+ }];
1467
+ };
1468
+ const getMenuEntriesAccountLoggedOut = state => {
1469
+ const {
1470
+ userLoginState
1471
+ } = state;
1472
+ const signInLabel = userLoginState === 'logging in' ? 'Signing In...' : 'Sign In';
1471
1473
  return [{
1472
1474
  command: 'ActivityBar.handleClickSignIn',
1473
1475
  flags: None,
@@ -1475,6 +1477,16 @@ const getMenuEntriesAccount = state => {
1475
1477
  label: signInLabel
1476
1478
  }];
1477
1479
  };
1480
+ const getMenuEntriesAccount = state => {
1481
+ // TODO maybe query it now from layout?
1482
+ const {
1483
+ userLoginState
1484
+ } = state;
1485
+ if (userLoginState === 'logged in' || userLoginState === 'logging out') {
1486
+ return getMenuEntriesAccountLoggedIn(state);
1487
+ }
1488
+ return getMenuEntriesAccountLoggedOut(state);
1489
+ };
1478
1490
 
1479
1491
  const Tab = 1;
1480
1492
  const Button = 1 << 1;
@@ -1970,18 +1982,12 @@ const handleClick = async (state, button, eventX, eventY) => {
1970
1982
  };
1971
1983
 
1972
1984
  const handleClickSignIn = async state => {
1973
- const {
1974
- platform
1975
- } = state;
1976
- const backendUrl = await invoke('Layout.getBackendUrl');
1977
- await invoke$1('Auth.login', {
1978
- backendUrl,
1979
- platform
1980
- });
1985
+ await invoke('Layout.signIn');
1981
1986
  return state;
1982
1987
  };
1983
1988
 
1984
1989
  const handleClickSignOut = async state => {
1990
+ await invoke('Layout.signOut');
1985
1991
  return state;
1986
1992
  };
1987
1993
 
@@ -2221,16 +2227,48 @@ const getActiveView = async () => {
2221
2227
  }
2222
2228
  };
2223
2229
 
2230
+ const getUserInfo = async () => {
2231
+ try {
2232
+ return await invoke('Layout.getUserInfo');
2233
+ } catch {
2234
+ return undefined;
2235
+ }
2236
+ };
2237
+
2238
+ const getUserState = userInfo => {
2239
+ if (!userInfo || typeof userInfo !== 'object') {
2240
+ return undefined;
2241
+ }
2242
+ if (!('userState' in userInfo)) {
2243
+ return undefined;
2244
+ }
2245
+ return userInfo.userState;
2246
+ };
2247
+
2248
+ const toUserLoginState = userState => {
2249
+ switch (userState) {
2250
+ case 'loggedIn':
2251
+ return 'logged in';
2252
+ case 'loggingIn':
2253
+ return 'logging in';
2254
+ case 'loggingOut':
2255
+ return 'logging out';
2256
+ default:
2257
+ return 'logged out';
2258
+ }
2259
+ };
2260
+
2224
2261
  const loadContent = async state => {
2225
2262
  const {
2226
2263
  accountEnabled,
2227
2264
  height,
2228
2265
  itemHeight
2229
2266
  } = state;
2230
- const [accountEnabledNew, activeView, sideBarVisible, sidebarLocation] = await Promise.all([getAccountEnabled(accountEnabled), getActiveView(), getSideBarVisible(), getSideBarPosition()]);
2267
+ const [accountEnabledNew, activeView, sideBarVisible, sidebarLocation, userInfo] = await Promise.all([getAccountEnabled(accountEnabled), getActiveView(), getSideBarVisible(), getSideBarPosition(), getUserInfo()]);
2231
2268
  const newState = {
2232
2269
  ...state,
2233
- accountEnabled: accountEnabledNew
2270
+ accountEnabled: accountEnabledNew,
2271
+ userLoginState: toUserLoginState(getUserState(userInfo))
2234
2272
  };
2235
2273
  const items = getActivityBarItems(newState);
2236
2274
  const index = items.findIndex(item => item.id === activeView);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/activity-bar-worker",
3
- "version": "5.7.0",
3
+ "version": "6.1.0",
4
4
  "description": "Explorer Worker",
5
5
  "repository": {
6
6
  "type": "git",