Skip to content

Commit

Permalink
feat: adapt page level properties as the prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
pengx17 committed Nov 8, 2021
1 parent ce409cf commit 2f7aca9
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "logseq-plugin-tabs",
"version": "1.7.5",
"schemaVersion": "1.0.0",
"main": "dist/index.html",
"scripts": {
"dev": "vite",
Expand Down
7 changes: 6 additions & 1 deletion src/PageTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@ const Tabs = React.forwardRef<HTMLElement, TabsProps>(
e.dataTransfer.effectAllowed = "move";
setDraggingTab(tab);
};
const prefix = tab.properties?.emoji
? tab.properties?.emoji
: isBlock(tab)
? "B"
: "P";
return (
<div
onClick={() => onClickTab(tab)}
Expand All @@ -118,7 +123,7 @@ const Tabs = React.forwardRef<HTMLElement, TabsProps>(
className="logseq-tab group"
>
<div className="text-xs rounded border mr-1 px-1 inline light:bg-white dark:bg-dark">
{isBlock(tab) ? "B" : "P"}
{prefix}
</div>
<span className="logseq-tab-title">
{tab.originalName ?? tab.name}{" "}
Expand Down
3 changes: 3 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ export interface ITabInfo {
page?: {
id: number;
};
properties?: {
emoji?: string;
};

// UI States:
pinned?: boolean;
Expand Down
4 changes: 2 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { PageEntity } from "@logseq/libs/dist/LSPlugin";
import React, { useMemo, useState } from "react";
import isEqual from "fast-deep-equal";
import { useHoverDirty, useMountedState } from "react-use";
import { version } from "../package.json";
import { schemaVersion } from "../package.json";
import { ITabInfo } from "./types";

export const useAppVisible = () => {
Expand Down Expand Up @@ -92,7 +92,7 @@ export const delay = (ms: number) =>
new Promise((resolve) => setTimeout(resolve, ms));

function getKeyId(graph: string) {
return "logseq-plugin-tabs:" + version + "/" + graph;
return "logseq-plugin-tabs:" + schemaVersion + "/" + graph;
}

const readFromLocalStorage = (graph: string): ITabInfo[] | null => {
Expand Down

0 comments on commit 2f7aca9

Please sign in to comment.