Skip to content

Commit

Permalink
wip: Editor and search improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
areknawo committed Feb 4, 2024
1 parent f81ff27 commit 614842f
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 17 deletions.
2 changes: 1 addition & 1 deletion apps/backend/assets/.env.example
Original file line number Diff line number Diff line change
@@ -1 +1 @@
PORT=4444
PORT=8888
2 changes: 1 addition & 1 deletion apps/web/src/layout/sidebar-menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ const SidebarMenu: Component = () => {
>
<Card
class={clsx(
"lg:p-0 flex justify-center items-center box-content fixed z-50 p-0 md:py-2 h-[calc(env(safe-area-inset-bottom,0)+3.625rem)] transition-all duration-300 m-0 rounded-0 border-0 border-t-2 md:border-t-0 md:border-r-2 w-full md:w-[calc(3.25rem+env(safe-area-inset-left,0px))] pl-[calc(env(safe-area-inset-left,0px))] md:h-full relative bottom-0 md:bottom-unset",
"flex justify-center items-center box-content fixed z-50 p-0 h-[calc(env(safe-area-inset-bottom,0)+3.625rem)] transition-all duration-300 m-0 rounded-0 border-0 border-t-2 md:border-t-0 md:border-r-2 w-full md:w-[calc(3.25rem+env(safe-area-inset-left,0px))] pl-[calc(env(safe-area-inset-left,0px))] md:h-full relative bottom-0 md:bottom-unset",
hideMenu() && "hidden"
)}
color="base"
Expand Down
20 changes: 11 additions & 9 deletions apps/web/src/views/editor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ const EditorView: Component = () => {
when={activeContentPieceId()}
fallback={
<div class="flex items-center justify-center w-full h-full">
<span class="text-2xl font-semibold text-gray-500 dark:text-gray-400">
To edit, select an article in the dashboard
<span class="text-2xl font-semibold text-gray-500 dark:text-gray-400 text-center">
Select article to edit
</span>
</div>
}
Expand Down Expand Up @@ -95,13 +95,15 @@ const EditorView: Component = () => {
</Show>
</div>
</div>
</Show>
<Show
when={!contentPieces[activeContentPieceId() || ""] || (activeContentPieceId() && syncing())}
>
<div class="flex items-center justify-center w-full h-full bg-gray-100 dark:bg-gray-800 absolute top-0 left-0">
<Loader />
</div>
<Show
when={
!contentPieces[activeContentPieceId() || ""] || (activeContentPieceId() && syncing())
}
>
<div class="flex items-center justify-center w-full h-full bg-gray-100 dark:bg-gray-800 absolute top-0 left-0">
<Loader />
</div>
</Show>
</Show>
</>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ const GitHubConfigurationView: Component<GitHubConfigurationViewProps> = (props)
path={mdiRefresh}
loading={installations.loading || repositories.loading || branches.loading}
text="soft"
color="contrast"
class="m-0"
onClick={async () => {
setSelectedInstallation(null);
Expand Down
7 changes: 5 additions & 2 deletions packages/backend/src/plugins/search/content/bulk-upsert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,13 @@ const bulkUpsertContent = createSearchContentHandler<{
if (!contentBuffer) continue;

const fragments = fragmentedContentProcessor(bufferToJSON(contentBuffer), contentPiece);
const validFragments = fragments.filter((fragment) => {
return Boolean(fragment.breadcrumb.map((crumb) => crumb === crumb.trim()).join(""));
});

if (!fragments.length) return;
if (!validFragments.length) return;

fragments.forEach((fragment) => {
validFragments.forEach((fragment) => {
batchCreator = batchCreator.withObject({
class: "Content",
tenant: `${contentPiece.workspaceId}`,
Expand Down
7 changes: 5 additions & 2 deletions packages/backend/src/plugins/search/content/upsert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,13 @@ const upsertContent = createSearchContentHandler<{
if (!contentBuffer) return;

const fragments = fragmentedContentProcessor(bufferToJSON(contentBuffer), details.contentPiece);
const validFragments = fragments.filter((fragment) => {
return Boolean(fragment.breadcrumb.map((crumb) => crumb === crumb.trim()).join(""));
});

if (!fragments.length) return;
if (!validFragments.length) return;

fragments.forEach((fragment) => {
validFragments.forEach((fragment) => {
batchCreator = batchCreator.withObject({
class: "Content",
tenant: `${details.contentPiece.workspaceId}`,
Expand Down
6 changes: 4 additions & 2 deletions packages/backend/src/routes/utils/handlers/link-preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const handler = async (
ctx: Context,
input: z.infer<typeof inputSchema>
): Promise<z.infer<typeof outputSchema>> => {
const urlFragments = input.url.split("/").filter(Boolean);
const urlFragments = input.url.split(".")[0].split("/").filter(Boolean);

if (input.url.startsWith("/")) {
if (!input.workspaceId) throw errors.serverError();
Expand All @@ -72,7 +72,9 @@ const handler = async (
const gitData = await gitDataCollection.findOne({
workspaceId: new ObjectId(input.workspaceId)
});
const record = gitData?.records.find((record) => record.path === urlFragments.join("/"));
const record = gitData?.records.find(
(record) => record.path.split(".")[0] === urlFragments.join("/")
);

if (record) {
contentPieceId = new ObjectId(record.contentPieceId);
Expand Down

0 comments on commit 614842f

Please sign in to comment.