Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
a4c5062
simplify createNativeBookmarkTree
michkot Feb 13, 2021
4dd2ee7
ensureContainersExist implementation uses new MandatoryBookmarkContai…
michkot Feb 13, 2021
363558c
cosmetic fix
michkot Feb 13, 2021
3add6fb
NativeContainersInfo with platformDefaultBookmarksNodeId
michkot Feb 13, 2021
5fa2f08
simple uses of platformDefaultBookmarksNodeId
michkot Feb 13, 2021
8a4fdaa
Complex uses of platformDefaultBookmarksNodeId + generification of we…
michkot Feb 13, 2021
143ea82
More notes
michkot Feb 13, 2021
c42d27f
Create mount-point bookmarks for unsupported containers in createNati…
michkot Feb 13, 2021
d1813a2
Unify firefox interface with webext- and chromium-
michkot Feb 13, 2021
b29ad13
Share the refactored chromium code via webext
michkot Feb 13, 2021
1979c23
Add notes
michkot Feb 13, 2021
94e6f06
getNativeContainerIds() now only returns entries with defined values.
michkot Feb 14, 2021
870843f
Enable use of strictNullChecks in tsconfig.json without affecting the…
michkot Feb 15, 2021
74bc6d8
Fix formating and strictNullChecks errors
michkot Feb 15, 2021
47ea734
Silence eslint errors about for(.. of ..) loops
michkot Feb 15, 2021
7cc1b74
Add more browser detection features to utility.services
michkot Feb 15, 2021
018fe8b
Refactor bookmark-service - getNativeContainerIds into a shared webex…
michkot Feb 15, 2021
96bed40
Merge remote-tracking branch 'refs/remotes/upstream/master' into HEAD
michkot Feb 15, 2021
cbda400
Remove remaining direct BookmarkContainer references
michkot Feb 15, 2021
8020096
Browser detection comments/logging
michkot Feb 15, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ export default class AndroidBookmarkService implements BookmarkService {
return bookmarks;
}

identifySupportedContainers(): ng.IPromise<void> {
return this.methodNotApplicable();
}

methodNotApplicable(): ng.IPromise<any> {
// Unused for this platform
return this.$q.resolve();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ export default class BackupRestoreSettingsComponent implements OnInit {
})
.then((bookmarks) => {
// Clean bookmarks for export
return cleanRecursive(this.bookmarkHelperSvc.removeEmptyContainers(bookmarks));
return cleanRecursive(bookmarks.filter((container) => container.children?.length));
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,15 +213,8 @@ export default class BookmarkHelperService {
}

getBookmarkType(bookmark: Bookmark): BookmarkType {
const bookmarkType = BookmarkType.Bookmark;

// Check if container
if (
bookmark.title === BookmarkContainer.Menu ||
bookmark.title === BookmarkContainer.Mobile ||
bookmark.title === BookmarkContainer.Other ||
bookmark.title === BookmarkContainer.Toolbar
) {
if (Object.values(BookmarkContainer).includes(bookmark.title as BookmarkContainer)) {
return BookmarkType.Container;
}

Expand All @@ -235,7 +228,7 @@ export default class BookmarkHelperService {
return BookmarkType.Separator;
}

return bookmarkType;
return BookmarkType.Bookmark;
}

getCachedBookmarks(): ng.IPromise<Bookmark[] | undefined> {
Expand Down Expand Up @@ -522,32 +515,6 @@ export default class BookmarkHelperService {
return this.$q.resolve(updatedBookmarks);
}

removeEmptyContainers(bookmarks: Bookmark[]): Bookmark[] {
const menuContainer = this.getContainer(BookmarkContainer.Menu, bookmarks);
const mobileContainer = this.getContainer(BookmarkContainer.Mobile, bookmarks);
const otherContainer = this.getContainer(BookmarkContainer.Other, bookmarks);
const toolbarContainer = this.getContainer(BookmarkContainer.Toolbar, bookmarks);
const removeArr: Bookmark[] = [];

if (!menuContainer?.children?.length) {
removeArr.push(menuContainer);
}

if (!mobileContainer?.children?.length) {
removeArr.push(mobileContainer);
}

if (!otherContainer?.children?.length) {
removeArr.push(otherContainer);
}

if (!toolbarContainer?.children?.length) {
removeArr.push(toolbarContainer);
}

return bookmarks.filter((x) => !removeArr.includes(x));
}

searchBookmarks(query: any): ng.IPromise<Bookmark[]> {
if (!query) {
query = { keywords: [] };
Expand Down
3 changes: 3 additions & 0 deletions src/modules/shared/bookmark/bookmark.enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ enum BookmarkChangeType {
Remove = 'remove'
}

// when adding a new container, add a translation to bookmark-helper.service.ts getBookmarkTitleForDisplay(...)
// do NOT reference any of these constants unless you absolutely have to
// (e.g. .Toolbar in conjunction with SettingsSvc.syncBookmarksToolbar() )
enum BookmarkContainer {
Menu = '[xbs] Menu',
Mobile = '[xbs] Mobile',
Expand Down
1 change: 1 addition & 0 deletions src/modules/shared/bookmark/bookmark.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export interface BookmarkService {
clearNativeBookmarks: () => ng.IPromise<void>;
createNativeBookmarksFromBookmarks: (bookmarks: Bookmark[]) => ng.IPromise<number>;
ensureContainersExist: (bookmarks: Bookmark[]) => Bookmark[];
identifySupportedContainers(): ng.IPromise<void>;
processNativeChangeOnBookmarks: (changeInfo: BookmarkChange, bookmarks: Bookmark[]) => ng.IPromise<Bookmark[]>;
processChangeOnNativeBookmarks: (
id: number,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,24 +137,26 @@ export default class BookmarkSyncProviderService implements SyncProvider {
}

processSync(sync: Sync): ng.IPromise<ProcessSyncResult> {
// Process sync
switch (sync.type) {
// Sync native bookmarks to service
case SyncType.Remote:
return this.processRemoteSync(sync);
// Overwrite native bookmarks with synced bookmarks
case SyncType.Local:
return this.processLocalSync(sync);
// Sync bookmarks to service and overwrite native bookmarks
case SyncType.LocalAndRemote:
return this.processLocalAndRemoteSync(sync);
// Upgrade sync to current version
case SyncType.Upgrade:
return this.processUpgradeSync();
// Ambiguous sync
default:
throw new Exceptions.AmbiguousSyncRequestException();
}
return this.bookmarkSvc.identifySupportedContainers().then(() => {
// Process sync
switch (sync.type) {
// Sync native bookmarks to service
case SyncType.Remote:
return this.processRemoteSync(sync);
// Overwrite native bookmarks with synced bookmarks
case SyncType.Local:
return this.processLocalSync(sync);
// Sync bookmarks to service and overwrite native bookmarks
case SyncType.LocalAndRemote:
return this.processLocalAndRemoteSync(sync);
// Upgrade sync to current version
case SyncType.Upgrade:
return this.processUpgradeSync();
// Ambiguous sync
default:
throw new Exceptions.AmbiguousSyncRequestException();
}
});
}

processLocalAndRemoteSync(sync: Sync): ng.IPromise<ProcessSyncResult> {
Expand Down
21 changes: 21 additions & 0 deletions src/modules/shared/utility/utility.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ import NetworkService from '../network/network.service';
import { StoreKey } from '../store/store.enum';
import StoreService from '../store/store.service';

declare global {
const opr: any;
}

@autobind
@Injectable('UtilityService')
export default class UtilityService {
Expand Down Expand Up @@ -157,6 +161,23 @@ export default class UtilityService {
return !angular.isUndefined(window.navigator.brave);
}

// as per https://stackoverflow.com/questions/9847580/how-to-detect-safari-chrome-ie-firefox-and-opera-browser/9851769#9851769
// Opera 20 - 74
isOperaBrowser(): boolean {
const windowsAny: any = window;
// eslint-disable-next-line no-undef
return (!!windowsAny.opr && !!opr.addons) || navigator.userAgent.indexOf(' OPR/') >= 0;
}
// Chrome 1 - 88
isChromeLikeBrowser(): boolean {
const windowsAny: any = window;
return !!windowsAny.chrome && (!!windowsAny.chrome.webstore || !!windowsAny.chrome.runtime);
}
// Edge (based on chromium) detection
isEdgeChromiumBrowser(): boolean {
return this.isChromeLikeBrowser() && navigator.userAgent.indexOf('Edg') !== -1;
}

isMobilePlatform(platformName: string): boolean {
return platformName === PlatformType.Android;
}
Expand Down
Loading