Skip to content

Commit e1ec274

Browse files
committed
bugfixes
1 parent 1c56b19 commit e1ec274

File tree

3 files changed

+38
-17
lines changed

3 files changed

+38
-17
lines changed

src/extension/codemic.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,13 +166,15 @@ class CodeMic {
166166

167167
// Open session.
168168
const session = await Session.Core.readLocal(this.context, workspace, { mustScan: recorder?.mustScan });
169-
assert(session, 'Failed to read sesion after setting workspace folder');
169+
assert(session, 'Failed to read session after setting workspace folder');
170170

171171
// Open screen. This will also load the session.
172172
if (screen === t.Screen.Player) {
173173
await this.openScreen({ screen, session, load: true });
174174
} else if (screen === t.Screen.Recorder) {
175175
await this.openScreen({ screen, session, clock: recorder!.clock });
176+
} else if (screen === t.Screen.Welcome) {
177+
await this.openScreen({ screen });
176178
}
177179

178180
return true;
@@ -388,6 +390,8 @@ class CodeMic {
388390
const workspace = uris?.[0]?.fsPath;
389391
if (!workspace) return ok;
390392

393+
// if (Session.Core.sessionExists(workspace))
394+
391395
await VscWorkspace.setUpWorkspace_MAY_RESTART_VSCODE(this.context, {
392396
screen: t.Screen.Welcome,
393397
workspace,
@@ -1032,6 +1036,8 @@ class CodeMic {
10321036

10331037
if (!(await this.closeCurrentScreen())) return;
10341038

1039+
this.setScreen(t.Screen.Loading);
1040+
10351041
switch (params.screen) {
10361042
case t.Screen.Loading: {
10371043
this.setScreen(t.Screen.Loading);
@@ -1143,7 +1149,7 @@ class CodeMic {
11431149
lib.unreachable(this.screen);
11441150
}
11451151

1146-
this.setScreen(t.Screen.Loading);
1152+
// this.setScreen(t.Screen.Loading);
11471153
return true;
11481154
}
11491155

src/lib/lib.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -721,9 +721,11 @@ export function searchSessions(
721721

722722
let pairs = sessions.map(listing => {
723723
const matchScore = searchQueryNorm ? getTokensMatchScore(getFields(listing.head)) : 1;
724-
const statsScore = (listing.publication ? listing.publication.likes * 20 + listing.publication.views : 1) / 10;
725-
const clipScore = listing.head.isClip ? 1 : 2;
726-
const score = matchScore * statsScore * clipScore;
724+
const likes = listing.publication?.likes ?? 0;
725+
const views = listing.publication?.views ?? 0;
726+
const statsScore = Math.sqrt(likes * 20 + views + 1) / 10;
727+
const clipMult = listing.head.isClip ? 1 : 2;
728+
const score = matchScore * statsScore * clipMult;
727729
return { listing, score };
728730
});
729731

@@ -735,7 +737,13 @@ export function searchSessions(
735737
remotePairs = _.filter(remotePairs, 'score');
736738
remotePairs = _.reject(remotePairs, p => recentPairs.some(recent => recent.listing.head.id === p.listing.head.id));
737739
remotePairs = _.orderBy(remotePairs, 'score', 'desc');
738-
recentPairs = _.take(_.filter(recentPairs, 'score'), recentLimit);
740+
recentPairs = _.filter(recentPairs, 'score');
741+
recentPairs = _.orderBy(
742+
recentPairs,
743+
p => p.listing.history && getSessionHistoryItemLastOpenTimestamp(p.listing.history),
744+
'desc',
745+
);
746+
recentPairs = _.take(recentPairs, recentLimit);
739747

740748
return _.map([...recentPairs, ...currentPairs, ...remotePairs], 'listing');
741749

src/view/recorder_toolbar.tsx

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -574,12 +574,29 @@ function CropPopover(props: PopoverProps & { onConfirm: (adjustMediaTracks: bool
574574
function ForkSessionPopover(
575575
props: PopoverProps & { onConfirm: (handle: string, workspace: string) => any; handle: string; workspace: string },
576576
) {
577+
const [handle, setHandle_] = useState(`${props.handle}_fork`);
577578
const [workspace, setWorkspace] = useState(`${props.workspace}_fork`);
578-
const [handle, setHandle] = useState(`${props.handle}_fork`);
579+
580+
function handleChanged(e: any) {
581+
const value = (e.target as HTMLInputElement).value.replace(/[^A-Za-z0-9_-]/g, '');
582+
setHandle_(value);
583+
if (workspace) {
584+
setWorkspace(path.join(path.dirname(workspace), value));
585+
}
586+
}
587+
579588
return (
580589
<Popover {...props}>
581590
<form className="recorder-popover-form">
582591
<label className="label">Fork session</label>
592+
<VSCodeTextField
593+
className="subsection"
594+
placeholder="A-Z a-z 0-9 - _ (e.g. my_project)"
595+
value={handle}
596+
onInput={handleChanged}
597+
>
598+
Handle
599+
</VSCodeTextField>
583600
<PathField
584601
className="subsection"
585602
placeholder="Workspace directory"
@@ -589,16 +606,6 @@ function ForkSessionPopover(
589606
>
590607
Workspace
591608
</PathField>
592-
<VSCodeTextField
593-
className="subsection"
594-
placeholder="A-Z a-z 0-9 - _ (e.g. my_project)"
595-
value={handle}
596-
onInput={e => {
597-
setHandle((e.target as HTMLInputElement).value.replace(/[^A-Za-z0-9_-]/g, ''));
598-
}}
599-
>
600-
Handle
601-
</VSCodeTextField>
602609
<VSCodeButton
603610
appearance="primary"
604611
onClick={e => {

0 commit comments

Comments
 (0)