@symbo.ls/fetch 2.6.14 → 2.6.16

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.
Files changed (2) hide show
  1. package/index.js +28 -13
  2. package/package.json +2 -2
package/index.js CHANGED
@@ -3,6 +3,7 @@
3
3
  import { client, fetch, set } from '@symbo.ls/based'
4
4
  import { deepMerge, isObject } from '@domql/utils'
5
5
  import { setCookie } from '@domql/cookie'
6
+ import { router } from '@domql/router'
6
7
 
7
8
  import TMP_DATA from '@symbo.ls/temp-db'
8
9
  import CONFIG_DEFAULT from '@symbo.ls/config-default'
@@ -43,8 +44,8 @@ export const syncSystem = (data, el, s) => {
43
44
  // set({ $id: s.projectId, state: defObjs.state })
44
45
  }
45
46
 
46
- deepMerge(s.PROJECT_SYSTEM, system)
47
- deepMerge(s.PROJECT_STATE, state)
47
+ // deepMerge(s.PROJECT_SYSTEM, system)
48
+ // deepMerge(s.PROJECT_STATE, state)
48
49
  }
49
50
 
50
51
  export const publishSystem = (data, el, s) => {
@@ -58,8 +59,11 @@ export const publishSystem = (data, el, s) => {
58
59
  export const fetchProject = (el, s, { userName, projectId, ...options }) => {
59
60
  fetch({
60
61
  $id: projectId,
61
- $all: true
62
- }, async data => {
62
+ $all: true,
63
+ icon: {
64
+ src: true
65
+ }
66
+ }, data => {
63
67
  const { key, name, icon } = data
64
68
 
65
69
  setCookie('appKey', key)
@@ -67,8 +71,8 @@ export const fetchProject = (el, s, { userName, projectId, ...options }) => {
67
71
  s.update({
68
72
  appKey: key,
69
73
  projectName: name,
70
- userName,
71
- projectId,
74
+ userName: userName,
75
+ projectId: projectId,
72
76
  icon
73
77
  }, options)
74
78
 
@@ -77,21 +81,32 @@ export const fetchProject = (el, s, { userName, projectId, ...options }) => {
77
81
  }
78
82
 
79
83
  export const fetchUser = (el, s, options) => {
80
- if (!s.projectId) {
81
- fetch({ $id: s.userId, name: true, projects: true }, data => {
84
+ const { userName, projectId } = s
85
+ if (!userName || !projectId) {
86
+ fetch({
87
+ $id: s.userId,
88
+ name: true,
89
+ projects: {
90
+ id: true,
91
+ name: true,
92
+ key: true,
93
+ icon: {
94
+ src: true
95
+ },
96
+ $list: true
97
+ }
98
+ }, data => {
82
99
  const { projects } = data
83
100
  const userName = data.name
84
101
  if (projects) {
85
- s.update({ projects })
86
- const projectId = projects[s.activeProject || 0]
102
+ s.update({ userName, projects })
103
+ const projectId = projects[s.activeProject || 0].id
87
104
  fetchProject(el, s, { userName, projectId, ...options })
88
105
  }
89
106
  })
90
107
  } else {
91
108
  fetchProject(el, s, {
92
- userName: s.userName,
93
- projectId: s.projectId,
94
- ...options
109
+ userName, projectId, ...options
95
110
  })
96
111
  }
97
112
  }
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@symbo.ls/fetch",
3
- "version": "2.6.14",
3
+ "version": "2.6.16",
4
4
  "main": "index.js",
5
5
  "dependencies": {
6
6
  "@symbo.ls/based": "latest",
7
7
  "@symbo.ls/config-default": "latest",
8
8
  "@symbo.ls/temp-db": "latest"
9
9
  },
10
- "gitHead": "366fb9878348671e8ad0653ebd7347cf37b43bb2"
10
+ "gitHead": "db978f0f4db5c1e3e23ff2c8bf12f61464769304"
11
11
  }