mirror of
https://github.com/tiddly-gittly/TidGi-Desktop.git
synced 2025-12-06 02:30:47 -08:00
refactor: preference keys to right order
This commit is contained in:
parent
b376a06b21
commit
260c9eacde
19 changed files with 106 additions and 105 deletions
|
|
@ -26,7 +26,7 @@ Given('I configure tidgi mini window with shortcut', async function() {
|
|||
|
||||
const updatedPreferences = {
|
||||
...existing.preferences,
|
||||
attachToTidgiMiniWindow: true,
|
||||
tidgiMiniWindow: true,
|
||||
keyboardShortcuts: {
|
||||
...(existing.preferences?.keyboardShortcuts || {}),
|
||||
'Window.toggleTidgiMiniWindow': shortcut,
|
||||
|
|
@ -42,12 +42,12 @@ function clearTidgiMiniWindowSettings() {
|
|||
const parsed = fs.readJsonSync(settingsPath) as ISettingFile;
|
||||
// Remove tidgi mini window-related preferences to avoid affecting other tests
|
||||
const cleanedPreferences = omit(parsed.preferences || {}, [
|
||||
'attachToTidgiMiniWindow',
|
||||
'tidgiMiniWindow',
|
||||
'tidgiMiniWindowSyncWorkspaceWithMainWindow',
|
||||
'tidgiMiniWindowFixedWorkspaceId',
|
||||
'tidgiMiniWindowAlwaysOnTop',
|
||||
'sidebarOnTidgiMiniWindow',
|
||||
'showTidgiMiniWindowTitleBar',
|
||||
'tidgiMiniWindowShowSidebar',
|
||||
'tidgiMiniWindowShowTitleBar',
|
||||
]);
|
||||
// Also clean up the tidgi mini window shortcut from keyboardShortcuts
|
||||
if (cleanedPreferences.keyboardShortcuts) {
|
||||
|
|
|
|||
|
|
@ -5,7 +5,8 @@ Feature: TidGi Mini Window
|
|||
So that I can quickly access TidGi from the system tray
|
||||
|
||||
Scenario: Enable tidgi mini window and test keyboard shortcut
|
||||
Given I launch the TidGi application
|
||||
Given I cleanup test wiki
|
||||
And I launch the TidGi application
|
||||
And I wait for the page to load completely
|
||||
And I click on an "open preferences button" element with selector "#open-preferences-button"
|
||||
And I switch to "preferences" window
|
||||
|
|
|
|||
|
|
@ -324,10 +324,10 @@
|
|||
"AlwaysOnTopDetail": "Keep TidGi’s main window always on top of other windows, and will not be covered by other windows",
|
||||
"AntiAntiLeech": "Some website has Anti-Leech, will prevent some images from being displayed on your wiki, we simulate a request header that looks like visiting that website to bypass this protection.",
|
||||
"AskDownloadLocation": "Ask where to save each file before downloading",
|
||||
"AttachToTidgiMiniWindow": "Attach to TidGi mini window",
|
||||
"AttachToTidgiMiniWindowShowSidebar": "Attach To TidGi Mini Window Show Sidebar",
|
||||
"AttachToTidgiMiniWindowShowSidebarTip": "Generally, TidGi mini window is only used to quickly view the current workspace, so the default synchronization with the main window workspace, do not need a sidebar, the default hidden sidebar.",
|
||||
"AttachToTidgiMiniWindowTip": "Make a small TidGi popup window that pop when you click system tray mini icon. Tip: Right-click on mini app icon to access context menu.",
|
||||
"TidgiMiniWindow": "Attach to TidGi mini window",
|
||||
"TidgiMiniWindowShowSidebar": "Attach To TidGi Mini Window Show Sidebar",
|
||||
"TidgiMiniWindowShowSidebarTip": "Generally, TidGi mini window is only used to quickly view the current workspace, so the default synchronization with the main window workspace, do not need a sidebar, the default hidden sidebar.",
|
||||
"TidgiMiniWindowTip": "Make a small TidGi popup window that pop when you click system tray mini icon. Tip: Right-click on mini app icon to access context menu.",
|
||||
"AttachToTaskbar": "Attach to taskbar",
|
||||
"AttachToTaskbarShowSidebar": "Attach To Taskbar Show Sidebar",
|
||||
"ChooseLanguage": "Choose Language 选择语言",
|
||||
|
|
@ -370,8 +370,8 @@
|
|||
"TidgiMiniWindowShortcutKeyPlaceholder": "e.g.: Ctrl+Shift+D",
|
||||
"TidgiMiniWindowSyncWorkspaceWithMainWindow": "TidGi Mini Window syncs with main window workspace",
|
||||
"TidgiMiniWindowSyncWorkspaceWithMainWindowDetail": "When checked, TidGi Mini Window will display the same workspace content as main window",
|
||||
"ShowTidgiMiniWindowTitleBar": "Show title bar on TidGi Mini Window",
|
||||
"ShowTidgiMiniWindowTitleBarDetail": "Show draggable title bar on TidGi Mini Window",
|
||||
"TidgiMiniWindowShowTitleBar": "Show title bar on TidGi Mini Window",
|
||||
"TidgiMiniWindowShowTitleBarDetail": "Show draggable title bar on TidGi Mini Window",
|
||||
"Miscellaneous": "Miscellaneous",
|
||||
"MoreWorkspaceSyncSettings": "More Workspace Sync Settings",
|
||||
"MoreWorkspaceSyncSettingsDescription": "Please right-click the workspace icon, open its workspace setting by click on \"Edit Workspace\" context menu item, and configure its independent synchronization settings in it.",
|
||||
|
|
|
|||
|
|
@ -324,10 +324,10 @@
|
|||
"AlwaysOnTopDetail": "Garder la fenêtre principale de TidGi toujours au-dessus des autres fenêtres, et ne sera pas couverte par d'autres fenêtres",
|
||||
"AntiAntiLeech": "Certains sites web ont une protection anti-leech, empêchant certaines images d'être affichées sur votre wiki, nous simulons un en-tête de requête qui ressemble à la visite de ce site web pour contourner cette protection.",
|
||||
"AskDownloadLocation": "Demander où enregistrer chaque fichier avant de télécharger",
|
||||
"AttachToTidgiMiniWindow": "Attacher à la mini-fenêtre TidGi",
|
||||
"AttachToTidgiMiniWindowShowSidebar": "Attacher à la mini-fenêtre TidGi Afficher la barre latérale",
|
||||
"AttachToTidgiMiniWindowShowSidebarTip": "En général, la petite fenêtre TidGi est uniquement utilisée pour visualiser rapidement l'espace de travail actuel, donc la synchronisation avec l'espace de travail de la fenêtre principale n'est pas nécessaire, la barre latérale est masquée par défaut.",
|
||||
"AttachToTidgiMiniWindowTip": "Créer une petite fenêtre contextuelle TidGi qui apparaît lorsque vous cliquez sur l'icône mini de la barre d'application. Astuce : Cliquez avec le bouton droit sur l'icône mini de l'application pour accéder au menu contextuel.",
|
||||
"TidgiMiniWindow": "Attacher à la mini-fenêtre TidGi",
|
||||
"TidgiMiniWindowShowSidebar": "Attacher à la mini-fenêtre TidGi Afficher la barre latérale",
|
||||
"TidgiMiniWindowShowSidebarTip": "En général, la petite fenêtre TidGi est uniquement utilisée pour visualiser rapidement l'espace de travail actuel, donc la synchronisation avec l'espace de travail de la fenêtre principale n'est pas nécessaire, la barre latérale est masquée par défaut.",
|
||||
"TidgiMiniWindowTip": "Créer une petite fenêtre contextuelle TidGi qui apparaît lorsque vous cliquez sur l'icône mini de la barre d'application. Astuce : Cliquez avec le bouton droit sur l'icône mini de l'application pour accéder au menu contextuel.",
|
||||
"AttachToTaskbar": "Attacher à la barre des tâches",
|
||||
"AttachToTaskbarShowSidebar": "Attacher à la barre des tâches Afficher la barre latérale",
|
||||
"ChooseLanguage": "Choisir la langue 选择语言",
|
||||
|
|
|
|||
|
|
@ -332,10 +332,10 @@
|
|||
"AlwaysOnTopDetail": "让太记的主窗口永远保持在其它窗口上方,不会被其他窗口覆盖",
|
||||
"AntiAntiLeech": "有的网站做了防盗链,会阻止某些图片在你的知识库上显示,我们通过模拟访问该网站的请求头来绕过这种限制。",
|
||||
"AskDownloadLocation": "下载前询问每个文件的保存位置",
|
||||
"AttachToTidgiMiniWindow": "附加到太记小窗",
|
||||
"AttachToTidgiMiniWindowShowSidebar": "太记小窗包含侧边栏",
|
||||
"AttachToTidgiMiniWindowShowSidebarTip": "一般太记小窗仅用于快速查看当前工作区,所以默认与主窗口工作区同步,不需要侧边栏,默认隐藏侧边栏。",
|
||||
"AttachToTidgiMiniWindowTip": "创建一个点击系统托盘图标会弹出的小太记窗口。提示:右键单击小图标以访问上下文菜单。",
|
||||
"TidgiMiniWindow": "附加到太记小窗",
|
||||
"TidgiMiniWindowShowSidebar": "太记小窗包含侧边栏",
|
||||
"TidgiMiniWindowShowSidebarTip": "一般太记小窗仅用于快速查看当前工作区,所以默认与主窗口工作区同步,不需要侧边栏,默认隐藏侧边栏。",
|
||||
"TidgiMiniWindowTip": "创建一个点击系统托盘图标会弹出的小太记窗口。提示:右键单击小图标以访问上下文菜单。",
|
||||
"AttachToTaskbar": "附加到任务栏",
|
||||
"AttachToTaskbarShowSidebar": "附加到任务栏的窗口包含侧边栏",
|
||||
"ChooseLanguage": "选择语言 Choose Language",
|
||||
|
|
@ -379,8 +379,8 @@
|
|||
"TidgiMiniWindowShortcutKeyPlaceholder": "例如:Ctrl+Shift+D",
|
||||
"TidgiMiniWindowSyncWorkspaceWithMainWindow": "小窗和主窗口展示同样的工作区",
|
||||
"TidgiMiniWindowSyncWorkspaceWithMainWindowDetail": "勾选后,小窗将与主窗口同步显示相同的工作区内容",
|
||||
"ShowTidgiMiniWindowTitleBar": "小窗显示标题栏",
|
||||
"ShowTidgiMiniWindowTitleBarDetail": "在太记小窗口上显示可拖动的标题栏",
|
||||
"TidgiMiniWindowShowTitleBar": "小窗显示标题栏",
|
||||
"TidgiMiniWindowShowTitleBarDetail": "在太记小窗口上显示可拖动的标题栏",
|
||||
"Miscellaneous": "其他设置",
|
||||
"MoreWorkspaceSyncSettings": "更多工作区同步设置",
|
||||
"MoreWorkspaceSyncSettingsDescription": "请右键工作区图标,点右键菜单里的「编辑工作区」来打开工作区设置,在里面配各个工作区的同步设置。",
|
||||
|
|
|
|||
|
|
@ -324,10 +324,10 @@
|
|||
"AlwaysOnTopDetail": "讓太記的主窗口永遠保持在其它窗口上方,不會被其他窗口覆蓋",
|
||||
"AntiAntiLeech": "有的網站做了防盜鏈,會阻止某些圖片在你的知識庫上顯示,我們透過模擬訪問該網站的請求頭來繞過這種限制。",
|
||||
"AskDownloadLocation": "下載前詢問每個文件的保存位置",
|
||||
"AttachToTidgiMiniWindow": "附加到太記小窗",
|
||||
"AttachToTidgiMiniWindowShowSidebar": "太記小窗包含側邊欄",
|
||||
"AttachToTidgiMiniWindowShowSidebarTip": "一般太記小窗僅用於快速查看當前工作區,所以默認與主窗口工作區同步,不需要側邊欄,默認隱藏側邊欄。",
|
||||
"AttachToTidgiMiniWindowTip": "創建一個點擊系統托盤圖示會彈出的小太記窗口。提示:右鍵單擊小圖示以訪問上下文菜單。",
|
||||
"TidgiMiniWindow": "附加到太記小窗",
|
||||
"TidgiMiniWindowShowSidebar": "太記小窗包含側邊欄",
|
||||
"TidgiMiniWindowShowSidebarTip": "一般太記小窗僅用於快速查看當前工作區,所以默認與主窗口工作區同步,不需要側邊欄,默認隱藏側邊欄。",
|
||||
"TidgiMiniWindowTip": "創建一個點擊系統托盤圖示會彈出的小太記窗口。提示:右鍵單擊小圖示以訪問上下文菜單。",
|
||||
"AttachToTaskbar": "附加到任務欄",
|
||||
"AttachToTaskbarShowSidebar": "附加到任務欄的窗口包含側邊欄",
|
||||
"ChooseLanguage": "選擇語言 Choose Language",
|
||||
|
|
|
|||
|
|
@ -139,8 +139,8 @@ const commonInit = async (): Promise<void> => {
|
|||
await workspaceService.initializeDefaultPageWorkspaces();
|
||||
// perform wiki startup and git sync for each workspace
|
||||
await workspaceViewService.initializeAllWorkspaceView();
|
||||
const attachToTidgiMiniWindow = await preferenceService.get('attachToTidgiMiniWindow');
|
||||
if (attachToTidgiMiniWindow) {
|
||||
const tidgiMiniWindow = await preferenceService.get('tidgiMiniWindow');
|
||||
if (tidgiMiniWindow) {
|
||||
await windowService.openTidgiMiniWindow(true, false);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ import Main from '../index';
|
|||
// Mock window.observables to provide realistic API behavior
|
||||
const preferencesSubject = new BehaviorSubject({
|
||||
sidebar: true,
|
||||
sidebarOnTidgiMiniWindow: true,
|
||||
tidgiMiniWindowShowSidebar: true,
|
||||
showSideBarText: true,
|
||||
showSideBarIcon: true,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ export default function Main(): React.JSX.Element {
|
|||
const { t } = useTranslation();
|
||||
useInitialPage();
|
||||
const preferences = usePreferenceObservable();
|
||||
const showSidebar = (windowName === WindowNames.tidgiMiniWindow ? preferences?.sidebarOnTidgiMiniWindow : preferences?.sidebar) ?? true;
|
||||
const showSidebar = (windowName === WindowNames.tidgiMiniWindow ? preferences?.tidgiMiniWindowShowSidebar : preferences?.sidebar) ?? true;
|
||||
return (
|
||||
<OuterRoot>
|
||||
<Helmet>
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ export class DatabaseService implements IDatabaseService {
|
|||
hasContent: !!this.settingFileContent,
|
||||
keys: this.settingFileContent ? Object.keys(this.settingFileContent).length : 0,
|
||||
hasPreferences: !!this.settingFileContent?.preferences,
|
||||
attachToTidgiMiniWindow: this.settingFileContent?.preferences?.attachToTidgiMiniWindow,
|
||||
tidgiMiniWindow: this.settingFileContent?.preferences?.tidgiMiniWindow,
|
||||
settingsFilePath: settings.file(),
|
||||
function: 'DatabaseService.initializeForApp',
|
||||
});
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@ export default async function getViewBounds(
|
|||
): Promise<{ height: number; width: number; x: number; y: number }> {
|
||||
const { findInPage = false, windowName } = config;
|
||||
const preferencesService = container.get<IPreferenceService>(serviceIdentifier.Preference);
|
||||
const [sidebar, sidebarOnTidgiMiniWindow] = await Promise.all([preferencesService.get('sidebar'), preferencesService.get('sidebarOnTidgiMiniWindow')]);
|
||||
const showSidebar = windowName === WindowNames.tidgiMiniWindow ? sidebarOnTidgiMiniWindow : sidebar;
|
||||
const [sidebar, tidgiMiniWindowShowSidebar] = await Promise.all([preferencesService.get('sidebar'), preferencesService.get('tidgiMiniWindowShowSidebar')]);
|
||||
const showSidebar = windowName === WindowNames.tidgiMiniWindow ? tidgiMiniWindowShowSidebar : sidebar;
|
||||
// Now showing sidebar on secondary window
|
||||
const secondary = windowName === WindowNames.secondary;
|
||||
const x = (showSidebar && !secondary) ? 68 : 0;
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ export const defaultPreferences: IPreferences = {
|
|||
allowPrerelease: Boolean(semver.prerelease(app.getVersion())),
|
||||
alwaysOnTop: false,
|
||||
askForDownloadPath: true,
|
||||
attachToTidgiMiniWindow: false,
|
||||
tidgiMiniWindow: false,
|
||||
disableAntiAntiLeech: false,
|
||||
disableAntiAntiLeechForUrls: [],
|
||||
downloadPath: DEFAULT_DOWNLOADS_PATH,
|
||||
|
|
@ -19,7 +19,7 @@ export const defaultPreferences: IPreferences = {
|
|||
tidgiMiniWindowAlwaysOnTop: false,
|
||||
tidgiMiniWindowFixedWorkspaceId: '',
|
||||
tidgiMiniWindowSyncWorkspaceWithMainWindow: true,
|
||||
showTidgiMiniWindowTitleBar: false,
|
||||
tidgiMiniWindowShowTitleBar: false,
|
||||
keyboardShortcuts: {},
|
||||
pauseNotifications: '',
|
||||
pauseNotificationsBySchedule: false,
|
||||
|
|
@ -32,7 +32,7 @@ export const defaultPreferences: IPreferences = {
|
|||
showSideBarIcon: true,
|
||||
showSideBarText: true,
|
||||
sidebar: true,
|
||||
sidebarOnTidgiMiniWindow: false,
|
||||
tidgiMiniWindowShowSidebar: false,
|
||||
spellcheck: true,
|
||||
spellcheckLanguages: ['en-US'],
|
||||
swipeToNavigate: true,
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ export interface IPreferences {
|
|||
allowPrerelease: boolean;
|
||||
alwaysOnTop: boolean;
|
||||
askForDownloadPath: boolean;
|
||||
attachToTidgiMiniWindow: boolean;
|
||||
tidgiMiniWindow: boolean;
|
||||
/**
|
||||
* 完全关闭反盗链
|
||||
*/
|
||||
|
|
@ -44,7 +44,7 @@ export interface IPreferences {
|
|||
/**
|
||||
* Should show sidebar on tidgi mini window?
|
||||
*/
|
||||
sidebarOnTidgiMiniWindow: boolean;
|
||||
tidgiMiniWindowShowSidebar: boolean;
|
||||
spellcheck: boolean;
|
||||
spellcheckLanguages: HunspellLanguages[];
|
||||
swipeToNavigate: boolean;
|
||||
|
|
@ -59,7 +59,7 @@ export interface IPreferences {
|
|||
/**
|
||||
* Whether to show title bar on tidgi mini window (independent of main window's titleBar setting)
|
||||
*/
|
||||
showTidgiMiniWindowTitleBar: boolean;
|
||||
tidgiMiniWindowShowTitleBar: boolean;
|
||||
/**
|
||||
* Keyboard shortcuts configuration stored as serviceIdentifier.methodName -> shortcut
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -247,7 +247,7 @@ export class View implements IViewService {
|
|||
};
|
||||
const checkNotExistResult = await Promise.all([
|
||||
checkNotExist(workspace, WindowNames.main),
|
||||
this.preferenceService.get('attachToTidgiMiniWindow').then((attachToTidgiMiniWindow) => attachToTidgiMiniWindow && checkNotExist(workspace, WindowNames.tidgiMiniWindow)),
|
||||
this.preferenceService.get('tidgiMiniWindow').then((tidgiMiniWindow) => tidgiMiniWindow && checkNotExist(workspace, WindowNames.tidgiMiniWindow)),
|
||||
]);
|
||||
return checkNotExistResult.every((result) => !result);
|
||||
}
|
||||
|
|
@ -412,15 +412,15 @@ export class View implements IViewService {
|
|||
public async setActiveViewForAllBrowserViews(workspaceID: string): Promise<void> {
|
||||
// Set main window workspace
|
||||
const mainWindowTask = this.setActiveView(workspaceID, WindowNames.main);
|
||||
const [attachToTidgiMiniWindow, tidgiMiniWindowSyncWorkspaceWithMainWindow, tidgiMiniWindowFixedWorkspaceId] = await Promise.all([
|
||||
this.preferenceService.get('attachToTidgiMiniWindow'),
|
||||
const [tidgiMiniWindow, tidgiMiniWindowSyncWorkspaceWithMainWindow, tidgiMiniWindowFixedWorkspaceId] = await Promise.all([
|
||||
this.preferenceService.get('tidgiMiniWindow'),
|
||||
this.preferenceService.get('tidgiMiniWindowSyncWorkspaceWithMainWindow'),
|
||||
this.preferenceService.get('tidgiMiniWindowFixedWorkspaceId'),
|
||||
]);
|
||||
|
||||
// For tidgi mini window, decide which workspace to show based on preferences
|
||||
let tidgiMiniWindowTask = Promise.resolve();
|
||||
if (attachToTidgiMiniWindow) {
|
||||
if (tidgiMiniWindow) {
|
||||
// Default to sync (undefined or true), otherwise use fixed workspace ID (fallback to main if not set)
|
||||
const shouldSync = tidgiMiniWindowSyncWorkspaceWithMainWindow === undefined || tidgiMiniWindowSyncWorkspaceWithMainWindow;
|
||||
const tidgiMiniWindowWorkspaceId = shouldSync ? workspaceID : (tidgiMiniWindowFixedWorkspaceId || workspaceID);
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ export async function handleAttachToTidgiMiniWindow(
|
|||
const preferenceService = container.get<IPreferenceService>(serviceIdentifier.Preference);
|
||||
|
||||
// Get tidgi mini window-specific titleBar preference
|
||||
const showTidgiMiniWindowTitleBar = await preferenceService.get('showTidgiMiniWindowTitleBar');
|
||||
const tidgiMiniWindowShowTitleBar = await preferenceService.get('tidgiMiniWindowShowTitleBar');
|
||||
|
||||
// setImage after Tray instance is created to avoid
|
||||
// "Segmentation fault (core dumped)" bug on Linux
|
||||
|
|
@ -43,15 +43,15 @@ export async function handleAttachToTidgiMiniWindow(
|
|||
minHeight: 100,
|
||||
minWidth: 250,
|
||||
// Use tidgi mini window-specific titleBar setting instead of inheriting from main window
|
||||
titleBarStyle: showTidgiMiniWindowTitleBar ? 'default' : 'hidden',
|
||||
frame: showTidgiMiniWindowTitleBar,
|
||||
titleBarStyle: tidgiMiniWindowShowTitleBar ? 'default' : 'hidden',
|
||||
frame: tidgiMiniWindowShowTitleBar,
|
||||
// Always hide the menu bar (File, Edit, View menu), even when showing title bar
|
||||
autoHideMenuBar: true,
|
||||
};
|
||||
|
||||
logger.info('Creating tidgi mini window with titleBar configuration', {
|
||||
function: 'handleAttachToTidgiMiniWindow',
|
||||
showTidgiMiniWindowTitleBar,
|
||||
tidgiMiniWindowShowTitleBar,
|
||||
titleBarStyle: tidgiMiniWindowConfig.titleBarStyle,
|
||||
frame: tidgiMiniWindowConfig.frame,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -350,13 +350,13 @@ export class Window implements IWindowService {
|
|||
logger.info('Closing tidgi mini window', { function: 'toggleTidgiMiniWindow' });
|
||||
await this.closeTidgiMiniWindow();
|
||||
} else {
|
||||
const attachToTidgiMiniWindow = await preferenceService.get('attachToTidgiMiniWindow');
|
||||
logger.debug('attachToTidgiMiniWindow preference checked', { function: 'toggleTidgiMiniWindow', attachToTidgiMiniWindow });
|
||||
if (attachToTidgiMiniWindow) {
|
||||
const tidgiMiniWindow = await preferenceService.get('tidgiMiniWindow');
|
||||
logger.debug('tidgiMiniWindow preference checked', { function: 'toggleTidgiMiniWindow', tidgiMiniWindow });
|
||||
if (tidgiMiniWindow) {
|
||||
logger.info('Opening tidgi mini window', { function: 'toggleTidgiMiniWindow' });
|
||||
await this.openTidgiMiniWindow(true, true); // Explicitly show window when toggling
|
||||
} else {
|
||||
logger.warn('Cannot open tidgi mini window: attachToTidgiMiniWindow preference is disabled', { function: 'toggleTidgiMiniWindow' });
|
||||
logger.warn('Cannot open tidgi mini window: tidgiMiniWindow preference is disabled', { function: 'toggleTidgiMiniWindow' });
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
|
|
@ -498,7 +498,7 @@ export class Window implements IWindowService {
|
|||
|
||||
public async reactWhenPreferencesChanged(key: string, value: unknown): Promise<void> {
|
||||
switch (key) {
|
||||
case 'attachToTidgiMiniWindow': {
|
||||
case 'tidgiMiniWindow': {
|
||||
if (value) {
|
||||
// Enable tidgi mini window without showing the window; visibility controlled by toggle/shortcut
|
||||
await this.openTidgiMiniWindow(true, false);
|
||||
|
|
@ -549,10 +549,10 @@ export class Window implements IWindowService {
|
|||
await this.updateWindowProperties(WindowNames.tidgiMiniWindow, { alwaysOnTop: value as boolean });
|
||||
return;
|
||||
}
|
||||
case 'showTidgiMiniWindowTitleBar': {
|
||||
case 'tidgiMiniWindowShowTitleBar': {
|
||||
// Title bar style requires recreating the window
|
||||
// We need to fully destroy and recreate the tidgi mini window with new titleBar settings
|
||||
logger.info('showTidgiMiniWindowTitleBar changed, recreating tidgi mini window', {
|
||||
logger.info('tidgiMiniWindowShowTitleBar changed, recreating tidgi mini window', {
|
||||
function: 'reactWhenPreferencesChanged',
|
||||
newValue: value,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -207,13 +207,13 @@ export class WorkspaceView implements IWorkspaceViewService {
|
|||
|
||||
// For tidgi mini window, decide which workspace to show based on preferences
|
||||
const tidgiMiniWindowTask = (async () => {
|
||||
const [attachToTidgiMiniWindow, tidgiMiniWindowSyncWorkspaceWithMainWindow, tidgiMiniWindowFixedWorkspaceId] = await Promise.all([
|
||||
this.preferenceService.get('attachToTidgiMiniWindow'),
|
||||
const [tidgiMiniWindow, tidgiMiniWindowSyncWorkspaceWithMainWindow, tidgiMiniWindowFixedWorkspaceId] = await Promise.all([
|
||||
this.preferenceService.get('tidgiMiniWindow'),
|
||||
this.preferenceService.get('tidgiMiniWindowSyncWorkspaceWithMainWindow'),
|
||||
this.preferenceService.get('tidgiMiniWindowFixedWorkspaceId'),
|
||||
]);
|
||||
|
||||
if (!attachToTidgiMiniWindow) {
|
||||
if (!tidgiMiniWindow) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -30,22 +30,22 @@ export function TidGiMiniWindow(props: Partial<ISectionProps>): React.JSX.Elemen
|
|||
<Switch
|
||||
edge='end'
|
||||
color='primary'
|
||||
checked={preference.attachToTidgiMiniWindow}
|
||||
checked={preference.tidgiMiniWindow}
|
||||
onChange={async (event) => {
|
||||
await window.service.preference.set('attachToTidgiMiniWindow', event.target.checked);
|
||||
await window.service.preference.set('tidgiMiniWindow', event.target.checked);
|
||||
}}
|
||||
data-testid='attach-to-tidgi-mini-window-switch'
|
||||
/>
|
||||
}
|
||||
>
|
||||
<ListItemText
|
||||
primary={platform === 'win32' ? t('Preference.AttachToTaskbar') : t('Preference.AttachToTidgiMiniWindow')}
|
||||
secondary={platform === 'linux' ? undefined : t('Preference.AttachToTidgiMiniWindowTip')}
|
||||
primary={platform === 'win32' ? t('Preference.AttachToTaskbar') : t('Preference.TidgiMiniWindow')}
|
||||
secondary={platform === 'linux' ? undefined : t('Preference.TidgiMiniWindowTip')}
|
||||
/>
|
||||
</ListItem>
|
||||
|
||||
{/* Other settings are only visible when attached to taskbar/system tray */}
|
||||
{preference.attachToTidgiMiniWindow && (
|
||||
{preference.tidgiMiniWindow && (
|
||||
<>
|
||||
{/* Sidebar display settings */}
|
||||
<ListItem
|
||||
|
|
@ -53,17 +53,17 @@ export function TidGiMiniWindow(props: Partial<ISectionProps>): React.JSX.Elemen
|
|||
<Switch
|
||||
edge='end'
|
||||
color='primary'
|
||||
checked={preference.sidebarOnTidgiMiniWindow}
|
||||
checked={preference.tidgiMiniWindowShowSidebar}
|
||||
onChange={async (event) => {
|
||||
await window.service.preference.set('sidebarOnTidgiMiniWindow', event.target.checked);
|
||||
await window.service.preference.set('tidgiMiniWindowShowSidebar', event.target.checked);
|
||||
}}
|
||||
data-testid='sidebar-on-tidgi-mini-window-switch'
|
||||
/>
|
||||
}
|
||||
>
|
||||
<ListItemText
|
||||
primary={platform === 'win32' ? t('Preference.AttachToTaskbarShowSidebar') : t('Preference.AttachToTidgiMiniWindowShowSidebar')}
|
||||
secondary={platform === 'linux' ? undefined : t('Preference.AttachToTidgiMiniWindowShowSidebarTip')}
|
||||
primary={platform === 'win32' ? t('Preference.AttachToTaskbarShowSidebar') : t('Preference.TidgiMiniWindowShowSidebar')}
|
||||
secondary={platform === 'linux' ? undefined : t('Preference.TidgiMiniWindowShowSidebarTip')}
|
||||
/>
|
||||
</ListItem>
|
||||
|
||||
|
|
@ -75,17 +75,17 @@ export function TidGiMiniWindow(props: Partial<ISectionProps>): React.JSX.Elemen
|
|||
<Switch
|
||||
edge='end'
|
||||
color='primary'
|
||||
checked={preference.showTidgiMiniWindowTitleBar}
|
||||
checked={preference.tidgiMiniWindowShowTitleBar}
|
||||
onChange={async (event) => {
|
||||
await window.service.preference.set('showTidgiMiniWindowTitleBar', event.target.checked);
|
||||
await window.service.preference.set('tidgiMiniWindowShowTitleBar', event.target.checked);
|
||||
}}
|
||||
data-testid='tidgi-mini-window-titlebar-switch'
|
||||
/>
|
||||
}
|
||||
>
|
||||
<ListItemText
|
||||
primary={t('Preference.ShowTidgiMiniWindowTitleBar')}
|
||||
secondary={t('Preference.ShowTidgiMiniWindowTitleBarDetail')}
|
||||
primary={t('Preference.TidgiMiniWindowShowTitleBar')}
|
||||
secondary={t('Preference.TidgiMiniWindowShowTitleBarDetail')}
|
||||
/>
|
||||
</ListItem>
|
||||
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ describe('TidGiMiniWindow Component', () => {
|
|||
vi.clearAllMocks();
|
||||
|
||||
preferenceSubject = new BehaviorSubject<IPreferences | undefined>(
|
||||
createMockPreference({ attachToTidgiMiniWindow: false }),
|
||||
createMockPreference({ tidgiMiniWindow: false }),
|
||||
);
|
||||
|
||||
Object.defineProperty(window.observables.preference, 'preference$', {
|
||||
|
|
@ -214,13 +214,13 @@ describe('TidGiMiniWindow Component', () => {
|
|||
|
||||
await renderComponent();
|
||||
|
||||
expect(screen.getByText('Preference.AttachToTidgiMiniWindow')).toBeInTheDocument();
|
||||
expect(screen.getByText('Preference.TidgiMiniWindow')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
describe('Attach to tidgi mini window toggle', () => {
|
||||
it('should display attach to tidgi mini window switch with correct initial state', async () => {
|
||||
preferenceSubject.next(createMockPreference({ attachToTidgiMiniWindow: false }));
|
||||
preferenceSubject.next(createMockPreference({ tidgiMiniWindow: false }));
|
||||
await renderComponent();
|
||||
|
||||
const switches = screen.getAllByRole('checkbox');
|
||||
|
|
@ -230,7 +230,7 @@ describe('TidGiMiniWindow Component', () => {
|
|||
|
||||
it('should call backend API when attach to tidgi mini window is toggled', async () => {
|
||||
const user = userEvent.setup();
|
||||
preferenceSubject.next(createMockPreference({ attachToTidgiMiniWindow: false }));
|
||||
preferenceSubject.next(createMockPreference({ tidgiMiniWindow: false }));
|
||||
await renderComponent();
|
||||
|
||||
const switches = screen.getAllByRole('checkbox');
|
||||
|
|
@ -239,13 +239,13 @@ describe('TidGiMiniWindow Component', () => {
|
|||
await user.click(attachSwitch);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(window.service.preference.set).toHaveBeenCalledWith('attachToTidgiMiniWindow', true);
|
||||
expect(window.service.preference.set).toHaveBeenCalledWith('tidgiMiniWindow', true);
|
||||
});
|
||||
});
|
||||
|
||||
it('should toggle attach to tidgi mini window setting', async () => {
|
||||
const user = userEvent.setup();
|
||||
preferenceSubject.next(createMockPreference({ attachToTidgiMiniWindow: false }));
|
||||
preferenceSubject.next(createMockPreference({ tidgiMiniWindow: false }));
|
||||
await renderComponent();
|
||||
|
||||
const switches = screen.getAllByRole('checkbox');
|
||||
|
|
@ -254,27 +254,27 @@ describe('TidGiMiniWindow Component', () => {
|
|||
await user.click(attachSwitch);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(window.service.preference.set).toHaveBeenCalledWith('attachToTidgiMiniWindow', true);
|
||||
expect(window.service.preference.set).toHaveBeenCalledWith('tidgiMiniWindow', true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Conditional settings visibility', () => {
|
||||
it('should hide additional settings when attachToTidgiMiniWindow is false', async () => {
|
||||
preferenceSubject.next(createMockPreference({ attachToTidgiMiniWindow: false }));
|
||||
it('should hide additional settings when tidgiMiniWindow is false', async () => {
|
||||
preferenceSubject.next(createMockPreference({ tidgiMiniWindow: false }));
|
||||
await renderComponent();
|
||||
|
||||
expect(screen.queryByText('Preference.AttachToTaskbarShowSidebar')).not.toBeInTheDocument();
|
||||
expect(screen.queryByText('Preference.AttachToTidgiMiniWindowShowSidebar')).not.toBeInTheDocument();
|
||||
expect(screen.queryByText('Preference.TidgiMiniWindowShowSidebar')).not.toBeInTheDocument();
|
||||
expect(screen.queryByText('Preference.TidgiMiniWindowAlwaysOnTop')).not.toBeInTheDocument();
|
||||
expect(screen.queryByText('Preference.TidgiMiniWindowSyncWorkspaceWithMainWindow')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should show additional settings when attachToTidgiMiniWindow is true', async () => {
|
||||
it('should show additional settings when tidgiMiniWindow is true', async () => {
|
||||
preferenceSubject.next(
|
||||
createMockPreference({
|
||||
attachToTidgiMiniWindow: true,
|
||||
sidebarOnTidgiMiniWindow: false,
|
||||
tidgiMiniWindow: true,
|
||||
tidgiMiniWindowShowSidebar: false,
|
||||
tidgiMiniWindowAlwaysOnTop: false,
|
||||
tidgiMiniWindowSyncWorkspaceWithMainWindow: true,
|
||||
}),
|
||||
|
|
@ -291,8 +291,8 @@ describe('TidGiMiniWindow Component', () => {
|
|||
it('should display sidebar toggle with correct initial state', async () => {
|
||||
preferenceSubject.next(
|
||||
createMockPreference({
|
||||
attachToTidgiMiniWindow: true,
|
||||
sidebarOnTidgiMiniWindow: false,
|
||||
tidgiMiniWindow: true,
|
||||
tidgiMiniWindowShowSidebar: false,
|
||||
}),
|
||||
);
|
||||
await renderComponent();
|
||||
|
|
@ -310,8 +310,8 @@ describe('TidGiMiniWindow Component', () => {
|
|||
const user = userEvent.setup();
|
||||
preferenceSubject.next(
|
||||
createMockPreference({
|
||||
attachToTidgiMiniWindow: true,
|
||||
sidebarOnTidgiMiniWindow: false,
|
||||
tidgiMiniWindow: true,
|
||||
tidgiMiniWindowShowSidebar: false,
|
||||
}),
|
||||
);
|
||||
await renderComponent();
|
||||
|
|
@ -322,7 +322,7 @@ describe('TidGiMiniWindow Component', () => {
|
|||
await user.click(sidebarSwitch);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(window.service.preference.set).toHaveBeenCalledWith('sidebarOnTidgiMiniWindow', true);
|
||||
expect(window.service.preference.set).toHaveBeenCalledWith('tidgiMiniWindowShowSidebar', true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
@ -331,7 +331,7 @@ describe('TidGiMiniWindow Component', () => {
|
|||
it('should display always on top toggle with correct initial state', async () => {
|
||||
preferenceSubject.next(
|
||||
createMockPreference({
|
||||
attachToTidgiMiniWindow: true,
|
||||
tidgiMiniWindow: true,
|
||||
tidgiMiniWindowAlwaysOnTop: false,
|
||||
}),
|
||||
);
|
||||
|
|
@ -350,7 +350,7 @@ describe('TidGiMiniWindow Component', () => {
|
|||
const user = userEvent.setup();
|
||||
preferenceSubject.next(
|
||||
createMockPreference({
|
||||
attachToTidgiMiniWindow: true,
|
||||
tidgiMiniWindow: true,
|
||||
tidgiMiniWindowAlwaysOnTop: false,
|
||||
}),
|
||||
);
|
||||
|
|
@ -371,7 +371,7 @@ describe('TidGiMiniWindow Component', () => {
|
|||
it('should display workspace sync toggle with correct initial state', async () => {
|
||||
preferenceSubject.next(
|
||||
createMockPreference({
|
||||
attachToTidgiMiniWindow: true,
|
||||
tidgiMiniWindow: true,
|
||||
tidgiMiniWindowSyncWorkspaceWithMainWindow: true,
|
||||
}),
|
||||
);
|
||||
|
|
@ -390,7 +390,7 @@ describe('TidGiMiniWindow Component', () => {
|
|||
const user = userEvent.setup();
|
||||
preferenceSubject.next(
|
||||
createMockPreference({
|
||||
attachToTidgiMiniWindow: true,
|
||||
tidgiMiniWindow: true,
|
||||
tidgiMiniWindowSyncWorkspaceWithMainWindow: true,
|
||||
}),
|
||||
);
|
||||
|
|
@ -421,7 +421,7 @@ describe('TidGiMiniWindow Component', () => {
|
|||
it('should show fixed workspace selector when sync is disabled', async () => {
|
||||
preferenceSubject.next(
|
||||
createMockPreference({
|
||||
attachToTidgiMiniWindow: true,
|
||||
tidgiMiniWindow: true,
|
||||
tidgiMiniWindowSyncWorkspaceWithMainWindow: false,
|
||||
}),
|
||||
);
|
||||
|
|
@ -437,7 +437,7 @@ describe('TidGiMiniWindow Component', () => {
|
|||
const user = userEvent.setup();
|
||||
preferenceSubject.next(
|
||||
createMockPreference({
|
||||
attachToTidgiMiniWindow: true,
|
||||
tidgiMiniWindow: true,
|
||||
tidgiMiniWindowSyncWorkspaceWithMainWindow: false,
|
||||
}),
|
||||
);
|
||||
|
|
@ -455,7 +455,7 @@ describe('TidGiMiniWindow Component', () => {
|
|||
it('should have workspace selector that can trigger API calls', async () => {
|
||||
preferenceSubject.next(
|
||||
createMockPreference({
|
||||
attachToTidgiMiniWindow: true,
|
||||
tidgiMiniWindow: true,
|
||||
tidgiMiniWindowSyncWorkspaceWithMainWindow: false,
|
||||
tidgiMiniWindowFixedWorkspaceId: '',
|
||||
}),
|
||||
|
|
@ -474,7 +474,7 @@ describe('TidGiMiniWindow Component', () => {
|
|||
it('should display currently selected workspace', async () => {
|
||||
preferenceSubject.next(
|
||||
createMockPreference({
|
||||
attachToTidgiMiniWindow: true,
|
||||
tidgiMiniWindow: true,
|
||||
tidgiMiniWindowSyncWorkspaceWithMainWindow: false,
|
||||
tidgiMiniWindowFixedWorkspaceId: 'workspace-2',
|
||||
}),
|
||||
|
|
@ -494,7 +494,7 @@ describe('TidGiMiniWindow Component', () => {
|
|||
it('should display keyboard shortcut button when tidgi mini window is attached', async () => {
|
||||
preferenceSubject.next(
|
||||
createMockPreference({
|
||||
attachToTidgiMiniWindow: true,
|
||||
tidgiMiniWindow: true,
|
||||
keyboardShortcuts: {},
|
||||
}),
|
||||
);
|
||||
|
|
@ -507,7 +507,7 @@ describe('TidGiMiniWindow Component', () => {
|
|||
it('should display current keyboard shortcut value', async () => {
|
||||
preferenceSubject.next(
|
||||
createMockPreference({
|
||||
attachToTidgiMiniWindow: true,
|
||||
tidgiMiniWindow: true,
|
||||
keyboardShortcuts: {
|
||||
'Window.toggleTidgiMiniWindow': 'Ctrl+Shift+M',
|
||||
},
|
||||
|
|
@ -522,7 +522,7 @@ describe('TidGiMiniWindow Component', () => {
|
|||
const user = userEvent.setup();
|
||||
preferenceSubject.next(
|
||||
createMockPreference({
|
||||
attachToTidgiMiniWindow: true,
|
||||
tidgiMiniWindow: true,
|
||||
keyboardShortcuts: {},
|
||||
}),
|
||||
);
|
||||
|
|
@ -553,7 +553,7 @@ describe('TidGiMiniWindow Component', () => {
|
|||
const user = userEvent.setup();
|
||||
preferenceSubject.next(
|
||||
createMockPreference({
|
||||
attachToTidgiMiniWindow: true,
|
||||
tidgiMiniWindow: true,
|
||||
keyboardShortcuts: {
|
||||
'Window.toggleTidgiMiniWindow': 'Ctrl+Shift+M',
|
||||
},
|
||||
|
|
@ -585,7 +585,7 @@ describe('TidGiMiniWindow Component', () => {
|
|||
it('should display helper text for keyboard shortcut', async () => {
|
||||
preferenceSubject.next(
|
||||
createMockPreference({
|
||||
attachToTidgiMiniWindow: true,
|
||||
tidgiMiniWindow: true,
|
||||
keyboardShortcuts: {},
|
||||
}),
|
||||
);
|
||||
|
|
@ -601,7 +601,7 @@ describe('TidGiMiniWindow Component', () => {
|
|||
|
||||
// Create a fresh subject for this test to avoid interference
|
||||
const toggleTestSubject = new BehaviorSubject<IPreferences | undefined>(
|
||||
createMockPreference({ attachToTidgiMiniWindow: false }),
|
||||
createMockPreference({ tidgiMiniWindow: false }),
|
||||
);
|
||||
|
||||
Object.defineProperty(window.observables.preference, 'preference$', {
|
||||
|
|
@ -642,7 +642,7 @@ describe('TidGiMiniWindow Component', () => {
|
|||
|
||||
// Wait for API call
|
||||
await waitFor(() => {
|
||||
expect(window.service.preference.set).toHaveBeenCalledWith('attachToTidgiMiniWindow', true);
|
||||
expect(window.service.preference.set).toHaveBeenCalledWith('tidgiMiniWindow', true);
|
||||
});
|
||||
|
||||
// Now verify new elements appear (they should appear automatically after the state update)
|
||||
|
|
@ -656,8 +656,8 @@ describe('TidGiMiniWindow Component', () => {
|
|||
const user = userEvent.setup();
|
||||
preferenceSubject.next(
|
||||
createMockPreference({
|
||||
attachToTidgiMiniWindow: true,
|
||||
sidebarOnTidgiMiniWindow: false,
|
||||
tidgiMiniWindow: true,
|
||||
tidgiMiniWindowShowSidebar: false,
|
||||
tidgiMiniWindowAlwaysOnTop: false,
|
||||
tidgiMiniWindowSyncWorkspaceWithMainWindow: true,
|
||||
}),
|
||||
|
|
@ -668,7 +668,7 @@ describe('TidGiMiniWindow Component', () => {
|
|||
|
||||
await user.click(switches[1]);
|
||||
await waitFor(() => {
|
||||
expect(window.service.preference.set).toHaveBeenCalledWith('sidebarOnTidgiMiniWindow', true);
|
||||
expect(window.service.preference.set).toHaveBeenCalledWith('tidgiMiniWindowShowSidebar', true);
|
||||
});
|
||||
|
||||
await user.click(switches[3]);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue