|
| 1 | +import {css, html} from 'lit'; |
| 2 | + |
| 3 | +import {CustomElement, InjectAfter, InjectionMode} from '../injectors'; |
| 4 | +import {FloatElement} from '../custom'; |
| 5 | +import '../common/ui/steam-button'; |
| 6 | +import {ClientSend} from '../../bridge/client'; |
| 7 | +import {state} from 'lit/decorators.js'; |
| 8 | +import {FetchPendingTrades} from '../../bridge/handlers/fetch_pending_trades'; |
| 9 | +import {HasPermissions} from '../../bridge/handlers/has_permissions'; |
| 10 | + |
| 11 | +@CustomElement() |
| 12 | +@InjectAfter( |
| 13 | + '.maincontent .profile_leftcol .nonresponsive_hidden:not(.responsive_createtradeoffer)', |
| 14 | + InjectionMode.ONCE |
| 15 | +) |
| 16 | +export class AutoTrackWidget extends FloatElement { |
| 17 | + @state() |
| 18 | + show = false; |
| 19 | + |
| 20 | + static styles = [ |
| 21 | + ...FloatElement.styles, |
| 22 | + css` |
| 23 | + .container { |
| 24 | + margin-top: 10px; |
| 25 | + margin-bottom: 10px; |
| 26 | + padding: 15px; |
| 27 | + background-color: rgb(48, 48, 48); |
| 28 | + color: white; |
| 29 | + display: flex; |
| 30 | + justify-content: space-between; |
| 31 | + align-items: center; |
| 32 | + } |
| 33 | +
|
| 34 | + .container.warning { |
| 35 | + background-color: rgb(179, 0, 0); |
| 36 | + } |
| 37 | +
|
| 38 | + .float-icon { |
| 39 | + float: left; |
| 40 | + } |
| 41 | +
|
| 42 | + .item-name { |
| 43 | + font-size: 18px; |
| 44 | + margin-left: 15px; |
| 45 | + line-height: 32px; |
| 46 | + } |
| 47 | +
|
| 48 | + .sale-info { |
| 49 | + padding-left: 45px; |
| 50 | + color: darkgrey; |
| 51 | + } |
| 52 | + `, |
| 53 | + ]; |
| 54 | + |
| 55 | + async connectedCallback() { |
| 56 | + super.connectedCallback(); |
| 57 | + |
| 58 | + try { |
| 59 | + await ClientSend(FetchPendingTrades, {}); |
| 60 | + |
| 61 | + const hasPermissions = await ClientSend(HasPermissions, {permissions: ['cookies', 'alarms']}); |
| 62 | + if (!hasPermissions) { |
| 63 | + this.show = true; |
| 64 | + } |
| 65 | + } catch (e) { |
| 66 | + console.info('user is not logged into CSFloat'); |
| 67 | + } |
| 68 | + } |
| 69 | + |
| 70 | + render() { |
| 71 | + return this.show |
| 72 | + ? html` |
| 73 | + <div class="container" style="margin: 20px 0 20px 0;"> |
| 74 | + <div> |
| 75 | + <div class="float-icon"> |
| 76 | + <img |
| 77 | + src="https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/79/798a12316637ad8fbb91ddb7dc63f770b680bd19_full.jpg" |
| 78 | + style="height: 32px;" |
| 79 | + /> |
| 80 | + </div> |
| 81 | + <span class="item-name"> Automatically Track Offers </span> |
| 82 | + <div class="sale-info">Allow CSFloat Market to automatically track and create offers.</div> |
| 83 | + </div> |
| 84 | + <csfloat-steam-button |
| 85 | + id="csfloat-enable-tracking" |
| 86 | + .text="${'Enable Tracking'}" |
| 87 | + ></csfloat-steam-button> |
| 88 | + </div> |
| 89 | + ` |
| 90 | + : html``; |
| 91 | + } |
| 92 | +} |
0 commit comments