MCPcopy
hub / github.com/leonhartX/gas-github / initContext

Function initContext

src/gas-hub.js:77–135  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

75
76
77function initContext() {
78 context = {};
79 const id = getId();
80
81 return new Promise((resolve, reject) => {
82 chrome.storage.sync.get([
83 'scm',
84 'token',
85 'user',
86 'baseUrl',
87 'bindRepo',
88 'bindBranch',
89 'bindType',
90 'bindPattern',
91 'bindConfig',
92 'gapiRefreshToken',
93 'gapiToken'
94 ], (item) => {
95 if (!item.token) {
96 reject(new Error('need login'));
97 } else if (!item.gapiToken) {
98 reject(new Error('need auth'));
99 } else {
100 showLog('Updateing Repository');
101 }
102 gas = new ScriptApi();
103 context.gapiRefreshToken = item.gapiRefreshToken;
104 context.gapiToken = item.gapiToken;
105 scm = createSCM(item);
106 context.bindRepo = item.bindRepo || {};
107 context.bindBranch = item.bindBranch || {};
108 context.bindType = item.bindType || {};
109 context.bindPattern = item.bindPattern || {};
110 context.bindConfig = item.bindConfig || {};
111 resolve(scm);
112 });
113 })
114 .then(scm => {
115 return scm.getNamespaces()
116 .then((owners) => {
117 let first = true;
118 owners.forEach((owner) => {
119 let content = `<li class="repo-owner-option VfPpkd-rymPhb-ibnC6b VfPpkd-rOvkhd-rymPhb-ibnC6b-OWXEXe-tPcied-hXIJHe"
120 role="menuitem" tabindex="-1">
121 <span class="VfPpkd-rymPhb-pZXsl"></span>
122 <span class="VfPpkd-rymPhb-b9t22c">${owner}</span></li>`
123 $('#repo-owner-list').append(content);
124 if (first) {
125 $('#selected-repo-owner').text(owner);
126 first = false;
127 }
128 });
129 return scm;
130 })
131 })
132 .then(scm => {
133 return scm.getRepos();
134 })

Callers

nothing calls this directly

Calls 5

getIdFunction · 0.85
showLogFunction · 0.85
createSCMFunction · 0.85
getNamespacesMethod · 0.45
getReposMethod · 0.45

Tested by

no test coverage detected