mirror of
https://github.com/zen-browser/desktop.git
synced 2025-10-16 14:56:14 +00:00
Fix: Update pinned tab title in storage on rename
This commit addresses an issue where renaming a pinned tab wouldn't update the title stored in `ZenPinnedTabsStorage`. The following changes were made: - Modified `ZenUIManager.mjs` to asynchronously call `ZenPinnedTabsStorage.updatePinTitle` when a tab is renamed via the keyboard. This ensures the stored title is synchronized with the displayed title. - Added the `updatePinTitle` function to `ZenPinnedTabsStorage.mjs`. This function updates the title of a zen pin within the database. This ensures consistency between the tab title displayed in the UI and the title stored for pinned tabs.
This commit is contained in:
@@ -665,7 +665,7 @@ var gZenVerticalTabsManager = {
|
||||
target.appendChild(child);
|
||||
},
|
||||
|
||||
renameTabKeydown(event) {
|
||||
async renameTabKeydown(event) {
|
||||
if (event.key === 'Enter') {
|
||||
let label = this._tabEdited.querySelector('.tab-label-container-editing');
|
||||
let input = this._tabEdited.querySelector('#tab-label-input');
|
||||
@@ -681,6 +681,11 @@ var gZenVerticalTabsManager = {
|
||||
} else {
|
||||
gBrowser.setTabTitle(this._tabEdited);
|
||||
}
|
||||
const pinId = this._tabEdited.getAttribute('zen-pin-id');
|
||||
if (pinId) {
|
||||
// Update pin title in storage
|
||||
await ZenPinnedTabsStorage.updatePinTitle(pinId, this._tabEdited.label);
|
||||
}
|
||||
|
||||
// Maybe add some confetti here?!?
|
||||
gZenUIManager.motion.animate(
|
||||
|
@@ -351,6 +351,58 @@ var ZenPinnedTabsStorage = {
|
||||
this._notifyPinsChanged('zen-pin-updated', Array.from(changedUUIDs));
|
||||
},
|
||||
|
||||
async updatePinTitle(uuid, newTitle, notifyObservers = true) {
|
||||
if (!uuid || typeof newTitle !== 'string') {
|
||||
throw new Error('Invalid parameters: uuid and newTitle are required');
|
||||
}
|
||||
|
||||
const changedUUIDs = new Set();
|
||||
|
||||
await PlacesUtils.withConnectionWrapper('ZenPinnedTabsStorage.updatePinTitle', async (db) => {
|
||||
await db.executeTransaction(async () => {
|
||||
const now = Date.now();
|
||||
|
||||
// Update the pin's title
|
||||
const result = await db.execute(
|
||||
`
|
||||
UPDATE zen_pins
|
||||
SET title = :newTitle,
|
||||
updated_at = :now
|
||||
WHERE uuid = :uuid
|
||||
`,
|
||||
{
|
||||
uuid,
|
||||
newTitle,
|
||||
now,
|
||||
}
|
||||
);
|
||||
|
||||
// Only proceed with change tracking if a row was actually updated
|
||||
if (result.rowsAffected > 0) {
|
||||
changedUUIDs.add(uuid);
|
||||
|
||||
// Record the change
|
||||
await db.execute(
|
||||
`
|
||||
INSERT OR REPLACE INTO zen_pins_changes (uuid, timestamp)
|
||||
VALUES (:uuid, :timestamp)
|
||||
`,
|
||||
{
|
||||
uuid,
|
||||
timestamp: Math.floor(now / 1000),
|
||||
}
|
||||
);
|
||||
|
||||
await this.updateLastChangeTimestamp(db);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
if (notifyObservers && changedUUIDs.size > 0) {
|
||||
this._notifyPinsChanged('zen-pin-updated', Array.from(changedUUIDs));
|
||||
}
|
||||
},
|
||||
|
||||
async __dropTables() {
|
||||
await PlacesUtils.withConnectionWrapper('ZenPinnedTabsStorage.__dropTables', async (db) => {
|
||||
await db.execute(`DROP TABLE IF EXISTS zen_pins`);
|
||||
|
Reference in New Issue
Block a user