fix editor mounted

pull/4791/head
filip mertens 5 months ago
parent e8b6a2fe92
commit c1435c41cd
  1. 4
      libs/remix-ui/editor/src/lib/remix-ui-editor.tsx
  2. 1
      libs/remix-ui/git/src/components/branchHeader.tsx
  3. 6
      libs/remix-ui/git/src/components/gitui.tsx
  4. 38
      libs/remix-ui/git/src/lib/gitactions.ts
  5. 10
      libs/remix-ui/git/src/lib/listeners.ts
  6. 2
      libs/remix-ui/git/src/state/gitpayload.ts
  7. 1
      libs/remix-ui/workspace/src/lib/actions/index.ts

@ -561,6 +561,7 @@ export const EditorUI = (props: EditorUIProps) => {
props.editorAPI.getValue = (uri: string) => { props.editorAPI.getValue = (uri: string) => {
if (!editorRef.current) return if (!editorRef.current) return
const model = editorModelsState[uri]?.model const model = editorModelsState[uri]?.model
if (model) { if (model) {
return model.getValue() return model.getValue()
@ -645,12 +646,11 @@ export const EditorUI = (props: EditorUIProps) => {
function handleDiffEditorDidMount(editor: any) { function handleDiffEditorDidMount(editor: any) {
console.log('diff editor mounted') console.log('diff editor mounted')
diffEditorRef.current = editor diffEditorRef.current = editor
defineAndSetTheme(monacoRef.current)
setReducerListener() setReducerListener()
props.events.onEditorMounted()
} }
function handleEditorDidMount(editor) { function handleEditorDidMount(editor) {
console.log('editor mounted')
editorRef.current = editor editorRef.current = editor
defineAndSetTheme(monacoRef.current) defineAndSetTheme(monacoRef.current)
setReducerListener() setReducerListener()

@ -9,7 +9,6 @@ export const BranchHeader = () => {
useEffect(() => { useEffect(() => {
if (context.currentBranch) { if (context.currentBranch) {
console.log('GET BRANCH COMMITS', context.currentBranch)
actions.getBranchDifferences(context.currentBranch, null, context) actions.getBranchDifferences(context.currentBranch, null, context)
} }
}, [context.currentBranch, context.commits, context.branches, context.remotes]) }, [context.currentBranch, context.commits, context.branches, context.remotes])

@ -66,7 +66,7 @@ export const GitUI = (props: IGitUi) => {
setCallBacks(plugin, gitDispatch, loaderDispatch) setCallBacks(plugin, gitDispatch, loaderDispatch)
setPlugin(plugin, gitDispatch, loaderDispatch) setPlugin(plugin, gitDispatch, loaderDispatch)
loaderDispatch({ type: 'plugin', payload: true }) loaderDispatch({ type: 'plugin', payload: true })
console.log(props) //console.log(props)
}, [appLoaded]) }, [appLoaded])
useEffect(() => { useEffect(() => {
@ -76,7 +76,7 @@ export const GitUI = (props: IGitUi) => {
const username = await plugin.call('settings', 'get', 'settings/github-user-name') const username = await plugin.call('settings', 'get', 'settings/github-user-name')
const email = await plugin.call('settings', 'get', 'settings/github-email') const email = await plugin.call('settings', 'get', 'settings/github-email')
const token = await plugin.call('settings', 'get', 'settings/gist-access-token') const token = await plugin.call('settings', 'get', 'settings/gist-access-token')
console.log('gitState', gitState, username, email, token) //console.log('gitState', gitState, username, email, token)
setSetup(!(username && email)) setSetup(!(username && email))
} }
checkconfig() checkconfig()
@ -99,7 +99,7 @@ export const GitUI = (props: IGitUi) => {
useEffect(() => { useEffect(() => {
if (!appLoaded) return if (!appLoaded) return
async function updatestate() { async function updatestate() {
console.log('updatestate', gitState)
if (gitState.currentBranch && gitState.currentBranch.remote && gitState.currentBranch.remote.url) { if (gitState.currentBranch && gitState.currentBranch.remote && gitState.currentBranch.remote.url) {
remoteCommits(gitState.currentBranch.remote.url, gitState.currentBranch.name, 1) remoteCommits(gitState.currentBranch.remote.url, gitState.currentBranch.name, 1)
} }

@ -42,26 +42,25 @@ let plugin: Plugin<any, CustomRemixApi>, dispatch: React.Dispatch<gitActionDispa
export const setPlugin = (p: Plugin, dispatcher: React.Dispatch<gitActionDispatch>) => { export const setPlugin = (p: Plugin, dispatcher: React.Dispatch<gitActionDispatch>) => {
plugin = p plugin = p
dispatch = dispatcher dispatch = dispatcher
console.log('setPlugin')
} }
export const init = async () => { export const init = async () => {
console.log('gitInit')
await plugin.call('dgitApi', "init"); await plugin.call('dgitApi', "init");
await gitlog(); await gitlog();
await getBranches(); await getBranches();
} }
export const getBranches = async () => { export const getBranches = async () => {
console.log('getBranches')
const branches = await plugin.call('dgitApi', "branches") const branches = await plugin.call('dgitApi', "branches")
console.log('branches :>>', branches)
dispatch(setBranches(branches)); dispatch(setBranches(branches));
} }
export const getRemotes = async () => { export const getRemotes = async () => {
console.log('getRemotes')
const remotes: remote[] = await plugin.call('dgitApi', "remotes"); const remotes: remote[] = await plugin.call('dgitApi', "remotes");
console.log('remotes :>>', remotes)
dispatch(setRemotes(remotes)); dispatch(setRemotes(remotes));
} }
@ -89,8 +88,7 @@ export const getFileStatusMatrix = async (filepaths: string[]) => {
} }
export const getCommits = async () => { export const getCommits = async () => {
//Utils.log("get commits");
console.log('getCommits')
try { try {
const commits: ReadCommitResult[] = await plugin.call( const commits: ReadCommitResult[] = await plugin.call(
'dgitApi', 'dgitApi',
@ -117,7 +115,7 @@ export const gitlog = async () => {
export const showCurrentBranch = async () => { export const showCurrentBranch = async () => {
try { try {
const branch = await currentBranch(); const branch = await currentBranch();
console.log('branch :>>', branch)
dispatch(setCanCommit((branch && branch.name !== ""))); dispatch(setCanCommit((branch && branch.name !== "")));
dispatch(setCurrentBranch(branch)); dispatch(setCurrentBranch(branch));
@ -279,7 +277,7 @@ export const checkoutfile = async (filename: string) => {
} }
export const checkout = async (cmd: checkoutInput) => { export const checkout = async (cmd: checkoutInput) => {
console.log(cmd)
await disableCallBacks(); await disableCallBacks();
await plugin.call('fileManager', 'closeAllFiles') await plugin.call('fileManager', 'closeAllFiles')
try { try {
@ -492,7 +490,7 @@ export const remoteBranches = async (owner: string, repo: string) => {
export const remoteCommits = async (url: string, branch: string, length: number) => { export const remoteCommits = async (url: string, branch: string, length: number) => {
const urlParts = url.split("/"); const urlParts = url.split("/");
console.log(urlParts, 'urlParts')
// check if it's github // check if it's github
if (!urlParts[urlParts.length - 3].includes('github')) { if (!urlParts[urlParts.length - 3].includes('github')) {
return return
@ -504,9 +502,9 @@ export const remoteCommits = async (url: string, branch: string, length: number)
try { try {
const token = await tokenWarning(); const token = await tokenWarning();
if (token) { if (token) {
console.log(token, owner, repo, branch, length)
const commits = await plugin.call('dgitApi' as any, 'remotecommits', { token, owner, repo, branch, length }); const commits = await plugin.call('dgitApi' as any, 'remotecommits', { token, owner, repo, branch, length });
console.log(commits, 'remote commits')
} else { } else {
sendToGitLog({ sendToGitLog({
type: 'error', type: 'error',
@ -523,7 +521,7 @@ export const remoteCommits = async (url: string, branch: string, length: number)
} }
export const saveGitHubCredentials = async (credentials: { username: string, email: string, token: string }) => { export const saveGitHubCredentials = async (credentials: { username: string, email: string, token: string }) => {
console.log('saveGitHubCredentials', credentials)
try { try {
const storedEmail = await plugin.call('config', 'getAppParameter', 'settings/github-email') const storedEmail = await plugin.call('config', 'getAppParameter', 'settings/github-email')
const storedUsername = await plugin.call('config', 'getAppParameter', 'settings/github-user-name') const storedUsername = await plugin.call('config', 'getAppParameter', 'settings/github-user-name')
@ -566,9 +564,9 @@ export const loadGitHubUserFromToken = async () => {
emails: userEmails emails: userEmails
} = await plugin.call('dgitApi' as any, 'getGitHubUser', { token }); } = await plugin.call('dgitApi' as any, 'getGitHubUser', { token });
console.log('GET USER"', data)
if (data && data.emails && data.user && data.user.login) { if (data && data.emails && data.user && data.user.login) {
console.log('SET USER"', data)
const primaryEmail = data.emails.find(email => email.primary) const primaryEmail = data.emails.find(email => email.primary)
const storedEmail = await plugin.call('config', 'getAppParameter', 'settings/github-email') const storedEmail = await plugin.call('config', 'getAppParameter', 'settings/github-email')
@ -635,7 +633,7 @@ export const diff = async (commitChange: commitChange) => {
}); });
const modifiedContent = Buffer.from(modifiedContentReadBlobResult.blob).toString("utf8"); const modifiedContent = Buffer.from(modifiedContentReadBlobResult.blob).toString("utf8");
console.log(modifiedContent)
commitChange.modified = modifiedContent; commitChange.modified = modifiedContent;
commitChange.readonly = true; commitChange.readonly = true;
} catch (e) { } catch (e) {
@ -650,7 +648,7 @@ export const diff = async (commitChange: commitChange) => {
}); });
const originalContent = Buffer.from(originalContentReadBlobResult.blob).toString("utf8"); const originalContent = Buffer.from(originalContentReadBlobResult.blob).toString("utf8");
console.log(originalContent)
commitChange.original = originalContent; commitChange.original = originalContent;
} catch (e) { } catch (e) {
commitChange.original = ""; commitChange.original = "";
@ -668,14 +666,14 @@ export const getCommitChanges = async (oid1: string, oid2: string, branch?: bran
log = await plugin.call('dgitApi', 'log', { log = await plugin.call('dgitApi', 'log', {
ref: branch ? branch.name : 'HEAD', ref: branch ? branch.name : 'HEAD',
}) })
console.log(log, 'log')
} catch (e) { } catch (e) {
console.log(e, 'log error') console.log(e, 'log error')
} }
if (log) { if (log) {
const foundCommit = log.find((commit: ReadCommitResult) => commit.oid === oid2) const foundCommit = log.find((commit: ReadCommitResult) => commit.oid === oid2)
if (!foundCommit && remote) { if (!foundCommit && remote) {
console.log('getCommitChanges fetching remote')
//await fetch(remote ? remote.name : null, branch ? branch.name : null, null, 5, true, true) //await fetch(remote ? remote.name : null, branch ? branch.name : null, null, 5, true, true)
await fetch({ await fetch({
remote: remote, remote: remote,

@ -43,7 +43,7 @@ export const setCallBacks = (viewPlugin: Plugin, gitDispatcher: React.Dispatch<g
setPlugin(viewPlugin, gitDispatcher) setPlugin(viewPlugin, gitDispatcher)
plugin.on("fileManager", "fileSaved", async (file: string) => { plugin.on("fileManager", "fileSaved", async (file: string) => {
console.log(file) //console.log(file)
loadFileQueue.enqueue(async () => { loadFileQueue.enqueue(async () => {
loadFiles() loadFiles()
}) })
@ -67,7 +67,7 @@ export const setCallBacks = (viewPlugin: Plugin, gitDispatcher: React.Dispatch<g
}); });
plugin.on("fileManager", "currentFileChanged", async (e) => { plugin.on("fileManager", "currentFileChanged", async (e) => {
console.log('current file change', e) //console.log('current file change', e)
//await synTimerStart(); //await synTimerStart();
}); });
@ -148,11 +148,11 @@ export const setCallBacks = (viewPlugin: Plugin, gitDispatcher: React.Dispatch<g
}) })
plugin.on('config', 'configChanged', async () => { plugin.on('config', 'configChanged', async () => {
console.log('config changed') //console.log('config changed')
await getGitConfig() await getGitConfig()
}) })
plugin.on('settings', 'configChanged', async () => { plugin.on('settings', 'configChanged', async () => {
console.log('settings changed') //console.log('settings changed')
await getGitConfig() await getGitConfig()
}) })
@ -173,7 +173,7 @@ export const getGitConfig = async () => {
export const loadFiles = async (filepaths: string[] = null) => { export const loadFiles = async (filepaths: string[] = null) => {
try { try {
const branch = await plugin.call('dgitApi', "currentbranch") const branch = await plugin.call('dgitApi', "currentbranch")
console.log('load files', branch) //console.log('load files', branch)
if (branch) { if (branch) {
await getFileStatusMatrix(filepaths); await getFileStatusMatrix(filepaths);
} else { } else {

@ -45,7 +45,7 @@ export const setRemoteBranches = (branches: any[]) => {
} }
export const setGitHubUser = (user: GitHubUser) => { export const setGitHubUser = (user: GitHubUser) => {
console.log('set user', user)
return { return {
type: 'SET_GITHUB_USER', type: 'SET_GITHUB_USER',
payload: user payload: user

@ -60,6 +60,7 @@ export const initWorkspace = (filePanelPlugin) => async (reducerDispatch: React.
let filePathToOpen = null let filePathToOpen = null
let workspaces = [] let workspaces = []
plugin.on('editor', 'editorMounted', async () => { plugin.on('editor', 'editorMounted', async () => {
console.log('editor mounted')
editorMounted = true editorMounted = true
if (filePathToOpen){ if (filePathToOpen){
setTimeout(async () => { setTimeout(async () => {

Loading…
Cancel
Save