forked from Shinonome/dots-hyprland
sideleft: booru qol
- '+' gives next page - tags now get appended instead of sent
This commit is contained in:
@@ -19,12 +19,31 @@ const USER_CACHE_DIR = GLib.get_user_cache_dir();
|
||||
Utils.exec(`bash -c 'mkdir -p ${USER_CACHE_DIR}/ags/media/waifus'`);
|
||||
Utils.exec(`bash -c 'rm ${USER_CACHE_DIR}/ags/media/waifus/*'`);
|
||||
|
||||
const CommandButton = (command) => Button({
|
||||
className: 'sidebar-chat-chip sidebar-chat-chip-action txt txt-small',
|
||||
onClicked: () => sendMessage(command),
|
||||
setup: setupCursorHover,
|
||||
label: command,
|
||||
});
|
||||
const TagButton = (command) => {
|
||||
const plusSign = Revealer({
|
||||
transition: 'slide_right',
|
||||
revealChild: false,
|
||||
className: 'margin-right-5',
|
||||
child: Label({
|
||||
label: '+',
|
||||
})
|
||||
});
|
||||
return Button({
|
||||
className: 'sidebar-chat-chip sidebar-chat-chip-action txt txt-small',
|
||||
onClicked: () => { chatEntry.buffer.text += `${command} ` },
|
||||
onHover: () => plusSign.revealChild = true,
|
||||
onHoverLost: () => plusSign.revealChild = false,
|
||||
setup: setupCursorHover,
|
||||
child: Box({
|
||||
children: [
|
||||
plusSign,
|
||||
Label({
|
||||
label: command,
|
||||
}),
|
||||
]
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
export const booruTabIcon = Box({
|
||||
hpack: 'center',
|
||||
@@ -271,7 +290,7 @@ const BooruPage = (taglist, serviceName = 'Booru') => {
|
||||
hpack: 'fill',
|
||||
className: 'spacing-h-5',
|
||||
children: [
|
||||
...taglist.map((tag) => CommandButton(tag)),
|
||||
...taglist.map((tag) => TagButton(tag)),
|
||||
Box({ hexpand: true }),
|
||||
]
|
||||
})
|
||||
@@ -420,8 +439,8 @@ const booruTags = Revealer({
|
||||
child: Box({
|
||||
className: 'spacing-h-5',
|
||||
children: [
|
||||
CommandButton('*'),
|
||||
CommandButton('hololive'),
|
||||
TagButton('( * )'),
|
||||
TagButton('hololive'),
|
||||
]
|
||||
})
|
||||
}),
|
||||
@@ -433,7 +452,7 @@ const booruTags = Revealer({
|
||||
export const booruCommands = Box({
|
||||
className: 'spacing-h-5',
|
||||
setup: (self) => {
|
||||
self.pack_end(CommandButton('/clear'), false, false, 0);
|
||||
self.pack_end(TagButton('/clear'), false, false, 0);
|
||||
self.pack_start(Button({
|
||||
className: 'sidebar-chat-chip-toggle',
|
||||
setup: setupCursorHover,
|
||||
@@ -455,7 +474,11 @@ const clearChat = () => { // destroy!!
|
||||
|
||||
export const sendMessage = (text) => {
|
||||
// Commands
|
||||
if (text.startsWith('/')) {
|
||||
if (text.startsWith('+')) { // Next page
|
||||
const lastQuery = BooruService.queries.at(-1);
|
||||
BooruService.fetch(`${lastQuery.realTagList.join(' ')} ${lastQuery.page + 1}`)
|
||||
}
|
||||
else if (text.startsWith('/')) {
|
||||
if (text.startsWith('/clear')) clearChat();
|
||||
else if (text.startsWith('/safe')) {
|
||||
BooruService.nsfw = false;
|
||||
|
||||
Reference in New Issue
Block a user