Browse Source

Fix spoiler link click

Fix attaching preloader to video
Fix displaying chat avatars
Fix contextmenu color in popups
master
Eduard Kuzmenko 2 years ago
parent
commit
3144026fba
  1. 26
      src/components/appMediaViewerBase.ts
  2. 3
      src/lib/appManagers/appDownloadManager.ts
  3. 8
      src/lib/appManagers/appManagersManager.ts
  4. 8
      src/lib/appManagers/appMessagesManager.ts
  5. 24
      src/lib/appManagers/createManagers.ts
  6. 7
      src/lib/appManagers/manager.ts
  7. 1
      src/lib/mtproto/apiFileManager.ts
  8. 4
      src/lib/mtproto/apiManager.ts
  9. 2
      src/lib/storages/peers.ts
  10. 4
      src/scss/partials/_spoiler.scss
  11. 3
      src/scss/style.scss

26
src/components/appMediaViewerBase.ts

@ -1374,16 +1374,6 @@ export default class AppMediaViewerBase< @@ -1374,16 +1374,6 @@ export default class AppMediaViewerBase<
}
});
video.addEventListener('error', () => {
if(video.error.code !== 4) {
this.log.error("Error " + video.error.code + "; details: " + video.error.message);
}
if(preloader) {
preloader.detach();
}
}, {once: true});
this.addEventListener('setMoverAfter', () => {
video.src = '';
video.load();
@ -1491,6 +1481,7 @@ export default class AppMediaViewerBase< @@ -1491,6 +1481,7 @@ export default class AppMediaViewerBase<
if(supportsStreaming) {
onAnimationEnd.then(() => {
if(video.readyState < video.HAVE_FUTURE_DATA) {
console.log('ppp 1');
preloader.attach(mover, true);
}
@ -1501,7 +1492,7 @@ export default class AppMediaViewerBase< @@ -1501,7 +1492,7 @@ export default class AppMediaViewerBase<
const attachCanPlay = () => {
video.addEventListener('canplay', () => {
//this.log('video waited and progress loaded');
console.log('ppp 2');
preloader.detach();
video.parentElement.classList.remove('is-buffering');
}, {once: true});
@ -1515,6 +1506,7 @@ export default class AppMediaViewerBase< @@ -1515,6 +1506,7 @@ export default class AppMediaViewerBase<
if(loading && isntEnoughData) {
attachCanPlay();
console.log('ppp 3');
preloader.attach(mover, true);
// поставлю класс для плеера, чтобы убрать большую иконку пока прелоадер на месте
@ -1542,6 +1534,7 @@ export default class AppMediaViewerBase< @@ -1542,6 +1534,7 @@ export default class AppMediaViewerBase<
if(!supportsStreaming) {
onAnimationEnd.then(async() => {
if(!(await getCacheContext()).url) {
console.log('ppp 4');
preloader.attach(mover, true, promise);
}
});
@ -1554,6 +1547,17 @@ export default class AppMediaViewerBase< @@ -1554,6 +1547,17 @@ export default class AppMediaViewerBase<
}
const url = (await getCacheContext()).url;
video.addEventListener('error', () => {
if(video.error.code !== 4) {
this.log.error("Error " + video.error.code + "; details: " + video.error.message);
}
if(preloader) {
preloader.detach();
}
}, {once: true});
if(target instanceof SVGSVGElement/* && (video.parentElement || !isSafari) */) { // if video exists
//if(!video.parentElement) {
div.firstElementChild.lastElementChild.append(video);

3
src/lib/appManagers/appDownloadManager.ts

@ -159,9 +159,6 @@ export class AppDownloadManager { @@ -159,9 +159,6 @@ export class AppDownloadManager {
public downloadMedia(options: DownloadMediaOptions, type: DownloadType = 'blob'): DownloadBlob {
const {downloadOptions, fileName} = getDownloadMediaDetails(options);
if(fileName === 'document_5307720352468571676') {
debugger;
}
return this.d(fileName, () => {
const cb = type === 'url' ? this.managers.apiFileManager.downloadMediaURL : (type === 'void' ? this.managers.apiFileManager.downloadMediaVoid : this.managers.apiFileManager.downloadMedia);

8
src/lib/appManagers/appManagersManager.ts

@ -58,13 +58,7 @@ export class AppManagersManager { @@ -58,13 +58,7 @@ export class AppManagersManager {
this.cryptoPortPromise
]);
const managers = await createManagers(appStoragesManager);
// костыль
if(appStateManager.userId) {
managers.apiManager.setUserAuth(appStateManager.userId);
}
const managers = await createManagers(appStoragesManager, appStateManager.userId);
return this.managers = managers;
}

8
src/lib/appManagers/appMessagesManager.ts

@ -2634,7 +2634,9 @@ export class AppMessagesManager extends AppManager { @@ -2634,7 +2634,9 @@ export class AppMessagesManager extends AppManager {
message.reply_to.reply_to_msg_id = message.reply_to_mid = generateMessageId(message.reply_to.reply_to_msg_id);
}
if(message.reply_to.reply_to_top_id) message.reply_to.reply_to_top_id = generateMessageId(message.reply_to.reply_to_top_id);
if(message.reply_to.reply_to_top_id) {
message.reply_to.reply_to_top_id = generateMessageId(message.reply_to.reply_to_top_id);
}
}
const replies = isMessage && message.replies;
@ -2649,9 +2651,9 @@ export class AppMessagesManager extends AppManager { @@ -2649,9 +2651,9 @@ export class AppMessagesManager extends AppManager {
}
//storage.generateIndex(message);
const myId = this.appUsersManager.getSelf().id.toPeerId();
const myId = this.appPeersManager.peerId;
const fwdHeader = isMessage && (message as Message.message).fwd_from as MessageFwdHeader;
const fwdHeader = isMessage && (message as Message.message).fwd_from;
message.peerId = peerId;
if(peerId === myId/* && !message.from_id && !message.fwd_from */) {

24
src/lib/appManagers/createManagers.ts

@ -42,8 +42,9 @@ import { TimeManager } from "../mtproto/timeManager"; @@ -42,8 +42,9 @@ import { TimeManager } from "../mtproto/timeManager";
import { AppStoragesManager } from "./appStoragesManager";
import cryptoMessagePort from "../crypto/cryptoMessagePort";
import appStateManager from "./appStateManager";
import filterUnique from "../../helpers/array/filterUnique";
export default function createManagers(appStoragesManager: AppStoragesManager) {
export default function createManagers(appStoragesManager: AppStoragesManager, userId: UserId) {
const managers = {
appPeersManager: new AppPeersManager,
appChatsManager: new AppChatsManager,
@ -101,13 +102,26 @@ export default function createManagers(appStoragesManager: AppStoragesManager) { @@ -101,13 +102,26 @@ export default function createManagers(appStoragesManager: AppStoragesManager) {
ctx[name] = manager;
}
const promises: Array<Promise<any> | void>[] = [];
for(const name in managers) {
const manager = managers[name as keyof T];
if(userId) {
managers.apiManager.setUserAuth(userId);
}
const promises: Array<Promise<(() => void) | void> | void>[] = [];
let names = Object.keys(managers) as (keyof T)[];
names.unshift('appUsersManager', 'appChatsManager', 'appMessagesManager', 'dialogsStorage');
names = filterUnique(names);
for(const name of names) {
const manager = managers[name];
if((manager as any)?.after) {
// console.log('injecting after', name);
const result = (manager as any).after();
promises.push(result);
delete (manager as any).after;
// if(result instanceof Promise) {
// result.then(() => {
// console.log('injected after', name);
// });
// }
}
}

7
src/lib/appManagers/manager.ts

@ -89,9 +89,4 @@ export class AppManager { @@ -89,9 +89,4 @@ export class AppManager {
Object.assign(this, managers);
// this.after();
}
protected after(): Promise<void> | void {
}
}
}

1
src/lib/mtproto/apiFileManager.ts

@ -33,6 +33,7 @@ import getFileNameForUpload from "../../helpers/getFileNameForUpload"; @@ -33,6 +33,7 @@ import getFileNameForUpload from "../../helpers/getFileNameForUpload";
import type { Progress } from "../appManagers/appDownloadManager";
import getDownloadMediaDetails from "../appManagers/utils/download/getDownloadMediaDetails";
import networkStats from "./networkStats";
import pause from "../../helpers/schedulers/pause";
type Delayed = {
offset: number,

4
src/lib/mtproto/apiManager.ts

@ -242,6 +242,8 @@ export class ApiManager extends ApiManagerMethods { @@ -242,6 +242,8 @@ export class ApiManager extends ApiManagerMethods {
userAuth = {dcID: 0, date: Date.now() / 1000 | 0, id: userAuth.toPeerId(false)};
}
this.rootScope.dispatchEvent('user_auth', userAuth);
if(!userAuth.dcID) {
const baseDcId = await this.getBaseDcId();
userAuth.dcID = baseDcId;
@ -252,8 +254,6 @@ export class ApiManager extends ApiManagerMethods { @@ -252,8 +254,6 @@ export class ApiManager extends ApiManagerMethods {
});
//this.telegramMeNotify(true);
this.rootScope.dispatchEvent('user_auth', userAuth);
}
public setBaseDcId(dcId: DcId) {

2
src/lib/storages/peers.ts

@ -22,7 +22,7 @@ class PeersStorage { @@ -22,7 +22,7 @@ class PeersStorage {
protected after() {
this.rootScope.addEventListener('user_auth', () => {
this.requestPeer(this.appUsersManager.userId.toPeerId(), 'self');
this.requestPeer(this.appPeersManager.peerId, 'self');
});
}

4
src/scss/partials/_spoiler.scss

@ -67,6 +67,10 @@ @@ -67,6 +67,10 @@
&:not(.is-spoiler-visible) {
.spoiler {
cursor: pointer;
&-text {
pointer-events: none;
}
}
}
}

3
src/scss/style.scss

@ -94,7 +94,6 @@ $chat-input-inner-padding-handhelds: .25rem; @@ -94,7 +94,6 @@ $chat-input-inner-padding-handhelds: .25rem;
--disabled-opacity: .3;
--round-video-size: 280px;
--menu-box-shadow: 0px 0px 10px var(--menu-box-shadow-color);
--menu-background-color: rgba(var(--surface-color-rgb), .75);
--menu-backdrop-filter: blur(50px);
--font-monospace: 'Roboto Mono', monospace;
--font-weight-bold: 500;
@ -208,6 +207,7 @@ $chat-input-inner-padding-handhelds: .25rem; @@ -208,6 +207,7 @@ $chat-input-inner-padding-handhelds: .25rem;
--spoiler-background-color: #e3e5e8;
--spoiler-draft-background-color: #d9d9d9;
--monospace-text-color: var(--danger-color);
--menu-background-color: rgba(var(--surface-color-rgb), .75);
--message-background-color: var(--surface-color);
--message-checkbox-color: #61c642;
@ -281,6 +281,7 @@ $chat-input-inner-padding-handhelds: .25rem; @@ -281,6 +281,7 @@ $chat-input-inner-padding-handhelds: .25rem;
--spoiler-background-color: #373e4e;
--spoiler-draft-background-color: #484848;
--monospace-text-color: var(--primary-text-color);
--menu-background-color: rgba(var(--surface-color-rgb), .75);
--message-background-color: var(--surface-color);
--message-checkbox-color: var(--primary-color);

Loading…
Cancel
Save