mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-23 06:59:31 +01:00
use alias from item
This commit is contained in:
@@ -48,7 +48,7 @@ const TagItem = React.memo(
|
||||
>
|
||||
#
|
||||
</Heading>
|
||||
{db.tags.alias(item.id)}
|
||||
{item.alias}
|
||||
</Heading>
|
||||
<Paragraph
|
||||
color={colors.icon}
|
||||
|
||||
@@ -16,17 +16,13 @@ import { Synced } from './synced';
|
||||
import { Tags } from './tags';
|
||||
import { Topics } from './topics';
|
||||
import SearchService from '../../services/search';
|
||||
import { COLORS_NOTE } from '../../utils/color-scheme';
|
||||
|
||||
export const Properties = ({ close = () => {}, item, buttons = [], getRef }) => {
|
||||
const colors = useThemeStore(state => state.colors);
|
||||
|
||||
const alias = item
|
||||
? item.type === 'tag'
|
||||
? db.tags.alias(item.id)
|
||||
: item.type === 'color'
|
||||
? db.colors.alias(item.id)
|
||||
: item.title
|
||||
: null;
|
||||
const alias = item.alias || item.title;
|
||||
const isColor = !!COLORS_NOTE[item.title];
|
||||
|
||||
const onScrollEnd = () => {
|
||||
getRef().current?.handleChildScrollEnd();
|
||||
@@ -62,7 +58,11 @@ export const Properties = ({ close = () => {}, item, buttons = [], getRef }) =>
|
||||
}}
|
||||
>
|
||||
<Heading size={SIZE.lg}>
|
||||
{item.type === 'tag' ? '#' : null}
|
||||
{item.type === 'tag' && !isColor ? (
|
||||
<Heading size={SIZE.xl} color={colors.accent}>
|
||||
#
|
||||
</Heading>
|
||||
) : null}
|
||||
{alias}
|
||||
</Heading>
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ export const TagsSection = React.memo(
|
||||
});
|
||||
};
|
||||
const renderItem = ({ item, index }) => {
|
||||
let alias = item ? (item.type === 'tag' ? db.tags.alias(item.title) : item.title) : null;
|
||||
let alias = item.alias || item.title;
|
||||
return <PinItem item={item} index={index} alias={alias} onPress={onPress} />;
|
||||
};
|
||||
|
||||
@@ -85,7 +85,7 @@ export const PinItem = React.memo(
|
||||
({ item, index, onPress, placeholder, alias }) => {
|
||||
const colors = useThemeStore(state => state.colors);
|
||||
const setMenuPins = useMenuStore(state => state.setMenuPins);
|
||||
alias = !item ? '' : item.type === 'tag' ? db.tags.alias(item.title) : item.title;
|
||||
alias = item?.alias || item?.title;
|
||||
const [visible, setVisible] = useState(false);
|
||||
const [headerTextState, setHeaderTextState] = useState(null);
|
||||
const color = headerTextState?.id === item.id ? colors.accent : colors.pri;
|
||||
|
||||
@@ -33,6 +33,7 @@ export const Home = ({ navigation, route }: NavigationProps<'Notes'>) => {
|
||||
const loading = useNoteStore(state => state.loading);
|
||||
const isFocused = useNavigationFocus(navigation, {
|
||||
onFocus: prev => {
|
||||
console.log('updating', route.name, 'on focus');
|
||||
Navigation.routeNeedsUpdate(route.name, Navigation.routeUpdateFunctions[route.name]);
|
||||
useNavigationStore.getState().update({
|
||||
name: route.name
|
||||
|
||||
@@ -15,13 +15,8 @@ export function toCamelCase(title: string) {
|
||||
export function getAlias(params: NotesScreenParams) {
|
||||
if (!params) return '';
|
||||
const { item } = params;
|
||||
let alias =
|
||||
item.type === 'tag'
|
||||
? db.tags?.alias(item.id)
|
||||
: item.type === 'color'
|
||||
? db.colors?.alias(item.id)
|
||||
: params?.title;
|
||||
return alias || item.title;
|
||||
//@ts-ignore
|
||||
return item.alias || item.title;
|
||||
}
|
||||
|
||||
export function openMonographsWebpage() {
|
||||
@@ -78,7 +73,6 @@ export function isSynced(params: NotesScreenParams) {
|
||||
|
||||
async function onNoteCreated(id: string, params: FirstSaveData) {
|
||||
if (!params) return;
|
||||
|
||||
switch (params.type) {
|
||||
case 'topic': {
|
||||
await db.notes?.move(
|
||||
|
||||
@@ -50,6 +50,14 @@ export interface RouteProps<T extends RouteName> extends NavigationProps<T> {
|
||||
rightButtons?: (params: NotesScreenParams) => HeaderRightButton[];
|
||||
}
|
||||
|
||||
function getItemType(routeName: RouteName) {
|
||||
if (routeName === 'TaggedNotes') return 'tag';
|
||||
if (routeName === 'ColoredNotes') return 'color';
|
||||
if (routeName === 'TopicNotes') return 'topic';
|
||||
if (routeName === 'Monographs') return 'monograph';
|
||||
return 'note';
|
||||
}
|
||||
|
||||
const NotesPage = ({
|
||||
route,
|
||||
navigation,
|
||||
@@ -108,7 +116,7 @@ const NotesPage = ({
|
||||
|
||||
!isMonograph &&
|
||||
setOnFirstSave({
|
||||
type: item.type,
|
||||
type: getItemType(route.name),
|
||||
id: item.id,
|
||||
color: item.title,
|
||||
//@ts-ignore
|
||||
|
||||
@@ -109,7 +109,7 @@ function clearRouteFromQueue(routeName: Route) {
|
||||
* Check if a route needs update
|
||||
*/
|
||||
function routeNeedsUpdate(routeName: Route, callback: () => void) {
|
||||
console.log('routeName', routesUpdateQueue);
|
||||
console.log('routeNeedsUpdate', routesUpdateQueue, routesUpdateQueue.indexOf(routeName));
|
||||
if (routesUpdateQueue.indexOf(routeName) > -1) {
|
||||
clearRouteFromQueue(routeName);
|
||||
console.log('CALL ROUTE UPDATE');
|
||||
@@ -120,13 +120,16 @@ function routeNeedsUpdate(routeName: Route, callback: () => void) {
|
||||
function queueRoutesForUpdate(...routes: Route[]) {
|
||||
console.log('updating routes', routes);
|
||||
const currentScreen = useNavigationStore.getState().currentScreen;
|
||||
const routeHistory = rootNavigatorRef.getState()?.history || [{ key: currentScreen.name }];
|
||||
const routeHistory = rootNavigatorRef.current?.getRootState()?.routes || [
|
||||
{ key: currentScreen.name }
|
||||
];
|
||||
|
||||
// filter out routes that are not rendered to prevent unnecessary updates
|
||||
routes = routes.filter(
|
||||
//@ts-ignore
|
||||
routeName => routeHistory?.findIndex(route => route.key?.startsWith(routeName)) > -1
|
||||
);
|
||||
console.log('routes to update: ', routes, routeHistory, currentScreen.name);
|
||||
|
||||
if (routes.indexOf(currentScreen.name) > -1) {
|
||||
console.log('updating current route');
|
||||
routeUpdateFunctions[currentScreen.name]();
|
||||
@@ -138,6 +141,7 @@ function queueRoutesForUpdate(...routes: Route[]) {
|
||||
|
||||
routesUpdateQueue = routesUpdateQueue.concat(routes);
|
||||
routesUpdateQueue = [...new Set(routesUpdateQueue)];
|
||||
console.log(routesUpdateQueue);
|
||||
}
|
||||
|
||||
function navigate<T extends RouteName>(screen: CurrentScreen, params: RouteParams[T]) {
|
||||
|
||||
@@ -47,12 +47,7 @@ export const useActions = ({ close = () => {}, item }) => {
|
||||
console.log(item.readonly, 'readonly');
|
||||
const user = useUserStore(state => state.user);
|
||||
const [notifPinned, setNotifPinned] = useState(null);
|
||||
const alias =
|
||||
item.type === 'tag'
|
||||
? db.tags.alias(item.id)
|
||||
: item.type === 'color'
|
||||
? db.colors.alias(item.id)
|
||||
: item.title;
|
||||
const alias = item.alias || item.title;
|
||||
|
||||
const isPublished = item.type === 'note' && db.monographs.isPublished(item.id);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user