Compare commits

...
Author SHA1 Message Date
StandardNotes CI 496525ef61 chore(release): publish
- @standardnotes/[email protected].3
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected].1
 - @standardnotes/[email protected]
 - @standardnotes/[email protected].4
 - @standardnotes/[email protected].1
 - @standardnotes/[email protected]
 - @standardnotes/[email protected].1
 - @standardnotes/[email protected].1
 - @standardnotes/[email protected]
 - @standardnotes/[email protected].4
 - @standardnotes/[email protected].2
 - @standardnotes/[email protected].0
2023-01-04 20:27:27 +00:00
Aman Harwara 6b2f8f3da2 Merge branch 'main' of github.com:standardnotes/app 2023-01-05 01:23:24 +05:30
Aman Harwara e57b28fe29 feat: Added file options menu to file preview modal 2023-01-05 01:23:15 +05:30
Aman Harwara ba4b6a580b feat: Added "Add tag" option to file context menu 2023-01-05 01:16:35 +05:30
Mo 59fc68296b refactor: optimize delay between batches on mobile to allow UI interactivity during load (#2129) 2023-01-04 13:31:45 -06:00
StandardNotes CI 69b2af7612 chore(release): publish
- @standardnotes/[email protected]
 - @standardnotes/[email protected].3
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected].3
 - @standardnotes/[email protected].3
2023-01-04 19:10:43 +00:00
Aman Harwara 30dda73e90 fix: Fixed issue where file upload toast would close before completion if you switched windows 2023-01-05 00:13:42 +05:30
StandardNotes CI 81ea9e896c chore(release): publish
- @standardnotes/[email protected]
 - @standardnotes/[email protected].2
 - @standardnotes/[email protected]
 - @standardnotes/[email protected].2
2023-01-04 01:14:43 +00:00
Mo bc9247df41 chore: trigger build 2023-01-03 18:46:49 -06:00
StandardNotes CI 71e8645ca4 chore(release): publish
- @standardnotes/[email protected].1
 - @standardnotes/[email protected]
2023-01-03 23:51:59 +00:00
Mo 72f384c215 ci: remove mobile dev 2023-01-03 17:26:29 -06:00
Mo b65e8562f2 ci: remove unused workflow 2023-01-03 16:30:16 -06:00
76 changed files with 536 additions and 227 deletions
-96
View File
@@ -1,96 +0,0 @@
name: Mobile TestFlight
on:
push:
tags:
- '*standardnotes/web*'
workflow_dispatch:
jobs:
android:
defaults:
run:
working-directory: packages/mobile
runs-on: ubuntu-latest
timeout-minutes: 45
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Export version from package.json
run: |
echo "PACKAGE_VERSION=$(grep '"version"' ../web/package.json | cut -d '"' -f 4 | cut -d "-" -f 1)" >> $GITHUB_ENV
- name: Setup react-native kernel and increase watchers
run: echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
- name: Decode Dev Android keystore
run: |
echo "${{ secrets.DEV_KEYSTORE }}" > keystore.keystore.asc
gpg -d --passphrase "${{ secrets.DEV_KEYSTORE_PASSPHRASE }}" --batch keystore.keystore.asc > android/app/keystore.keystore
- name: Ruby Setup for Fastlane
uses: ruby/setup-ruby@v1
- name: Install dependencies
run: yarn install --immutable
- run: yarn build:mobile
- name: fastlane
uses: maierj/[email protected]
env:
PACKAGE_VERSION: ${{ env.PACKAGE_VERSION }}
BUILD_NUMBER: ${{ github.run_number }}
ANDROID_KEYSTORE_ALIAS: ${{ secrets.DEV_ANDROID_KEYSTORE_ALIAS }}
ANDROID_KEYSTORE_PRIVATE_KEY_PASSWORD: ${{ secrets.DEV_ANDROID_KEYSTORE_PRIVATE_KEY_PASSWORD }}
ANDROID_KEYSTORE_PASSWORD: ${{ secrets.DEV_ANDROID_KEYSTORE_PASSWORD }}
GOOGLE_PLAY_JSON_KEY_DATA: ${{ secrets.GOOGLE_PLAY_JSON_KEY_DATA }}
with:
lane: 'android dev'
subdirectory: 'packages/mobile'
ios:
env:
ITMSTRANSPORTER_FORCE_ITMS_PACKAGE_UPLOAD: true
defaults:
run:
working-directory: packages/mobile
runs-on: macos-11
timeout-minutes: 90
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Export version from package.json
run: |
echo "PACKAGE_VERSION=$(grep '"version"' ../web/package.json | cut -d '"' -f 4 | cut -d "-" -f 1)" >> $GITHUB_ENV
- name: Ruby Setup for Fastlane
uses: ruby/setup-ruby@v1
- name: Install dependencies
run: yarn install --immutable && yarn install:pods
- run: yarn build:mobile
- name: Set ssh connection to Github
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
- name: Export Apple AppStore Connect API key
run: echo "${{ secrets.APPSTORE_CONNECT_KEY }}" > ios/Authkey.p8
- name: Setup fastlane
uses: maierj/[email protected]
env:
FASTLANE_USER: ${{ secrets.FASTLANE_USER }}
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }}
with:
lane: 'ios setup'
subdirectory: 'packages/mobile'
- name: fastlane
uses: maierj/[email protected]
env:
PACKAGE_VERSION: ${{ env.PACKAGE_VERSION }}
APPLE_APP_ID: ${{ secrets.DEV_APP_APPLE_ID }}
APPSTORE_CONNECT_KEY_ID: ${{ secrets.APPSTORE_CONNECT_KEY_ID }}
APPSTORE_CONNECT_KEY_ISSUER_ID: ${{ secrets.APPSTORE_CONNECT_KEY_ISSUER_ID }}
FASTLANE_USER: ${{ secrets.FASTLANE_USER }}
FASTLANE_SESSION: ${{ secrets.FASTLANE_SESSION }}
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
MATCH_CERTIFICATES_URL: ${{ secrets.MATCH_CERTIFICATES_URL }}
MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }}
FASTLANE_PASSWORD: ${{ secrets.FASTLANE_PASSWORD }}
MATCH_GIT_BASIC_AUTHORIZATION: ${{ secrets.MATCH_GIT_BASIC_AUTHORIZATION }}
BUILD_NUMBER: ${{ github.run_number }}
with:
lane: 'ios dev'
subdirectory: 'packages/mobile'
+1 -1
View File
@@ -27,7 +27,7 @@
"build:services": "yarn workspaces foreach -pt --topological-dev --verbose -R --from @standardnotes/services run build",
"build:api": "yarn workspaces foreach -pt --topological-dev --verbose -R --from @standardnotes/api run build",
"start:server:web": "lerna run start --scope=@standardnotes/web",
"start:server:e2e": "lerna run start:test-server --scope=@standardnotes/snjs",
"e2e": "lerna run start:test-server --scope=@standardnotes/snjs",
"reset": "find . -type dir -name node_modules | xargs rm -rf && rm -rf yarn.lock && yarn install",
"release:prod": "lerna version --conventional-commits --yes -m \"chore(release): publish\"",
"publish:prod": "lerna publish from-git --yes --no-verify-access --loglevel verbose",
+4
View File
@@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.21.3](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-01-04)
**Note:** Version bump only for package @standardnotes/api
## [1.21.2](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-01-03)
**Note:** Version bump only for package @standardnotes/api
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@standardnotes/api",
"version": "1.21.2",
"version": "1.21.3",
"engines": {
"node": ">=16.0.0 <17.0.0"
},
+12
View File
@@ -3,6 +3,18 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [3.104.68](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-01-04)
**Note:** Version bump only for package @standardnotes/desktop
## [3.104.67](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-01-04)
**Note:** Version bump only for package @standardnotes/desktop
## [3.104.66](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-01-04)
**Note:** Version bump only for package @standardnotes/desktop
## [3.104.65](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-01-03)
**Note:** Version bump only for package @standardnotes/desktop
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@standardnotes/desktop",
"main": "./app/dist/index.js",
"version": "3.104.65",
"version": "3.104.68",
"license": "AGPL-3.0-or-later",
"author": "Standard Notes.",
"private": true,
+4
View File
@@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.19.34](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-01-04)
**Note:** Version bump only for package @standardnotes/encryption
## [1.19.33](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-01-03)
**Note:** Version bump only for package @standardnotes/encryption
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@standardnotes/encryption",
"version": "1.19.33",
"version": "1.19.34",
"engines": {
"node": ">=16.0.0 <17.0.0"
},
+4
View File
@@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.28.1](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-01-04)
**Note:** Version bump only for package @standardnotes/filepicker
# [1.28.0](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-01-03)
### Features
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@standardnotes/filepicker",
"version": "1.28.0",
"version": "1.28.1",
"engines": {
"node": ">=16.0.0 <17.0.0"
},
+4
View File
@@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.14.11](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-01-04)
**Note:** Version bump only for package @standardnotes/files
## [1.14.10](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-01-03)
**Note:** Version bump only for package @standardnotes/files
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@standardnotes/files",
"version": "1.14.10",
"version": "1.14.11",
"engines": {
"node": ">=16.0.0 <17.0.0"
},
+16
View File
@@ -3,6 +3,22 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [3.50.4](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-01-04)
**Note:** Version bump only for package @standardnotes/mobile
## [3.50.3](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-01-04)
**Note:** Version bump only for package @standardnotes/mobile
## [3.50.2](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-01-04)
**Note:** Version bump only for package @standardnotes/mobile
## [3.50.1](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-01-03)
**Note:** Version bump only for package @standardnotes/mobile
# [3.50.0](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-01-03)
### Features
-6
View File
@@ -1,16 +1,10 @@
for_platform :ios do
for_lane :dev do
app_identifier "com.standardnotes.standardnotes.dev"
end
for_lane :prod do
app_identifier "com.standardnotes.standardnotes"
end
end
for_platform :android do
for_lane :dev do
package_name 'com.standardnotes.dev'
end
for_lane :prod do
package_name 'com.standardnotes'
end
+1 -1
View File
@@ -2,7 +2,7 @@ storage_mode("git")
# type("development") # The default type, can be: appstore, adhoc, enterprise or development
app_identifier(["com.standardnotes.standardnotes", "com.standardnotes.standardnotes.dev"])
app_identifier(["com.standardnotes.standardnotes"])
# For all available options run `fastlane match --help`
# Remove the # in the beginning of the line to enable the other options
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@standardnotes/mobile",
"version": "3.50.0",
"version": "3.50.4",
"author": "Standard Notes.",
"private": true,
"license": "AGPL-3.0-or-later",
+4
View File
@@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.41.1](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-01-04)
**Note:** Version bump only for package @standardnotes/models
# [1.41.0](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-01-03)
### Features
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@standardnotes/models",
"version": "1.41.0",
"version": "1.41.1",
"engines": {
"node": ">=16.0.0 <17.0.0"
},
+16
View File
@@ -3,6 +3,22 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.4.91](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-01-04)
**Note:** Version bump only for package @standardnotes/releases
## [1.4.90](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-01-04)
**Note:** Version bump only for package @standardnotes/releases
## [1.4.89](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-01-04)
**Note:** Version bump only for package @standardnotes/releases
## [1.4.88](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-01-03)
**Note:** Version bump only for package @standardnotes/releases
## [1.4.87](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-01-03)
**Note:** Version bump only for package @standardnotes/releases
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@standardnotes/releases",
"version": "1.4.87",
"version": "1.4.91",
"license": "AGPL-3.0-or-later",
"main": "dist/releases.json",
"types": "dist/index.d.ts",
+4
View File
@@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.52.1](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-01-04)
**Note:** Version bump only for package @standardnotes/services
# [1.52.0](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-01-03)
### Features
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@standardnotes/services",
"version": "1.52.0",
"version": "1.52.1",
"engines": {
"node": ">=16.0.0 <17.0.0"
},
@@ -182,5 +182,6 @@ export const ErrorAlertStrings = {
export const KeychainRecoveryStrings = {
Title: 'Restore Keychain',
Text: "We've detected that your keychain has been wiped. This can happen when restoring your device from a backup. Please enter your account password to restore your account keys.",
Text: (email: string) =>
`We've detected that your keychain has been wiped. This can happen when restoring your device from a backup. Please enter your account password for "${email}" to restore your account keys.`,
}
@@ -1,3 +1,4 @@
import { Base64String } from '@standardnotes/sncrypto-common'
import { UserRequestType } from '@standardnotes/common'
import { DeinitSource } from '../Application/DeinitSource'
@@ -8,4 +9,5 @@ export interface UserClientInterface {
}>
signOut(force?: boolean, source?: DeinitSource): Promise<void>
submitUserRequest(requestType: UserRequestType): Promise<boolean>
populateSessionFromDemoShareToken(token: Base64String): Promise<void>
}
@@ -1,3 +1,4 @@
import { Base64String } from '@standardnotes/sncrypto-common'
import { EncryptionProviderInterface, SNRootKey, SNRootKeyParams } from '@standardnotes/encryption'
import { HttpResponse, SignInResponse, User } from '@standardnotes/responses'
import { KeyParamsOrigination, UserRequestType } from '@standardnotes/common'
@@ -470,6 +471,11 @@ export class UserService extends AbstractService<AccountEvent, AccountEventData>
}
}
public async populateSessionFromDemoShareToken(token: Base64String): Promise<void> {
await this.sessionManager.populateSessionFromDemoShareToken(token)
await this.notifyEvent(AccountEvent.SignedInOrRegistered)
}
private async setPasscodeWithoutWarning(passcode: string, origination: KeyParamsOrigination) {
const identifier = UuidGenerator.GenerateUuid()
const key = await this.protocolService.createRootKey(identifier, passcode, origination)
+4
View File
@@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [2.158.1](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-01-04)
**Note:** Version bump only for package @standardnotes/snjs
# [2.158.0](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-01-03)
### Features
+1 -1
View File
@@ -53,7 +53,7 @@ Once the server infrastructure is ready, and you've built all packages, you can
In app repo:
```
yarn start:server:e2e
yarn e2e
```
Once you are finished you can close the running local server on E2E repo by typing:
@@ -1581,6 +1581,7 @@ export class SNApplication implements ApplicationInterface, AppGroupManagedAppli
this.identifier,
{
loadBatchSize: this.options.loadBatchSize,
sleepBetweenBatches: this.options.sleepBetweenBatches,
},
this.internalEventBus,
)
@@ -1,9 +1,15 @@
import { ApplicationSyncOptions } from './OptionalOptions'
import { ApplicationDisplayOptions, ApplicationSyncOptions } from './OptionalOptions'
export interface ApplicationOptionsWhichHaveDefaults {
loadBatchSize: ApplicationSyncOptions['loadBatchSize']
sleepBetweenBatches: ApplicationSyncOptions['sleepBetweenBatches']
allowNoteSelectionStatePersistence: ApplicationDisplayOptions['allowNoteSelectionStatePersistence']
allowMultipleSelection: ApplicationDisplayOptions['allowMultipleSelection']
}
export const ApplicationOptionsDefaults: ApplicationOptionsWhichHaveDefaults = {
loadBatchSize: 700,
sleepBetweenBatches: 10,
allowMultipleSelection: true,
allowNoteSelectionStatePersistence: true,
}
@@ -3,10 +3,14 @@ export interface ApplicationSyncOptions {
* The size of the item batch to decrypt and render upon application load.
*/
loadBatchSize: number
sleepBetweenBatches: number
}
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface ApplicationDisplayOptions {}
export interface ApplicationDisplayOptions {
allowNoteSelectionStatePersistence: boolean
allowMultipleSelection: boolean
}
export interface ApplicationOptionalConfiguratioOptions {
/**
+4 -4
View File
@@ -1,4 +1,4 @@
import { AnyKeyParamsContent } from '@standardnotes/common'
import { AnyKeyParamsContent, KeyParamsContent004 } from '@standardnotes/common'
import { EncryptedPayload, EncryptedTransferPayload, isErrorDecryptingPayload } from '@standardnotes/models'
import { PreviousSnjsVersion1_0_0, PreviousSnjsVersion2_0_0, SnjsVersion } from '../Version'
import { Migration } from '@Lib/Migrations/Migration'
@@ -165,7 +165,7 @@ export class BaseMigration extends Migration {
}
private async repairMissingKeychain() {
const rawAccountParams = await this.reader.getAccountKeyParams()
const rawAccountParams = (await this.reader.getAccountKeyParams()) as AnyKeyParamsContent
/** Choose an item to decrypt against */
const allItems = (
@@ -196,14 +196,14 @@ export class BaseMigration extends Migration {
ChallengeReason.Custom,
false,
KeychainRecoveryStrings.Title,
KeychainRecoveryStrings.Text,
KeychainRecoveryStrings.Text((rawAccountParams as KeyParamsContent004).identifier),
)
return new Promise((resolve) => {
this.services.challengeService.addChallengeObserver(challenge, {
onNonvalidatedSubmit: async (challengeResponse) => {
const password = challengeResponse.values[0].value as string
const accountParams = this.services.protocolService.createKeyParams(rawAccountParams as AnyKeyParamsContent)
const accountParams = this.services.protocolService.createKeyParams(rawAccountParams)
const rootKey = await this.services.protocolService.computeRootKey(password, accountParams)
/** TS can't detect we returned early above if itemToDecrypt is null */
+10 -2
View File
@@ -298,6 +298,9 @@ export class SNSyncService
? chunks.fullEntries.remainingChunks
: chunks.keys.remainingChunks
let chunkIndex = 0
const ChunkIndexOfContentTypePriorityItems = 0
for (const chunk of remainingChunks) {
const dbEntries = isChunkFullEntry(chunk)
? chunk.entries
@@ -314,7 +317,14 @@ export class SNSyncService
.filter(isNotUndefined)
await this.processPayloadBatch(payloads, totalProcessedCount, payloadCount)
const shouldSleepOnlyAfterFirstRegularBatch = chunkIndex > ChunkIndexOfContentTypePriorityItems
if (shouldSleepOnlyAfterFirstRegularBatch) {
await sleep(this.options.sleepBetweenBatches, false, 'Sleeping to allow interface to update')
}
totalProcessedCount += payloads.length
chunkIndex++
}
this.databaseLoaded = true
@@ -353,8 +363,6 @@ export class SNSyncService
if (currentPosition != undefined && payloadCount != undefined) {
this.opStatus.setDatabaseLoadStatus(currentPosition, payloadCount, false)
}
await sleep(1, false)
}
private setLastSyncToken(token: string) {
+12 -9
View File
@@ -20,16 +20,19 @@ describe('application instances', () => {
})
it('two distinct applications should not share model manager state', async () => {
const app1 = await Factory.createAndInitializeApplication('app1')
const app2 = await Factory.createAndInitializeApplication('app2')
expect(app1.payloadManager).to.equal(app1.payloadManager)
expect(app1.payloadManager).to.not.equal(app2.payloadManager)
const context1 = await Factory.createAppContext({ identifier: 'app1' })
const context2 = await Factory.createAppContext({ identifier: 'app2' })
await Promise.all([context1.launch(), context2.launch()])
await Factory.createMappedNote(app1)
expect(app1.itemManager.items.length).length.to.equal(BaseItemCounts.DefaultItems + 1)
expect(app2.itemManager.items.length).to.equal(BaseItemCounts.DefaultItems)
await Factory.safeDeinit(app1)
await Factory.safeDeinit(app2)
expect(context1.application.payloadManager).to.equal(context1.application.payloadManager)
expect(context1.application.payloadManager).to.not.equal(context2.application.payloadManager)
await Factory.createMappedNote(context1.application)
expect(context1.application.itemManager.items.length).length.to.equal(BaseItemCounts.DefaultItems + 1)
expect(context2.application.itemManager.items.length).to.equal(BaseItemCounts.DefaultItems)
await context1.deinit()
await context2.deinit()
})
it('two distinct applications should not share storage manager state', async () => {
+4 -2
View File
@@ -16,7 +16,9 @@ describe('basic auth', function () {
beforeEach(async function () {
localStorage.clear()
this.expectedItemCount = BaseItemCounts.DefaultItems
this.application = await Factory.createInitAppWithFakeCrypto()
this.context = await Factory.createAppContext()
await this.context.launch()
this.application = this.context.application
this.email = UuidGenerator.GenerateUuid()
this.password = UuidGenerator.GenerateUuid()
})
@@ -402,7 +404,7 @@ describe('basic auth', function () {
await this.application.syncService.markAllItemsAsNeedingSyncAndPersist()
await this.application.syncService.sync(syncOptions)
this.application = await Factory.signOutApplicationAndReturnNew(this.application)
this.application = await this.context.signout()
expect(this.application.itemManager.items.length).to.equal(BaseItemCounts.DefaultItems)
expect(this.application.payloadManager.invalidPayloads.length).to.equal(0)
+32
View File
@@ -163,6 +163,13 @@ export class AppContext {
return newApplication
}
async signout() {
await this.application.user.signOut()
await this.initialize()
await this.launch()
return this.application
}
syncWithIntegrityCheck() {
return this.application.sync.sync({ checkIntegrity: true, awaitAll: true })
}
@@ -189,11 +196,36 @@ export class AppContext {
})
}
awaitUserPrefsSingletonCreation() {
const preferences = this.application.preferencesService.preferences
if (preferences) {
return
}
let didCompleteRelevantSync = false
return new Promise((resolve) => {
this.application.syncService.addEventObserver((eventName, data) => {
if (!didCompleteRelevantSync) {
if (data?.savedPayloads) {
const matching = data.savedPayloads.find((p) => {
return p.content_type === ContentType.UserPrefs
})
if (matching) {
didCompleteRelevantSync = true
resolve()
}
}
}
})
})
}
async launch({ awaitDatabaseLoad = true, receiveChallenge } = { awaitDatabaseLoad: true }) {
await this.application.prepareForLaunch({
receiveChallenge: receiveChallenge || this.handleChallenge,
})
await this.application.launch(awaitDatabaseLoad)
await this.awaitUserPrefsSingletonCreation()
}
async deinit() {
@@ -21,7 +21,9 @@ describe('app models', () => {
beforeEach(async function () {
this.expectedItemCount = BaseItemCounts.DefaultItems
this.application = await Factory.createInitAppWithFakeCrypto()
this.context = await Factory.createAppContext()
this.application = this.context.application
await this.context.launch()
})
afterEach(async function () {
@@ -13,6 +13,7 @@ describe('importing', function () {
let application
let email
let password
let context
beforeEach(function () {
localStorage.clear()
@@ -20,11 +21,16 @@ describe('importing', function () {
const setup = async ({ fakeCrypto }) => {
expectedItemCount = BaseItemCounts.DefaultItems
if (fakeCrypto) {
application = await Factory.createInitAppWithFakeCrypto()
context = await Factory.createAppContext()
} else {
application = await Factory.createInitAppWithRealCrypto()
context = await Factory.createAppContextWithRealCrypto()
}
await context.launch()
application = context.application
email = UuidGenerator.GenerateUuid()
password = UuidGenerator.GenerateUuid()
Factory.handlePasswordChallenges(application, password)
@@ -9,7 +9,9 @@ const expect = chai.expect
describe('model manager mapping', () => {
beforeEach(async function () {
this.expectedItemCount = BaseItemCounts.DefaultItems
this.application = await Factory.createInitAppWithFakeCrypto()
this.context = await Factory.createAppContext()
await this.context.launch()
this.application = this.context.application
})
afterEach(async function () {
@@ -14,7 +14,9 @@ describe('notes and tags', () => {
beforeEach(async function () {
this.expectedItemCount = BaseItemCounts.DefaultItems
this.application = await Factory.createInitAppWithFakeCrypto()
this.context = await Factory.createAppContext()
await this.context.launch()
this.application = this.context.application
})
afterEach(async function () {
@@ -7,7 +7,9 @@ const expect = chai.expect
describe('tags as folders', () => {
beforeEach(async function () {
this.application = await Factory.createInitAppWithFakeCrypto()
this.context = await Factory.createAppContext()
await this.context.launch()
this.application = this.context.application
})
afterEach(async function () {
+5 -1
View File
@@ -7,7 +7,11 @@ const expect = chai.expect
describe('preferences', function () {
beforeEach(async function () {
localStorage.clear()
this.application = await Factory.createInitAppWithFakeCrypto()
this.context = await Factory.createAppContext()
await this.context.launch()
this.application = this.context.application
this.email = UuidGenerator.GenerateUuid()
this.password = UuidGenerator.GenerateUuid()
})
+5 -1
View File
@@ -31,7 +31,11 @@ describe('singletons', function () {
beforeEach(async function () {
localStorage.clear()
this.expectedItemCount = BaseItemCounts.DefaultItems
this.application = await Factory.createInitAppWithFakeCrypto()
this.context = await Factory.createAppContext()
await this.context.launch()
this.application = this.context.application
this.email = UuidGenerator.GenerateUuid()
this.password = UuidGenerator.GenerateUuid()
this.registerUser = async () => {
+5 -2
View File
@@ -16,7 +16,9 @@ describe('storage manager', function () {
beforeEach(async function () {
localStorage.clear()
this.expectedKeyCount = BASE_KEY_COUNT
this.application = await Factory.createInitAppWithFakeCrypto(Environment.Mobile)
this.context = await Factory.createAppContext()
await this.context.launch()
this.application = this.context.application
this.email = UuidGenerator.GenerateUuid()
this.password = UuidGenerator.GenerateUuid()
})
@@ -221,7 +223,8 @@ describe('storage manager', function () {
expect(decrypted.content).to.be.an.instanceof(Object)
})
it('disabling storage encryption should store items without encryption', async function () {
/** @TODO: Storage encryption disable is no longer available, remove tests and associated functionality */
it.skip('disabling storage encryption should store items without encryption', async function () {
await Factory.registerUserToApplication({
application: this.application,
email: this.email,
@@ -13,7 +13,9 @@ describe('offline syncing', () => {
beforeEach(async function () {
this.expectedItemCount = BaseItemCounts.DefaultItems
this.application = await Factory.createInitAppWithFakeCrypto()
this.context = await Factory.createAppContext()
await this.context.launch()
this.application = this.context.application
})
afterEach(async function () {
@@ -95,7 +95,7 @@ describe('online syncing', function () {
await this.application.sync.sync(syncOptions)
this.application = await Factory.signOutApplicationAndReturnNew(this.application)
this.application = await this.context.signout()
expect(this.application.itemManager.items.length).to.equal(BaseItemCounts.DefaultItems)
+6 -2
View File
@@ -7,7 +7,11 @@ const expect = chai.expect
describe('upgrading', () => {
beforeEach(async function () {
localStorage.clear()
this.application = await Factory.createInitAppWithFakeCrypto()
this.context = await Factory.createAppContext()
await this.context.launch()
this.application = this.context.application
this.email = UuidGenerator.GenerateUuid()
this.password = UuidGenerator.GenerateUuid()
this.passcode = '1234'
@@ -170,7 +174,7 @@ describe('upgrading', () => {
/** Delete default items key that is created on launch */
const itemsKey = await this.application.protocolService.getSureDefaultItemsKey()
await this.application.itemManager.setItemToBeDeleted(itemsKey)
expect(this.application.itemManager.getDisplayableItemsKeys().length).to.equal(0)
expect(Uuids(this.application.itemManager.getDisplayableItemsKeys()).includes(itemsKey.uuid)).to.equal(false)
Factory.createMappedNote(this.application)
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@standardnotes/snjs",
"version": "2.158.0",
"version": "2.158.1",
"engines": {
"node": ">=16.0.0 <17.0.0"
},
+10
View File
@@ -3,6 +3,16 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.3.17](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-01-04)
**Note:** Version bump only for package @standardnotes/toast
## [1.3.16](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-01-04)
### Bug Fixes
* Fixed issue where file upload toast would close before completion if you switched windows ([30dda73](https://github.com/standardnotes/app/commit/30dda73e9078bbccf91c3f43307250c84a17e8bd))
## [1.3.15](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2022-12-29)
**Note:** Version bump only for package @standardnotes/toast
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@standardnotes/toast",
"version": "1.3.15",
"version": "1.3.17",
"private": true,
"main": "./src/index.ts",
"scripts": {
+5 -1
View File
@@ -27,8 +27,12 @@ export const ToastTimer: FunctionComponent<Props> = ({ toast, index }) => {
const remainingTimeRef = useRef(duration)
const dismissToastOnEnd = useCallback(() => {
if (!shouldAutoClose) {
return
}
dismissToast(toast.id)
}, [toast.id])
}, [shouldAutoClose, toast.id])
const clearTimer = useCallback(() => {
if (toastTimerIdRef.current) {
+8
View File
@@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.22.4](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-01-04)
**Note:** Version bump only for package @standardnotes/ui-services
## [1.22.3](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-01-04)
**Note:** Version bump only for package @standardnotes/ui-services
## [1.22.2](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-01-03)
**Note:** Version bump only for package @standardnotes/ui-services
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@standardnotes/ui-services",
"version": "1.22.2",
"version": "1.22.4",
"engines": {
"node": ">=16.0.0 <17.0.0"
},
+4
View File
@@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.15.2](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-01-04)
**Note:** Version bump only for package @standardnotes/utils
## [1.15.1](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-01-03)
**Note:** Version bump only for package @standardnotes/utils
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@standardnotes/utils",
"version": "1.15.1",
"version": "1.15.2",
"engines": {
"node": ">=16.0.0 <17.0.0"
},
+2 -2
View File
@@ -519,9 +519,9 @@ export function truncateHexString(string: string, desiredBits: number) {
* When awaited, this function allows code execution to pause for a set time.
* Should be used primarily for testing.
*/
export async function sleep(milliseconds: number, warn = true): Promise<void> {
export async function sleep(milliseconds: number, warn = true, desc = ''): Promise<void> {
if (warn) {
console.warn(`Sleeping for ${milliseconds}ms`)
console.warn(`Sleeping for ${milliseconds}ms ${desc}`)
}
return new Promise<void>((resolve) => {
setTimeout(function () {
+15
View File
@@ -3,6 +3,21 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
# [3.133.0](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-01-04)
### Features
* Added "Add tag" option to file context menu ([ba4b6a5](https://github.com/standardnotes/app/commit/ba4b6a580b2b18d2c383475c8723fb66fa9fecdf))
* Added file options menu to file preview modal ([e57b28f](https://github.com/standardnotes/app/commit/e57b28fe29f230754c247bf2a769355a7fbd30cb))
## [3.132.3](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-01-04)
**Note:** Version bump only for package @standardnotes/web
## [3.132.2](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-01-04)
**Note:** Version bump only for package @standardnotes/web
# [3.132.0](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-01-03)
### Features
+38
View File
@@ -1,5 +1,43 @@
{
"versions": [
{
"version": "3.133.0",
"title": "[3.133.0](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-01-04)",
"date": null,
"body": "### Features\n\n* Added \"Add tag\" option to file context menu ([ba4b6a5](https://github.com/standardnotes/app/commit/ba4b6a580b2b18d2c383475c8723fb66fa9fecdf))\n* Added file options menu to file preview modal ([e57b28f](https://github.com/standardnotes/app/commit/e57b28fe29f230754c247bf2a769355a7fbd30cb))",
"parsed": {
"_": [
"Added \"Add tag\" option to file context menu (ba4b6a5)",
"Added file options menu to file preview modal (e57b28f)"
],
"Features": [
"Added \"Add tag\" option to file context menu (ba4b6a5)",
"Added file options menu to file preview modal (e57b28f)"
]
}
},
{
"version": "3.132.3",
"title": "[3.132.3](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-01-04)",
"date": null,
"body": "**Note:** Version bump only for package @standardnotes/web",
"parsed": {
"_": [
"Note: Version bump only for package @standardnotes/web"
]
}
},
{
"version": "3.132.2",
"title": "[3.132.2](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-01-04)",
"date": null,
"body": "**Note:** Version bump only for package @standardnotes/web",
"parsed": {
"_": [
"Note: Version bump only for package @standardnotes/web"
]
}
},
{
"version": "3.132.0",
"title": "[3.132.0](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-01-03)",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@standardnotes/web",
"version": "3.132.0",
"version": "3.133.0",
"license": "AGPL-3.0-or-later",
"main": "dist/app.js",
"author": "Standard Notes.",
@@ -78,7 +78,11 @@ export class WebApplication extends SNApplication implements WebApplicationInter
appVersion: deviceInterface.appVersion,
webSocketUrl: webSocketUrl,
loadBatchSize:
deviceInterface.environment === Environment.Mobile ? 100 : ApplicationOptionsDefaults.loadBatchSize,
deviceInterface.environment === Environment.Mobile ? 250 : ApplicationOptionsDefaults.loadBatchSize,
sleepBetweenBatches:
deviceInterface.environment === Environment.Mobile ? 250 : ApplicationOptionsDefaults.sleepBetweenBatches,
allowMultipleSelection: deviceInterface.environment !== Environment.Mobile,
allowNoteSelectionStatePersistence: deviceInterface.environment !== Environment.Mobile,
})
makeObservable(this, {
@@ -14,7 +14,6 @@ import { ApplicationGroup } from '@/Application/ApplicationGroup'
import { formatLastSyncDate } from '@/Utils/DateUtils'
import Spinner from '@/Components/Spinner/Spinner'
import { MenuItemIconSize } from '@/Constants/TailwindClassNames'
import { MutuallyExclusiveMediaQueryBreakpoints, useMediaQuery } from '@/Hooks/useMediaQuery'
type Props = {
viewControllerManager: ViewControllerManager
@@ -85,22 +84,9 @@ const GeneralAccountMenu: FunctionComponent<Props> = ({
setMenuPane(AccountMenuPane.SignIn)
}, [setMenuPane])
const openFileSend = useCallback(() => {
const link = 'https://filesend.standardnotes.com/'
if (application.isNativeMobileWeb()) {
application.mobileDevice().openUrl(link)
return
}
window.open(link, '_blank')
}, [application])
const CREATE_ACCOUNT_INDEX = 1
const SWITCHER_INDEX = 0
const isMobileScreen = useMediaQuery(MutuallyExclusiveMediaQueryBreakpoints.sm)
return (
<>
<div className="mt-1 mb-1 flex items-center justify-between px-3">
@@ -186,12 +172,6 @@ const GeneralAccountMenu: FunctionComponent<Props> = ({
</div>
<span className="text-neutral">v{application.version}</span>
</MenuItem>
{isMobileScreen && (
<MenuItem onClick={openFileSend}>
<Icon type="open-in" className={iconClassName} />
Open FileSend
</MenuItem>
)}
<MenuItem onClick={() => viewControllerManager.isImportModalVisible.set(true)}>
<Icon type="archive" className={iconClassName} />
Import
@@ -89,7 +89,7 @@ const ApplicationView: FunctionComponent<Props> = ({ application, mainApplicatio
return
}
void application.sessions.populateSessionFromDemoShareToken(token)
void application.user.populateSessionFromDemoShareToken(token)
}, [application])
const onAppLaunch = useCallback(() => {
@@ -216,6 +216,8 @@ const ApplicationView: FunctionComponent<Props> = ({ application, mainApplicatio
<FileContextMenuWrapper
filesController={viewControllerManager.filesController}
selectionController={viewControllerManager.selectionController}
navigationController={viewControllerManager.navigationController}
linkingController={viewControllerManager.linkingController}
/>
<PurchaseFlowWrapper application={application} viewControllerManager={viewControllerManager} />
<ConfirmSignoutContainer
@@ -358,6 +358,7 @@ const ContentListView = forwardRef<HTMLDivElement, Props>(
filesController={filesController}
featuresController={featuresController}
linkingController={linkingController}
navigationController={navigationController}
/>
) : (
<ContentList
@@ -1,4 +1,6 @@
import { FilesController } from '@/Controllers/FilesController'
import { LinkingController } from '@/Controllers/LinkingController'
import { NavigationController } from '@/Controllers/Navigation/NavigationController'
import { SelectedItemsController } from '@/Controllers/SelectedItemsController'
import { observer } from 'mobx-react-lite'
import { FunctionComponent } from 'react'
@@ -9,36 +11,47 @@ import FileMenuOptions from './FileMenuOptions'
type Props = {
filesController: FilesController
selectionController: SelectedItemsController
linkingController: LinkingController
navigationController: NavigationController
}
const FileContextMenu: FunctionComponent<Props> = observer(({ filesController, selectionController }) => {
const { showFileContextMenu, setShowFileContextMenu, fileContextMenuLocation } = filesController
const { selectedFiles } = selectionController
const FileContextMenu: FunctionComponent<Props> = observer(
({ filesController, selectionController, linkingController, navigationController }) => {
const { showFileContextMenu, setShowFileContextMenu, fileContextMenuLocation } = filesController
const { selectedFiles } = selectionController
return (
<Popover
open={showFileContextMenu}
anchorPoint={fileContextMenuLocation}
togglePopover={() => setShowFileContextMenu(!showFileContextMenu)}
align="start"
className="py-2"
>
<Menu a11yLabel="File context menu" isOpen={showFileContextMenu}>
<FileMenuOptions
filesController={filesController}
selectedFiles={selectedFiles}
closeMenu={() => setShowFileContextMenu(false)}
shouldShowRenameOption={false}
shouldShowAttachOption={false}
/>
</Menu>
</Popover>
)
})
return (
<Popover
open={showFileContextMenu}
anchorPoint={fileContextMenuLocation}
togglePopover={() => setShowFileContextMenu(!showFileContextMenu)}
align="start"
className="py-2"
>
<Menu a11yLabel="File context menu" isOpen={showFileContextMenu}>
<FileMenuOptions
filesController={filesController}
linkingController={linkingController}
navigationController={navigationController}
selectedFiles={selectedFiles}
closeMenu={() => setShowFileContextMenu(false)}
shouldShowRenameOption={false}
shouldShowAttachOption={false}
/>
</Menu>
</Popover>
)
},
)
FileContextMenu.displayName = 'FileContextMenu'
const FileContextMenuWrapper: FunctionComponent<Props> = ({ filesController, selectionController }) => {
const FileContextMenuWrapper: FunctionComponent<Props> = ({
filesController,
linkingController,
navigationController,
selectionController,
}) => {
const { showFileContextMenu } = filesController
const { selectedFiles } = selectionController
@@ -48,7 +61,14 @@ const FileContextMenuWrapper: FunctionComponent<Props> = ({ filesController, sel
return null
}
return <FileContextMenu filesController={filesController} selectionController={selectionController} />
return (
<FileContextMenu
filesController={filesController}
linkingController={linkingController}
navigationController={navigationController}
selectionController={selectionController}
/>
)
}
export default observer(FileContextMenuWrapper)
@@ -11,10 +11,16 @@ import MenuItem from '../Menu/MenuItem'
import { FileContextMenuBackupOption } from './FileContextMenuBackupOption'
import MenuSwitchButtonItem from '../Menu/MenuSwitchButtonItem'
import { FileItem } from '@standardnotes/snjs'
import AddTagOption from '../NotesOptions/AddTagOption'
import { MenuItemIconSize } from '@/Constants/TailwindClassNames'
import { LinkingController } from '@/Controllers/LinkingController'
import { NavigationController } from '@/Controllers/Navigation/NavigationController'
type Props = {
closeMenu: () => void
filesController: FilesController
linkingController: LinkingController
navigationController: NavigationController
isFileAttachedToNote?: boolean
renameToggleCallback?: (isRenamingFile: boolean) => void
shouldShowRenameOption: boolean
@@ -25,6 +31,8 @@ type Props = {
const FileMenuOptions: FunctionComponent<Props> = ({
closeMenu,
filesController,
linkingController,
navigationController,
isFileAttachedToNote,
renameToggleCallback,
shouldShowRenameOption,
@@ -82,6 +90,12 @@ const FileMenuOptions: FunctionComponent<Props> = ({
) : null}
</>
)}
<AddTagOption
navigationController={navigationController}
linkingController={linkingController}
selectedItems={selectedFiles}
iconClassName={`text-neutral mr-2 ${MenuItemIconSize}`}
/>
<MenuSwitchButtonItem
checked={hasProtectedFiles}
onChange={(hasProtectedFiles) => {
@@ -6,13 +6,22 @@ import { SelectedItemsController } from '@/Controllers/SelectedItemsController'
import Popover from '../Popover/Popover'
import RoundIconButton from '../Button/RoundIconButton'
import Menu from '../Menu/Menu'
import { LinkingController } from '@/Controllers/LinkingController'
import { NavigationController } from '@/Controllers/Navigation/NavigationController'
type Props = {
filesController: FilesController
selectionController: SelectedItemsController
linkingController: LinkingController
navigationController: NavigationController
}
const FilesOptionsPanel = ({ filesController, selectionController }: Props) => {
const FilesOptionsPanel = ({
filesController,
linkingController,
navigationController,
selectionController,
}: Props) => {
const [isOpen, setIsOpen] = useState(false)
const buttonRef = useRef<HTMLButtonElement>(null)
@@ -25,6 +34,8 @@ const FilesOptionsPanel = ({ filesController, selectionController }: Props) => {
<Menu a11yLabel="File options panel" isOpen={isOpen}>
<FileMenuOptions
filesController={filesController}
linkingController={linkingController}
navigationController={navigationController}
selectedFiles={selectionController.selectedFiles}
closeMenu={() => {
setIsOpen(false)
@@ -10,6 +10,9 @@ import { ViewControllerManager } from '@/Controllers/ViewControllerManager'
import { observer } from 'mobx-react-lite'
import FilePreview from './FilePreview'
import { getIconForFileType } from '@/Utils/Items/Icons/getIconForFileType'
import FileMenuOptions from '../FileContextMenu/FileMenuOptions'
import Menu from '../Menu/Menu'
import Popover from '../Popover/Popover'
type Props = {
application: WebApplication
@@ -23,7 +26,9 @@ const FilePreviewModal: FunctionComponent<Props> = observer(({ application, view
return null
}
const [showOptionsMenu, setShowOptionsMenu] = useState(false)
const [showFileInfoPanel, setShowFileInfoPanel] = useState(false)
const menuButtonRef = useRef<HTMLButtonElement>(null)
const closeButtonRef = useRef<HTMLButtonElement>(null)
const keyDownHandler: KeyboardEventHandler = useCallback(
@@ -91,6 +96,38 @@ const FilePreviewModal: FunctionComponent<Props> = observer(({ application, view
<span className="ml-3 font-medium">{currentFile.name}</span>
</div>
<div className="flex items-center">
<button
className="mr-4 flex cursor-pointer rounded border border-solid border-border bg-transparent p-1.5 hover:bg-contrast"
onClick={() => setShowOptionsMenu((show) => !show)}
ref={menuButtonRef}
>
<Icon type="more" className="text-neutral" />
</button>
<Popover
open={showOptionsMenu}
anchorElement={menuButtonRef.current}
togglePopover={() => {
setShowOptionsMenu(false)
}}
side="bottom"
align="start"
className="py-2"
overrideZIndex="z-modal"
>
<Menu a11yLabel="File context menu" isOpen={showOptionsMenu}>
<FileMenuOptions
filesController={viewControllerManager.filesController}
linkingController={viewControllerManager.linkingController}
navigationController={viewControllerManager.navigationController}
selectedFiles={[currentFile]}
closeMenu={() => {
setShowOptionsMenu(false)
}}
shouldShowRenameOption={false}
shouldShowAttachOption={false}
/>
</Menu>
</Popover>
<button
className="mr-4 flex cursor-pointer rounded border border-solid border-border bg-transparent p-1.5 hover:bg-contrast"
onClick={() => setShowFileInfoPanel((show) => !show)}
@@ -112,6 +112,8 @@ const FileViewWithoutProtection = ({ application, viewControllerManager, file }:
<FileOptionsPanel
filesController={viewControllerManager.filesController}
selectionController={viewControllerManager.selectionController}
linkingController={viewControllerManager.linkingController}
navigationController={viewControllerManager.navigationController}
/>
</div>
</div>
@@ -31,8 +31,19 @@ import { LinkingController } from '@/Controllers/LinkingController'
import { FeaturesController } from '@/Controllers/FeaturesController'
import { MutuallyExclusiveMediaQueryBreakpoints, useMediaQuery } from '@/Hooks/useMediaQuery'
import { useApplication } from '../ApplicationProvider'
import { NavigationController } from '@/Controllers/Navigation/NavigationController'
const ContextMenuCell = ({ files, filesController }: { files: FileItem[]; filesController: FilesController }) => {
const ContextMenuCell = ({
files,
filesController,
navigationController,
linkingController,
}: {
files: FileItem[]
filesController: FilesController
navigationController: NavigationController
linkingController: LinkingController
}) => {
const [contextMenuVisible, setContextMenuVisible] = useState(false)
const anchorElementRef = useRef<HTMLButtonElement>(null)
@@ -61,6 +72,8 @@ const ContextMenuCell = ({ files, filesController }: { files: FileItem[]; filesC
>
<Menu a11yLabel="File context menu" isOpen={contextMenuVisible}>
<FileMenuOptions
linkingController={linkingController}
navigationController={navigationController}
closeMenu={() => {
setContextMenuVisible(false)
}}
@@ -160,9 +173,16 @@ type Props = {
filesController: FilesController
featuresController: FeaturesController
linkingController: LinkingController
navigationController: NavigationController
}
const FilesTableView = ({ application, filesController, featuresController, linkingController }: Props) => {
const FilesTableView = ({
application,
filesController,
featuresController,
linkingController,
navigationController,
}: Props) => {
const files = application.items
.getDisplayableNotesAndFiles()
.filter((item) => item.content_type === ContentType.File) as FileItem[]
@@ -312,12 +332,22 @@ const FilesTableView = ({ application, filesController, featuresController, link
featuresController={featuresController}
linkingController={linkingController}
/>
<ContextMenuCell files={[file]} filesController={filesController} />
<ContextMenuCell
files={[file]}
filesController={filesController}
linkingController={linkingController}
navigationController={navigationController}
/>
</div>
)
},
selectionActions: (fileIds) => (
<ContextMenuCell files={files.filter((file) => fileIds.includes(file.uuid))} filesController={filesController} />
<ContextMenuCell
files={files.filter((file) => fileIds.includes(file.uuid))}
filesController={filesController}
linkingController={linkingController}
navigationController={navigationController}
/>
),
showSelectionActions: true,
})
@@ -347,6 +377,8 @@ const FilesTableView = ({ application, filesController, featuresController, link
shouldShowRenameOption={false}
shouldShowAttachOption={false}
selectedFiles={[contextMenuFile]}
linkingController={linkingController}
navigationController={navigationController}
/>
</Menu>
</Popover>
@@ -5,13 +5,22 @@ import { useCallback } from 'react'
import FileOptionsPanel from '../FileContextMenu/FileOptionsPanel'
import { FilesController } from '@/Controllers/FilesController'
import { SelectedItemsController } from '@/Controllers/SelectedItemsController'
import { NavigationController } from '@/Controllers/Navigation/NavigationController'
import { LinkingController } from '@/Controllers/LinkingController'
type Props = {
filesController: FilesController
selectionController: SelectedItemsController
linkingController: LinkingController
navigationController: NavigationController
}
const MultipleSelectedFiles = ({ filesController, selectionController }: Props) => {
const MultipleSelectedFiles = ({
filesController,
selectionController,
linkingController,
navigationController,
}: Props) => {
const count = selectionController.selectedFilesCount
const cancelMultipleSelection = useCallback(() => {
@@ -23,7 +32,12 @@ const MultipleSelectedFiles = ({ filesController, selectionController }: Props)
<div className="flex w-full items-center justify-between p-4">
<h1 className="m-0 text-lg font-bold">{count} selected files</h1>
<div>
<FileOptionsPanel filesController={filesController} selectionController={selectionController} />
<FileOptionsPanel
filesController={filesController}
selectionController={selectionController}
linkingController={linkingController}
navigationController={navigationController}
/>
</div>
</div>
<div className="flex min-h-full w-full max-w-md flex-grow flex-col items-center justify-center">
@@ -118,6 +118,8 @@ class NoteGroupView extends AbstractComponent<Props, State> {
<MultipleSelectedFiles
filesController={this.viewControllerManager.filesController}
selectionController={this.viewControllerManager.selectionController}
navigationController={this.viewControllerManager.navigationController}
linkingController={this.viewControllerManager.linkingController}
/>
)}
{shouldNotShowMultipleSelectedItems && hasControllers && (
@@ -2,22 +2,28 @@ import { observer } from 'mobx-react-lite'
import { FunctionComponent, useCallback, useRef, useState } from 'react'
import Icon from '@/Components/Icon/Icon'
import { NavigationController } from '@/Controllers/Navigation/NavigationController'
import { NotesController } from '@/Controllers/NotesController/NotesController'
import { KeyboardKey } from '@standardnotes/ui-services'
import Popover from '../Popover/Popover'
import { IconType } from '@standardnotes/snjs'
import { classNames, DecryptedItemInterface, IconType, SNTag } from '@standardnotes/snjs'
import { getTitleForLinkedTag } from '@/Utils/Items/Display/getTitleForLinkedTag'
import { useApplication } from '../ApplicationProvider'
import MenuItem from '../Menu/MenuItem'
import Menu from '../Menu/Menu'
import { LinkingController } from '@/Controllers/LinkingController'
type Props = {
navigationController: NavigationController
notesController: NotesController
linkingController: LinkingController
selectedItems: DecryptedItemInterface[]
iconClassName: string
}
const AddTagOption: FunctionComponent<Props> = ({ navigationController, notesController, iconClassName }) => {
const AddTagOption: FunctionComponent<Props> = ({
navigationController,
linkingController,
selectedItems,
iconClassName,
}) => {
const application = useApplication()
const menuContainerRef = useRef<HTMLDivElement>(null)
const buttonRef = useRef<HTMLButtonElement>(null)
@@ -28,6 +34,18 @@ const AddTagOption: FunctionComponent<Props> = ({ navigationController, notesCon
setIsOpen((isOpen) => !isOpen)
}, [])
const isTagLinkedToSelectedItems = (tag: SNTag) => {
return selectedItems.every((item) => application.getItemTags(item).find((itemTag) => itemTag.uuid === tag.uuid))
}
const linkTagToSelectedItems = (tag: SNTag) => {
selectedItems.forEach((item) => linkingController.linkItems(item, tag))
}
const unlinkTagFromSelectedItems = (tag: SNTag) => {
selectedItems.forEach((item) => linkingController.unlinkItems(item, tag))
}
return (
<div ref={menuContainerRef}>
<MenuItem
@@ -53,15 +71,14 @@ const AddTagOption: FunctionComponent<Props> = ({ navigationController, notesCon
side="right"
align="start"
className="py-2"
overrideZIndex="z-modal"
>
<Menu a11yLabel="Tag selection menu" isOpen={isOpen}>
{navigationController.tags.map((tag) => (
<MenuItem
key={tag.uuid}
onClick={() => {
notesController.isTagInSelectedNotes(tag)
? notesController.removeTagFromSelectedNotes(tag).catch(console.error)
: notesController.addTagToSelectedNotes(tag).catch(console.error)
isTagLinkedToSelectedItems(tag) ? unlinkTagFromSelectedItems(tag) : linkTagToSelectedItems(tag)
}}
>
{tag.iconString && (
@@ -72,8 +89,10 @@ const AddTagOption: FunctionComponent<Props> = ({ navigationController, notesCon
/>
)}
<span
className={`overflow-hidden overflow-ellipsis whitespace-nowrap
${notesController.isTagInSelectedNotes(tag) ? 'font-bold' : ''}`}
className={classNames(
'overflow-hidden overflow-ellipsis whitespace-nowrap',
isTagLinkedToSelectedItems(tag) ? 'font-bold' : '',
)}
>
{getTitleForLinkedTag(tag, application)?.longTitle}
</span>
@@ -42,6 +42,7 @@ const NotesOptions = ({
application,
navigationController,
notesController,
linkingController,
historyModalController,
closeMenu,
}: NotesOptionsProps) => {
@@ -214,7 +215,8 @@ const NotesOptions = ({
<AddTagOption
iconClassName={iconClass}
navigationController={navigationController}
notesController={notesController}
selectedItems={notes}
linkingController={linkingController}
/>
)}
<MenuItem
@@ -11,15 +11,17 @@ import { ItemListController } from './ItemListController'
import { ItemsReloadSource } from './ItemsReloadSource'
describe('item list controller', () => {
let application: WebApplication
let controller: ItemListController
let navigationController: NavigationController
let selectionController: SelectedItemsController
beforeEach(() => {
const application = {} as jest.Mocked<WebApplication>
application = {} as jest.Mocked<WebApplication>
application.streamItems = jest.fn()
application.addEventObserver = jest.fn()
application.addWebEventObserver = jest.fn()
application.isNativeMobileWeb = jest.fn().mockReturnValue(false)
navigationController = {} as jest.Mocked<NavigationController>
selectionController = {} as jest.Mocked<SelectedItemsController>
@@ -50,6 +52,12 @@ describe('item list controller', () => {
})
})
it('should return false is platform is native mobile web', () => {
application.isNativeMobileWeb = jest.fn().mockReturnValue(true)
expect(controller.shouldSelectFirstItem(ItemsReloadSource.TagChange)).toBe(false)
})
it('should return false first item is file', () => {
controller.getFirstNonProtectedItem = jest.fn().mockReturnValue({
content_type: ContentType.File,
@@ -414,6 +414,10 @@ export class ItemListController extends AbstractViewController implements Intern
}
shouldSelectFirstItem = (itemsReloadSource: ItemsReloadSource) => {
if (this.application.isNativeMobileWeb()) {
return false
}
const item = this.getFirstNonProtectedItem()
if (item && isFile(item)) {
return false
@@ -196,10 +196,13 @@ export class NavigationController
}
hydrateFromPersistedValue = (state: NavigationControllerPersistableValue | undefined) => {
if (!state) {
const uuidsToPreventHydrationOf: string[] = [SystemViewId.Files]
if (!state || uuidsToPreventHydrationOf.includes(state.selectedTagUuid)) {
void this.selectHomeNavigationView()
return
}
if (state.selectedTagUuid) {
this.selectedUuid = state.selectedTagUuid
this.selectHydratedTagOrDefault()
@@ -11,6 +11,7 @@ import {
InternalEventBus,
isFile,
Uuids,
isNote,
} from '@standardnotes/snjs'
import { SelectionControllerPersistableValue } from '@standardnotes/ui-services'
import { action, computed, makeObservable, observable, reaction, runInAction } from 'mobx'
@@ -77,8 +78,14 @@ export class SelectedItemsController
if (!state) {
return
}
if (!this.selectedUuids.size && state.selectedUuids.length > 0) {
void this.selectUuids(state.selectedUuids)
if (!this.application.options.allowNoteSelectionStatePersistence) {
const items = this.application.items.findItems(state.selectedUuids).filter((item) => !isNote(item))
void this.selectUuids(Uuids(items))
} else {
void this.selectUuids(state.selectedUuids)
}
}
}
@@ -264,20 +271,22 @@ export class SelectedItemsController
log(LoggingDomain.Selection, 'Select item', item.uuid)
const supportsMultipleSelection = this.application.options.allowMultipleSelection
const hasMeta = this.keyboardService.activeModifiers.has(KeyboardModifier.Meta)
const hasCtrl = this.keyboardService.activeModifiers.has(KeyboardModifier.Ctrl)
const hasShift = this.keyboardService.activeModifiers.has(KeyboardModifier.Shift)
const hasMoreThanOneSelected = this.selectedItemsCount > 1
const isAuthorizedForAccess = await this.application.protections.authorizeItemAccess(item)
if (userTriggered && (hasMeta || hasCtrl)) {
if (supportsMultipleSelection && userTriggered && (hasMeta || hasCtrl)) {
if (this.selectedUuids.has(uuid) && hasMoreThanOneSelected) {
this.removeSelectedItem(uuid)
} else if (isAuthorizedForAccess) {
this.setSelectedUuids(this.selectedUuids.add(uuid))
this.selectedUuids.add(uuid)
this.setSelectedUuids(this.selectedUuids)
this.lastSelectedItem = item
}
} else if (userTriggered && hasShift) {
} else if (supportsMultipleSelection && userTriggered && hasShift) {
await this.selectItemsRange({ selectedItem: item })
} else {
const shouldSelectNote = hasMoreThanOneSelected || !this.selectedUuids.has(uuid)