rome -> eslint + prettier
This commit is contained in:
@@ -1,94 +1,92 @@
|
||||
import {
|
||||
createChannelMessage,
|
||||
getChannelMessages,
|
||||
getChannels,
|
||||
} from "@libs/storage";
|
||||
import { LumeEvent } from "@utils/types";
|
||||
import { create } from "zustand";
|
||||
import { immer } from "zustand/middleware/immer";
|
||||
import { create } from 'zustand';
|
||||
import { immer } from 'zustand/middleware/immer';
|
||||
|
||||
import { createChannelMessage, getChannelMessages, getChannels } from '@libs/storage';
|
||||
|
||||
import { LumeEvent } from '@utils/types';
|
||||
|
||||
export const useChannels = create(
|
||||
immer((set) => ({
|
||||
channels: [],
|
||||
fetch: async () => {
|
||||
const response = await getChannels();
|
||||
set({ channels: response });
|
||||
},
|
||||
add: (event) => {
|
||||
set((state) => {
|
||||
const target = state.channels.findIndex(
|
||||
(m: { event_id: string }) => m.event_id === event.id,
|
||||
);
|
||||
if (target !== -1) {
|
||||
state.channels[target]["new_messages"] =
|
||||
state.channels[target]["new_messages"] + 1 || 1;
|
||||
} else {
|
||||
state.channels.push({ event_id: event.id, ...event });
|
||||
}
|
||||
});
|
||||
},
|
||||
clearBubble: (id: string) => {
|
||||
set((state) => {
|
||||
const target = state.channels.findIndex(
|
||||
(m: { event_id: string }) => m.event_id === id,
|
||||
);
|
||||
state.channels[target]["new_messages"] = 0;
|
||||
});
|
||||
},
|
||||
})),
|
||||
immer((set) => ({
|
||||
channels: [],
|
||||
fetch: async () => {
|
||||
const response = await getChannels();
|
||||
set({ channels: response });
|
||||
},
|
||||
add: (event) => {
|
||||
set((state) => {
|
||||
const target = state.channels.findIndex(
|
||||
(m: { event_id: string }) => m.event_id === event.id
|
||||
);
|
||||
if (target !== -1) {
|
||||
state.channels[target]['new_messages'] =
|
||||
state.channels[target]['new_messages'] + 1 || 1;
|
||||
} else {
|
||||
state.channels.push({ event_id: event.id, ...event });
|
||||
}
|
||||
});
|
||||
},
|
||||
clearBubble: (id: string) => {
|
||||
set((state) => {
|
||||
const target = state.channels.findIndex(
|
||||
(m: { event_id: string }) => m.event_id === id
|
||||
);
|
||||
state.channels[target]['new_messages'] = 0;
|
||||
});
|
||||
},
|
||||
}))
|
||||
);
|
||||
|
||||
export const useChannelMessages = create(
|
||||
immer((set) => ({
|
||||
messages: [],
|
||||
replyTo: { id: null, pubkey: null, content: null },
|
||||
fetch: async (id: string) => {
|
||||
const events = await getChannelMessages(id);
|
||||
set({ messages: events });
|
||||
},
|
||||
add: (id, event: LumeEvent) => {
|
||||
set((state: any) => {
|
||||
createChannelMessage(
|
||||
id,
|
||||
event.id,
|
||||
event.pubkey,
|
||||
event.kind,
|
||||
event.content,
|
||||
event.tags,
|
||||
event.created_at,
|
||||
);
|
||||
state.messages.push({
|
||||
event_id: event.id,
|
||||
channel_id: id,
|
||||
hide: 0,
|
||||
mute: 0,
|
||||
...event,
|
||||
});
|
||||
});
|
||||
},
|
||||
openReply: (id: string, pubkey: string, content: string) => {
|
||||
set(() => ({ replyTo: { id, pubkey, content } }));
|
||||
},
|
||||
closeReply: () => {
|
||||
set(() => ({ replyTo: { id: null, pubkey: null, content: null } }));
|
||||
},
|
||||
hideMessage: (id: string) => {
|
||||
set((state) => {
|
||||
const target = state.messages.findIndex((m) => m.id === id);
|
||||
state.messages[target]["hide"] = true;
|
||||
});
|
||||
},
|
||||
muteUser: (pubkey: string) => {
|
||||
set((state) => {
|
||||
const target = state.messages.findIndex((m) => m.pubkey === pubkey);
|
||||
state.messages[target]["mute"] = true;
|
||||
});
|
||||
},
|
||||
clear: () => {
|
||||
set(() => ({
|
||||
messages: [],
|
||||
replyTo: { id: null, pubkey: null, content: null },
|
||||
}));
|
||||
},
|
||||
})),
|
||||
immer((set) => ({
|
||||
messages: [],
|
||||
replyTo: { id: null, pubkey: null, content: null },
|
||||
fetch: async (id: string) => {
|
||||
const events = await getChannelMessages(id);
|
||||
set({ messages: events });
|
||||
},
|
||||
add: (id, event: LumeEvent) => {
|
||||
set((state: any) => {
|
||||
createChannelMessage(
|
||||
id,
|
||||
event.id,
|
||||
event.pubkey,
|
||||
event.kind,
|
||||
event.content,
|
||||
event.tags,
|
||||
event.created_at
|
||||
);
|
||||
state.messages.push({
|
||||
event_id: event.id,
|
||||
channel_id: id,
|
||||
hide: 0,
|
||||
mute: 0,
|
||||
...event,
|
||||
});
|
||||
});
|
||||
},
|
||||
openReply: (id: string, pubkey: string, content: string) => {
|
||||
set(() => ({ replyTo: { id, pubkey, content } }));
|
||||
},
|
||||
closeReply: () => {
|
||||
set(() => ({ replyTo: { id: null, pubkey: null, content: null } }));
|
||||
},
|
||||
hideMessage: (id: string) => {
|
||||
set((state) => {
|
||||
const target = state.messages.findIndex((m) => m.id === id);
|
||||
state.messages[target]['hide'] = true;
|
||||
});
|
||||
},
|
||||
muteUser: (pubkey: string) => {
|
||||
set((state) => {
|
||||
const target = state.messages.findIndex((m) => m.pubkey === pubkey);
|
||||
state.messages[target]['mute'] = true;
|
||||
});
|
||||
},
|
||||
clear: () => {
|
||||
set(() => ({
|
||||
messages: [],
|
||||
replyTo: { id: null, pubkey: null, content: null },
|
||||
}));
|
||||
},
|
||||
}))
|
||||
);
|
||||
|
||||
@@ -1,41 +1,41 @@
|
||||
import { create } from "zustand";
|
||||
import { create } from 'zustand';
|
||||
|
||||
interface ComposerState {
|
||||
open: boolean;
|
||||
reply: { id: string; root: string; pubkey: string };
|
||||
repost: { id: string; pubkey: string };
|
||||
toggleModal: (status: boolean) => void;
|
||||
setReply: (id: string, root: string, pubkey: string) => void;
|
||||
setRepost: (id: string, pubkey: string) => void;
|
||||
clearReply: () => void;
|
||||
clearRepost: () => void;
|
||||
open: boolean;
|
||||
reply: { id: string; root: string; pubkey: string };
|
||||
repost: { id: string; pubkey: string };
|
||||
toggleModal: (status: boolean) => void;
|
||||
setReply: (id: string, root: string, pubkey: string) => void;
|
||||
setRepost: (id: string, pubkey: string) => void;
|
||||
clearReply: () => void;
|
||||
clearRepost: () => void;
|
||||
}
|
||||
|
||||
export const useComposer = create<ComposerState>((set) => ({
|
||||
open: false,
|
||||
reply: { id: null, root: null, pubkey: null },
|
||||
repost: { id: null, pubkey: null },
|
||||
toggleModal: (status: boolean) => {
|
||||
set({ open: status });
|
||||
if (!status) {
|
||||
set({ repost: { id: null, pubkey: null } });
|
||||
set({ reply: { id: null, root: null, pubkey: null } });
|
||||
}
|
||||
},
|
||||
setReply: (id: string, root: string, pubkey: string) => {
|
||||
set({ reply: { id: id, root: root, pubkey: pubkey } });
|
||||
set({ repost: { id: null, pubkey: null } });
|
||||
set({ open: true });
|
||||
},
|
||||
setRepost: (id: string, pubkey: string) => {
|
||||
set({ repost: { id: id, pubkey: pubkey } });
|
||||
set({ reply: { id: null, root: null, pubkey: null } });
|
||||
set({ open: true });
|
||||
},
|
||||
clearReply: () => {
|
||||
set({ reply: { id: null, root: null, pubkey: null } });
|
||||
},
|
||||
clearRepost: () => {
|
||||
set({ repost: { id: null, pubkey: null } });
|
||||
},
|
||||
open: false,
|
||||
reply: { id: null, root: null, pubkey: null },
|
||||
repost: { id: null, pubkey: null },
|
||||
toggleModal: (status: boolean) => {
|
||||
set({ open: status });
|
||||
if (!status) {
|
||||
set({ repost: { id: null, pubkey: null } });
|
||||
set({ reply: { id: null, root: null, pubkey: null } });
|
||||
}
|
||||
},
|
||||
setReply: (id: string, root: string, pubkey: string) => {
|
||||
set({ reply: { id: id, root: root, pubkey: pubkey } });
|
||||
set({ repost: { id: null, pubkey: null } });
|
||||
set({ open: true });
|
||||
},
|
||||
setRepost: (id: string, pubkey: string) => {
|
||||
set({ repost: { id: id, pubkey: pubkey } });
|
||||
set({ reply: { id: null, root: null, pubkey: null } });
|
||||
set({ open: true });
|
||||
},
|
||||
clearReply: () => {
|
||||
set({ reply: { id: null, root: null, pubkey: null } });
|
||||
},
|
||||
clearRepost: () => {
|
||||
set({ repost: { id: null, pubkey: null } });
|
||||
},
|
||||
}));
|
||||
|
||||
@@ -1,72 +1,72 @@
|
||||
export const APP_VERSION = "1.0.0";
|
||||
export const APP_VERSION = '1.0.0';
|
||||
|
||||
export const DEFAULT_AVATAR = "https://void.cat/d/5VKmKyuHyxrNMf9bWSVPih";
|
||||
export const DEFAULT_AVATAR = 'https://void.cat/d/5VKmKyuHyxrNMf9bWSVPih';
|
||||
|
||||
export const OPENGRAPH = {
|
||||
REGEX_VALID_URL: new RegExp(
|
||||
"^" +
|
||||
// protocol identifier
|
||||
"(?:(?:https?|ftp)://)" +
|
||||
// user:pass authentication
|
||||
"(?:\\S+(?::\\S*)?@)?" +
|
||||
"(?:" +
|
||||
// IP address exclusion
|
||||
// private & local networks
|
||||
"(?!(?:10|127)(?:\\.\\d{1,3}){3})" +
|
||||
"(?!(?:169\\.254|192\\.168)(?:\\.\\d{1,3}){2})" +
|
||||
"(?!172\\.(?:1[6-9]|2\\d|3[0-1])(?:\\.\\d{1,3}){2})" +
|
||||
// IP address dotted notation octets
|
||||
// excludes loopback network 0.0.0.0
|
||||
// excludes reserved space >= 224.0.0.0
|
||||
// excludes network & broacast addresses
|
||||
// (first & last IP address of each class)
|
||||
"(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])" +
|
||||
"(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}" +
|
||||
"(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))" +
|
||||
"|" +
|
||||
// host name
|
||||
"(?:(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)" +
|
||||
// domain name
|
||||
"(?:\\.(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)*" +
|
||||
// TLD identifier
|
||||
"(?:\\.(?:[a-z\\u00a1-\\uffff]{2,}))" +
|
||||
// TLD may end with dot
|
||||
"\\.?" +
|
||||
")" +
|
||||
// port number
|
||||
"(?::\\d{2,5})?" +
|
||||
// resource path
|
||||
"(?:[/?#]\\S*)?" +
|
||||
"$",
|
||||
"i",
|
||||
),
|
||||
REGEX_VALID_URL: new RegExp(
|
||||
'^' +
|
||||
// protocol identifier
|
||||
'(?:(?:https?|ftp)://)' +
|
||||
// user:pass authentication
|
||||
'(?:\\S+(?::\\S*)?@)?' +
|
||||
'(?:' +
|
||||
// IP address exclusion
|
||||
// private & local networks
|
||||
'(?!(?:10|127)(?:\\.\\d{1,3}){3})' +
|
||||
'(?!(?:169\\.254|192\\.168)(?:\\.\\d{1,3}){2})' +
|
||||
'(?!172\\.(?:1[6-9]|2\\d|3[0-1])(?:\\.\\d{1,3}){2})' +
|
||||
// IP address dotted notation octets
|
||||
// excludes loopback network 0.0.0.0
|
||||
// excludes reserved space >= 224.0.0.0
|
||||
// excludes network & broacast addresses
|
||||
// (first & last IP address of each class)
|
||||
'(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])' +
|
||||
'(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}' +
|
||||
'(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))' +
|
||||
'|' +
|
||||
// host name
|
||||
'(?:(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)' +
|
||||
// domain name
|
||||
'(?:\\.(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)*' +
|
||||
// TLD identifier
|
||||
'(?:\\.(?:[a-z\\u00a1-\\uffff]{2,}))' +
|
||||
// TLD may end with dot
|
||||
'\\.?' +
|
||||
')' +
|
||||
// port number
|
||||
'(?::\\d{2,5})?' +
|
||||
// resource path
|
||||
'(?:[/?#]\\S*)?' +
|
||||
'$',
|
||||
'i'
|
||||
),
|
||||
|
||||
REGEX_LOOPBACK: new RegExp(
|
||||
"^" +
|
||||
"(?:(?:10|127)(?:\\.\\d{1,3}){3})" +
|
||||
"|" +
|
||||
"(?:(?:169\\.254|192\\.168|192\\.0)(?:\\.\\d{1,3}){2})" +
|
||||
"|" +
|
||||
"(?:172\\.(?:1[6-9]|2\\d|3[0-1])(?:\\.\\d{1,3}){2})" +
|
||||
"$",
|
||||
"i",
|
||||
),
|
||||
REGEX_LOOPBACK: new RegExp(
|
||||
'^' +
|
||||
'(?:(?:10|127)(?:\\.\\d{1,3}){3})' +
|
||||
'|' +
|
||||
'(?:(?:169\\.254|192\\.168|192\\.0)(?:\\.\\d{1,3}){2})' +
|
||||
'|' +
|
||||
'(?:172\\.(?:1[6-9]|2\\d|3[0-1])(?:\\.\\d{1,3}){2})' +
|
||||
'$',
|
||||
'i'
|
||||
),
|
||||
|
||||
REGEX_CONTENT_TYPE_IMAGE: new RegExp("image/.*", "i"),
|
||||
REGEX_CONTENT_TYPE_IMAGE: new RegExp('image/.*', 'i'),
|
||||
|
||||
REGEX_CONTENT_TYPE_AUDIO: new RegExp("audio/.*", "i"),
|
||||
REGEX_CONTENT_TYPE_AUDIO: new RegExp('audio/.*', 'i'),
|
||||
|
||||
REGEX_CONTENT_TYPE_VIDEO: new RegExp("video/.*", "i"),
|
||||
REGEX_CONTENT_TYPE_VIDEO: new RegExp('video/.*', 'i'),
|
||||
|
||||
REGEX_CONTENT_TYPE_TEXT: new RegExp("text/.*", "i"),
|
||||
REGEX_CONTENT_TYPE_TEXT: new RegExp('text/.*', 'i'),
|
||||
|
||||
REGEX_CONTENT_TYPE_APPLICATION: new RegExp("application/.*", "i"),
|
||||
REGEX_CONTENT_TYPE_APPLICATION: new RegExp('application/.*', 'i'),
|
||||
};
|
||||
|
||||
export const FULL_RELAYS = [
|
||||
"wss://relayable.org",
|
||||
"wss://relay.damus.io",
|
||||
"wss://relay.nostrgraph.net",
|
||||
"wss://relay.nostr.band/all",
|
||||
"wss://nostr.mutinywallet.com",
|
||||
'wss://relayable.org',
|
||||
'wss://relay.damus.io',
|
||||
'wss://relay.nostrgraph.net',
|
||||
'wss://relay.nostr.band/all',
|
||||
'wss://nostr.mutinywallet.com',
|
||||
];
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import { create } from "zustand";
|
||||
import { create } from 'zustand';
|
||||
|
||||
interface NoteState {
|
||||
hasNewNote: boolean;
|
||||
toggleHasNewNote: (status: boolean) => void;
|
||||
hasNewNote: boolean;
|
||||
toggleHasNewNote: (status: boolean) => void;
|
||||
}
|
||||
|
||||
export const useNote = create<NoteState>((set) => ({
|
||||
hasNewNote: false,
|
||||
toggleHasNewNote: (status: boolean) => {
|
||||
set({ hasNewNote: status });
|
||||
},
|
||||
hasNewNote: false,
|
||||
toggleHasNewNote: (status: boolean) => {
|
||||
set({ hasNewNote: status });
|
||||
},
|
||||
}));
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
import { create } from "zustand";
|
||||
import { createJSONStorage, persist } from "zustand/middleware";
|
||||
import { create } from 'zustand';
|
||||
import { createJSONStorage, persist } from 'zustand/middleware';
|
||||
|
||||
export const useOnboarding = create(
|
||||
persist(
|
||||
(set) => ({
|
||||
profile: {},
|
||||
createProfile: (data) => {
|
||||
set({ profile: data });
|
||||
},
|
||||
}),
|
||||
{
|
||||
name: "onboarding",
|
||||
storage: createJSONStorage(() => sessionStorage),
|
||||
},
|
||||
),
|
||||
persist(
|
||||
(set) => ({
|
||||
profile: {},
|
||||
createProfile: (data) => {
|
||||
set({ profile: data });
|
||||
},
|
||||
}),
|
||||
{
|
||||
name: 'onboarding',
|
||||
storage: createJSONStorage(() => sessionStorage),
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
export const COMPOSE_SHORTCUT = "meta+n";
|
||||
export const ADD_IMAGEBLOCK_SHORTCUT = "meta+i";
|
||||
export const ADD_FEEDBLOCK_SHORTCUT = "meta+f";
|
||||
export const COMPOSE_SHORTCUT = 'meta+n';
|
||||
export const ADD_IMAGEBLOCK_SHORTCUT = 'meta+i';
|
||||
export const ADD_FEEDBLOCK_SHORTCUT = 'meta+f';
|
||||
|
||||
Reference in New Issue
Block a user