Skip to content

Commit

Permalink
fix(codeserver-remote): remote editor session now also tracking code-…
Browse files Browse the repository at this point in the history
…server's version

allow vheditor's managed code-server session to be restarted after upgrading to newer version
  • Loading branch information
vhqtvn committed Feb 9, 2023
1 parent efb1968 commit a3e62d9
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 7 deletions.
12 changes: 10 additions & 2 deletions app/src/main/java/vn/vhn/vhscode/root/EditorHostActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -428,8 +428,10 @@ class EditorHostActivity : FragmentActivity(), ServiceConnection,
codeServerService?.sessionsHost?.createCodeEditorSession(
GlobalSessionsManager.getNextSessionId(GlobalSessionsManager.SessionType.CODESERVER_EDITOR),
"Editor",
listenOnAllInterface = intent.getBooleanExtra(NewSessionActivity.kSessionAllInterfaces,
true),
listenOnAllInterface = intent.getBooleanExtra(
NewSessionActivity.kSessionAllInterfaces,
true
),
useSSL = intent.getBooleanExtra(NewSessionActivity.kSessionSSL, true),
port = preferences.editLocalServerListenPort.toIntOrNull(),
verbose = preferences.editorVerbose,
Expand Down Expand Up @@ -703,19 +705,25 @@ class EditorHostActivity : FragmentActivity(), ServiceConnection,
when (val item = mListViewAdapter.getItem(binding.viewPager.currentItem)) {
is TerminalItem -> {
val (commandId) = item
binding.overlayReloadBtn.visibility = View.GONE
binding.overlayKillBtn.isEnabled =
codeServerService?.sessionsHost?.getTerminalSessionForCommandId(commandId)?.isRunning
?: false
}
is CodeEditorItem -> {
val (sid) = item
binding.overlayReloadBtn.visibility = View.VISIBLE
binding.overlayKillBtn.isEnabled =
codeServerService?.sessionsHost?.getVSCodeSessionForId(sid)?.terminated != true
}
else -> {}
}
}

fun onResetCacheClicked(view: View) {
mCurrentEditorFragment?.resetCache()
}

fun onKillClicked(view: View) {
if (mListViewAdapter.isEmpty) return
when (val item = mListViewAdapter.getItem(binding.viewPager.currentItem)) {
Expand Down
17 changes: 13 additions & 4 deletions app/src/main/java/vn/vhn/vhscode/root/fragments/VSCodeFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -541,10 +541,10 @@ class VSCodeFragment : Fragment() {
setLogVisible(false)
return true
}
if (binding.webView.canGoBack()) {
binding.webView.goBack()
return true
}
// if (binding.webView.canGoBack()) {
// binding.webView.goBack()
// return true
// }
return false
}

Expand All @@ -560,4 +560,13 @@ class VSCodeFragment : Fragment() {
fun onPageStarted(view: WebView?, url: String?, favicon: Bitmap?) {
binding.loading.visibility = View.VISIBLE
}

fun resetCache() {
_binding?.also {
it.webView.post {
it.webView.clearCache(true)
it.webView.reload()
}
}
}
}
13 changes: 13 additions & 0 deletions app/src/main/res/layout/activity_editor_host.xml
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,19 @@
android:orientation="horizontal"
android:paddingEnd="20dp">

<Button
android:id="@+id/overlay_reload_btn"
style="?android:attr/borderlessButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:background="@drawable/transparent_button_bg"
android:fontFamily="@font/fa_solid_900"
android:onClick="onResetCacheClicked"
android:text="&#xf51a; Clear cache"
android:textColor="@color/red_error" />

<Button
android:id="@+id/overlay_kill_btn"
style="?android:attr/borderlessButtonStyle"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/raw/boot_remote.sh
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ SUDO
fi

[[ "$1" == "--" ]] && shift
ARGS_HASH=$(echo "$@" | md5sum | awk '{print $1}')
ARGS_HASH=$(echo "$@" "@@current-cs-version:::$CURRENT_CS_VER" | md5sum | awk '{print $1}')

NODE=$(NODE_OPTIONS='-v' $CODESERVER 2>&1 | awk -F: '{print $1}')
CURRENT_SESSION_FILE="$VHEDITOR_STORAGE/current-session"
Expand Down

0 comments on commit a3e62d9

Please sign in to comment.